OpendTect  7.0
Public Member Functions | Protected Attributes | List of all members
HiddenParam< O, V > Class Template Reference

Workaround manager when you cannot add class members to a class due to binary compability issues. More...

Public Member Functions

 HiddenParam (const V &undefval)
 
 ~HiddenParam ()
 
void deleteAndNullPtrParam (O *obj)
 
void deleteAndZeroPtrParam (O *obj)
 
const V & getParam (const O *obj) const
 
bool hasParam (const O *obj) const
 
void removeAndDeleteParam (O *obj)
 
void removeParam (O *obj)
 
void setParam (O *obj, const V &val)
 
bool setParamIfValueIs (O *obj, const V &curval, const V &newval)
 

Protected Attributes

Threads::Lock lock_
 
ObjectSet< O > objects_
 
TypeSet< V > params_
 
undef_
 

Detailed Description

template<class O, class V>
class HiddenParam< O, V >

Workaround manager when you cannot add class members to a class due to binary compability issues.

If you want to add the variable of type V to class O, do the following in the source-file:

HiddenParam<O,V> myparammanager( undef_val );
Workaround manager when you cannot add class members to a class due to binary compability issues.
Definition: hiddenparam.h:51

You can then access the variable in the source-file by:

myparammanager.setParam( this, new_value );

and retrieve it by

V value = myparammanager.getParam( this );
Note
V cannot be boolean. Use char instead. V must be 'simple' enough to be stored in a type-set. Also note you may not be able to call the removeParam (if the class does not already have a destructor), so so don't use with objects that are created millions of times in those cases, as you will leak memory. Finally, note that you MUST set the parameter in the constructor. The undef value is not ment to be returned, it's merely to keep the compiler happy.

<>

Constructor & Destructor Documentation

◆ HiddenParam()

template<class O , class V >
HiddenParam< O, V >::HiddenParam ( const V &  undefval)
inline

◆ ~HiddenParam()

template<class O , class V >
HiddenParam< O, V >::~HiddenParam

Member Function Documentation

◆ deleteAndNullPtrParam()

template<class O , class V >
void HiddenParam< O, V >::deleteAndNullPtrParam ( O *  obj)

◆ deleteAndZeroPtrParam()

template<class O , class V >
void HiddenParam< O, V >::deleteAndZeroPtrParam ( O *  obj)
inline

◆ getParam()

template<class O , class V >
const V & HiddenParam< O, V >::getParam ( const O *  obj) const

◆ hasParam()

template<class O , class V >
bool HiddenParam< O, V >::hasParam ( const O *  obj) const

◆ removeAndDeleteParam()

template<class O , class V >
void HiddenParam< O, V >::removeAndDeleteParam ( O *  obj)

◆ removeParam()

template<class O , class V >
void HiddenParam< O, V >::removeParam ( O *  obj)

◆ setParam()

template<class O , class V >
void HiddenParam< O, V >::setParam ( O *  obj,
const V &  val 
)

◆ setParamIfValueIs()

template<class O , class V >
bool HiddenParam< O, V >::setParamIfValueIs ( O *  obj,
const V &  curval,
const V &  newval 
)

Sets value if current value is equal to curval. Otherwise the value is not changed.

Returns
true if value is changed.

Member Data Documentation

◆ lock_

template<class O , class V >
Threads::Lock HiddenParam< O, V >::lock_
mutableprotected

◆ objects_

template<class O , class V >
ObjectSet<O> HiddenParam< O, V >::objects_
protected

◆ params_

template<class O , class V >
TypeSet<V> HiddenParam< O, V >::params_
protected

◆ undef_

template<class O , class V >
V HiddenParam< O, V >::undef_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2024