#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) | |
virtual | ~TypedAttribute () |
const TAttribute & | getValue (const TOwner &owner) const |
void | setValue (TOwner &owner, const TAttribute &value) const |
Inherited | |
bool | isReadOnly () const |
virtual const RTTI & | getOwnerRTTI () const |
virtual const RTTI & | getRTTI () const |
Static Public Member Functions | |
static const RTTI & | getClassRTTI () |
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 parameters :
Definition at line 19 of file OBTTypedAttribute.h.
typedef const TAttribute&( TOwner::* OBT::TypedAttribute< TOwner, TAttribute >::Getter)() const |
typedef void( TOwner::* OBT::TypedAttribute< TOwner, TAttribute >::Setter)(const TAttribute &value) |
typedef const TAttribute& OBT::TypedAttribute< TOwner, TAttribute >::value_type |
Definition at line 29 of file OBTTypedAttribute.h.
typedef TOwner OBT::TypedAttribute< TOwner, TAttribute >::owner_type |
Definition at line 30 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 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 }
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 }
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 }
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.
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.
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.
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().