OpendTect-6_4  6.4
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 setParam (O *obj, const V &val)
 
bool setParamIfValueIs (O *obj, const V &curval, const V &newval)
 
const V & getParam (const O *obj) const
 
bool hasParam (const O *obj) const
 
void removeParam (O *obj)
 
void removeAndDeleteParam (O *obj)
 
void deleteAndZeroPtrParam (O *obj)
 

Protected Attributes

ObjectSet< O > objects_
 
TypeSet< V > params_
 
Threads::Lock lock_
 
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 );

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

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

Member Function Documentation

template<class O , class V >
void HiddenParam< O, V >::deleteAndZeroPtrParam ( O *  obj)
template<class O , class V >
const V & HiddenParam< O, V >::getParam ( const O *  obj) const
template<class O , class V >
bool HiddenParam< O, V >::hasParam ( const O *  obj) const
template<class O , class V >
void HiddenParam< O, V >::removeAndDeleteParam ( O *  obj)
template<class O , class V >
void HiddenParam< O, V >::removeParam ( O *  obj)
template<class O , class V >
void HiddenParam< O, V >::setParam ( O *  obj,
const V &  val 
)
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

template<class O, class V>
Threads::Lock HiddenParam< O, V >::lock_
mutableprotected
template<class O, class V>
ObjectSet<O> HiddenParam< O, V >::objects_
protected
template<class O, class V>
TypeSet<V> HiddenParam< O, V >::params_
protected
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. 2019