Template class for inspectable attributes giving access to non primitive data types. More...
#include <OBTTypedAttribute.h>
Public Types | |
typedef const TAttribute &(TOwner::* | Getter )() const |
Getter function for non primitive data types. | |
typedef void(TOwner::* | Setter )(const TAttribute &value) |
Setter function for non primitive data types. | |
typedef const TAttribute & | value_type |
typedef TOwner | owner_type |
Public Member Functions | |
TypedAttribute (const char *name, Getter getter, Setter setter) | |
constructor | |
virtual | ~TypedAttribute () |
destructor | |
const TAttribute & | getValue (const TOwner &owner) const |
get the value of the inspectable attribute | |
void | setValue (TOwner &owner, const TAttribute &value) const |
set accessor to the value of the inspectable attribute | |
Inherited | |
bool | isReadOnly () const |
test if the attribute can be set | |
virtual const RTTI & | getOwnerRTTI () const |
returns RTTI info associated with the owner of the attribute | |
virtual const RTTI & | getRTTI () const |
Returns RTTI info associated with this class instance. | |
Static Public Member Functions | |
static const RTTI & | getClassRTTI () |
Returns RTTI info associated with this class type. | |
Private Attributes | |
Getter | _getter |
pointer to the owner's get accessor to the attribute value | |
Setter | _setter |
pointer to the owner's set accessor to the attribute value |
Template class for inspectable attributes giving access to non primitive data types.
Template parameters :
Definition at line 19 of file OBTTypedAttribute.h.
typedef const TAttribute&( TOwner::* OBT::TypedAttribute< TOwner, TAttribute >::Getter)() const |
Getter function for non primitive data types.
Definition at line 25 of file OBTTypedAttribute.h.
typedef TOwner OBT::TypedAttribute< TOwner, TAttribute >::owner_type |
Definition at line 30 of file OBTTypedAttribute.h.
typedef void( TOwner::* OBT::TypedAttribute< TOwner, TAttribute >::Setter)(const TAttribute &value) |
Setter function for non primitive data types.
Definition at line 27 of file OBTTypedAttribute.h.
typedef const TAttribute& OBT::TypedAttribute< TOwner, TAttribute >::value_type |
Definition at line 29 of file OBTTypedAttribute.h.
OBT::TypedAttribute< TOwner, TAttribute >::TypedAttribute | ( | const char * | name, | |
Getter | getter, | |||
Setter | setter | |||
) | [inline] |
constructor
name | attribute name | |
getter | pointer to the owner's get accessor to the attribute value | |
setter | pointer to the owner's set accessor to the attribute value |
Definition at line 96 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::_getter, and OBT_DBG_ASSERT.
00097 : 00098 AbstractAttribute( name ), 00099 _getter( getter ), 00100 _setter( setter ) 00101 { 00102 OBT_DBG_ASSERT( _getter != NULL ) ; 00103 }
OBT::TypedAttribute< TOwner, TAttribute >::~TypedAttribute | ( | ) | [inline, virtual] |
const RTTI & OBT::TypedAttribute< TOwner, TAttribute >::getClassRTTI | ( | ) | [inline, static] |
Returns RTTI info associated with this class type.
Reimplemented from OBT::AbstractAttribute.
Definition at line 170 of file OBTTypedAttribute.h.
Referenced by OBT::TypedAttribute< TOwner, TAttribute >::getOwnerRTTI(), and OBT::TypedAttribute< TOwner, TAttribute >::getRTTI().
00171 { 00172 return TAttribute::getClassRTTI() ; 00173 }
const OBT::RTTI & OBT::TypedAttribute< TOwner, TAttribute >::getOwnerRTTI | ( | ) | const [inline, virtual] |
returns RTTI info associated with the owner of the attribute
Implements OBT::AbstractAttribute.
Definition at line 150 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::getClassRTTI().
00151 { 00152 return TOwner::getClassRTTI() ; 00153 }
const RTTI & OBT::TypedAttribute< TOwner, TAttribute >::getRTTI | ( | ) | const [inline, virtual] |
Returns RTTI info associated with this class instance.
Reimplemented from OBT::AbstractAttribute.
Definition at line 160 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::getClassRTTI().
00161 { 00162 return TAttribute::getClassRTTI() ; 00163 }
const TAttribute & OBT::TypedAttribute< TOwner, TAttribute >::getValue | ( | const TOwner & | owner | ) | const [inline] |
get the value of the inspectable attribute
Note that if you use the same TypedAttribute instance to get an inspectable attribute's values for several objects, the reference retrieved from previous calls to getValue will be affected by the following calls. In such situation, if you wish to re-use the retrieved value, copy the retrieved reference into another instance of the corresponding inspectable type (or directly into a variable of the corresponding primitive data type).
owner | reference to the class instance from which the attribute value must be retrieved |
OBT_Exception | [DEBUG only] if TOwner is not a base class of owner. |
Definition at line 129 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::_getter.
00130 { 00131 return ( owner.*_getter )() ; 00132 }
bool OBT::TypedAttribute< TOwner, TAttribute >::isReadOnly | ( | ) | const [inline, virtual] |
test if the attribute can be set
Implements OBT::AbstractAttribute.
Definition at line 119 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::_setter.
Referenced by OBT::TypedAttribute< TOwner, TAttribute >::setValue().
00120 { 00121 return ( _setter == NULL ) ; 00122 }
void OBT::TypedAttribute< TOwner, TAttribute >::setValue | ( | TOwner & | owner, | |
const TAttribute & | value | |||
) | const [inline] |
set accessor to the value of the inspectable attribute
It is an error to call this method if the attribute is read only, which leads to execution abortion in debug mode.
owner | reference to the class instance from which the attribute value must be setted | |
value | a reference to the value to assign to the attribute |
Definition at line 138 of file OBTTypedAttribute.h.
References OBT::TypedAttribute< TOwner, TAttribute >::_setter, OBT::TypedAttribute< TOwner, TAttribute >::isReadOnly(), and OBT_DBG_ASSERT.
00139 { 00140 // Cannot write to a read-only attribute. 00141 OBT_DBG_ASSERT( isReadOnly( ) == false ) ; 00142 ( owner.*_setter )( value ) ; 00143 }
Getter OBT::TypedAttribute< TOwner, TAttribute >::_getter [private] |
pointer to the owner's get accessor to the attribute value
Definition at line 86 of file OBTTypedAttribute.h.
Referenced by OBT::TypedAttribute< TOwner, TAttribute >::getValue(), and OBT::TypedAttribute< TOwner, TAttribute >::TypedAttribute().
Setter OBT::TypedAttribute< TOwner, TAttribute >::_setter [private] |
pointer to the owner's set accessor to the attribute value
Definition at line 89 of file OBTTypedAttribute.h.
Referenced by OBT::TypedAttribute< TOwner, TAttribute >::isReadOnly(), and OBT::TypedAttribute< TOwner, TAttribute >::setValue().