Template class for inspectable attributes giving access to primitive data types (short, int, float, etc. More...
#include <OBTPrimitiveAttribute.h>
Public Types | |
typedef TAttribute(TOwner::* | Getter )() const |
Getter function for primitive data types. | |
typedef void(TOwner::* | Setter )(TAttribute value) |
Setter function for primitive data types. | |
typedef TAttribute | value_type |
typedef TOwner | owner_type |
Public Member Functions | |
PrimitiveAttribute (const char *name, Getter getter, Setter setter) | |
constructor | |
virtual | ~PrimitiveAttribute () |
destructor | |
TAttribute | getValue (const TOwner &owner) const |
get the value of the inspectable attribute | |
void | setValue (TOwner &owner, 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 | |
Static Private Attributes | |
static const RTTI | _rtti |
RTTI structure. |
Template class for inspectable attributes giving access to primitive data types (short, int, float, etc.
).
Template parameters :
The accessors of the owner class use value parameters.
Definition at line 21 of file OBTPrimitiveAttribute.h.
typedef TAttribute( TOwner::* OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::Getter)() const |
Getter function for primitive data types.
Definition at line 26 of file OBTPrimitiveAttribute.h.
typedef TOwner OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::owner_type |
Definition at line 31 of file OBTPrimitiveAttribute.h.
typedef void( TOwner::* OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::Setter)(TAttribute value) |
Setter function for primitive data types.
Definition at line 28 of file OBTPrimitiveAttribute.h.
typedef TAttribute OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::value_type |
Definition at line 30 of file OBTPrimitiveAttribute.h.
OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::PrimitiveAttribute | ( | 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 |
an | OBT_Exception [DEBUG only] if getter is NULL. |
Definition at line 109 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_getter, and OBT_DBG_ASSERT.
00110 : 00111 AbstractAttribute( name ), 00112 _getter( getter ), 00113 _setter( setter ) 00114 { 00115 OBT_DBG_ASSERT( _getter != NULL ) ; 00116 }
OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::~PrimitiveAttribute | ( | ) | [inline, virtual] |
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getClassRTTI | ( | ) | [inline, static] |
Returns RTTI info associated with this class type.
Reimplemented from OBT::AbstractAttribute.
Definition at line 183 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_rtti.
Referenced by OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getOwnerRTTI().
00184 { 00185 return _rtti ; 00186 }
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getOwnerRTTI | ( | ) | const [inline, virtual] |
returns RTTI info associated with the owner of the attribute
Implements OBT::AbstractAttribute.
Definition at line 163 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getClassRTTI().
00164 { 00165 return TOwner::getClassRTTI() ; 00166 }
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getRTTI | ( | ) | const [inline, virtual] |
Returns RTTI info associated with this class instance.
Reimplemented from OBT::AbstractAttribute.
Definition at line 173 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_rtti.
00174 { 00175 return _rtti ; 00176 }
TAttribute OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getValue | ( | const TOwner & | owner | ) | const [inline] |
get the value of the inspectable attribute
Note that if you use the same PrimitiveAttribute 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 141 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_getter.
00142 { 00143 return ( owner.*_getter )() ; 00144 }
bool OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::isReadOnly | ( | ) | const [inline, virtual] |
test if the attribute can be set
Implements OBT::AbstractAttribute.
Definition at line 131 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_setter.
Referenced by OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::setValue().
00132 { 00133 return ( _setter == NULL ) ; 00134 }
void OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::setValue | ( | TOwner & | owner, | |
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 |
OBT_Exception | [DEBUG only] if :
|
value | a reference to the value to assign to the attribute |
Definition at line 151 of file OBTPrimitiveAttribute.h.
References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_setter, OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::isReadOnly(), and OBT_DBG_ASSERT.
00152 { 00153 // Cannot write to a read-only attribute. 00154 OBT_DBG_ASSERT( isReadOnly( ) == false ) ; 00155 ( owner.*_setter )( value ) ; 00156 }
Getter OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_getter [private] |
pointer to the owner's get accessor to the attribute value
Definition at line 91 of file OBTPrimitiveAttribute.h.
Referenced by OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getValue(), and OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::PrimitiveAttribute().
const RTTI OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_rtti [inline, static, private] |
RTTI structure.
Reimplemented from OBT::AbstractAttribute.
Definition at line 97 of file OBTPrimitiveAttribute.h.
Referenced by OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getClassRTTI(), and OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getRTTI().
Setter OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_setter [private] |
pointer to the owner's set accessor to the attribute value
Definition at line 94 of file OBTPrimitiveAttribute.h.
Referenced by OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::isReadOnly(), and OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::setValue().