OBT::PrimitiveAttribute< TOwner, TAttribute, typeID > Class Template Reference

#include <OBTPrimitiveAttribute.h>

Inheritance diagram for OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >:

Inheritance graph
[legend]
Collaboration diagram for OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >:

Collaboration graph
[legend]

List of all members.

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)
virtual ~PrimitiveAttribute ()
TAttribute getValue (const TOwner &owner) const
void setValue (TOwner &owner, TAttribute value) const
Inherited
bool isReadOnly () const
virtual const RTTIgetOwnerRTTI () const
virtual const RTTIgetRTTI () const

Static Public Member Functions

static const RTTIgetClassRTTI ()

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.


Detailed Description

template<class TOwner, class TAttribute, unsigned long typeID>
class OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >

Template class for inspectable attributes giving access to primitive data types (short, int, float, etc.).

Author:
Michaël Rouillé <michael.rouille@gmail.com>
Template parameters :

The accessors of the owner class use value parameters.

Definition at line 21 of file OBTPrimitiveAttribute.h.


Member Typedef Documentation

template<class TOwner, class TAttribute, unsigned long typeID>
typedef TAttribute( TOwner::* OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::Getter)() const

Getter function for primitive data types.

Definition at line 26 of file OBTPrimitiveAttribute.h.

template<class TOwner, class TAttribute, unsigned long typeID>
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.

template<class TOwner, class TAttribute, unsigned long typeID>
typedef TAttribute OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::value_type

Definition at line 30 of file OBTPrimitiveAttribute.h.

template<class TOwner, class TAttribute, unsigned long typeID>
typedef TOwner OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::owner_type

Definition at line 31 of file OBTPrimitiveAttribute.h.


Constructor & Destructor Documentation

template<class TOwner, class TAttribute, unsigned long typeID>
OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::PrimitiveAttribute ( const char *  name,
Getter  getter,
Setter  setter 
) [inline]

constructor

Parameters:
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
Exceptions:
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         }

template<class TOwner, class TAttribute, unsigned long typeID>
OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::~PrimitiveAttribute (  )  [inline, virtual]

destructor

Definition at line 122 of file OBTPrimitiveAttribute.h.

00123         {   
00124         }


Member Function Documentation

template<class TOwner, class TAttribute, unsigned long typeID>
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).

Parameters:
owner reference to the class instance from which the attribute value must be retrieved
Exceptions:
OBT_Exception [DEBUG only] if TOwner is not a base class of owner.
Returns:
a copy of the attribute value

Definition at line 141 of file OBTPrimitiveAttribute.h.

References OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::_getter.

00142         {
00143                 return ( owner.*_getter )() ;
00144         }

template<class TOwner, class TAttribute, unsigned long typeID>
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.

Parameters:
owner reference to the class instance from which the attribute value must be setted
Exceptions:
OBT_Exception [DEBUG only] if :
  • This instance corresponds to a read-only attribute.
  • TOwner is not a base class of owner.
Parameters:
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         }

template<class TOwner, class TAttribute, unsigned long typeID>
bool OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::isReadOnly (  )  const [inline, virtual]

test if the attribute can be set

Returns:
false if the setValue method can be called on the attribute, true otherwise

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         }

template<class TOwner, class TAttribute, unsigned long typeID>
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getOwnerRTTI (  )  const [inline, virtual]

returns RTTI info associated with the owner of the attribute

Returns:
RTTI info associated with the owner of the attribute

Implements OBT::AbstractAttribute.

Definition at line 163 of file OBTPrimitiveAttribute.h.

00164         {
00165                 return TOwner::getClassRTTI() ;
00166         }

template<class TOwner, class TAttribute, unsigned long typeID>
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getRTTI (  )  const [inline, virtual]

Returns RTTI info associated with this class instance

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         }

template<class TOwner, class TAttribute, unsigned long typeID>
const RTTI & OBT::PrimitiveAttribute< TOwner, TAttribute, typeID >::getClassRTTI (  )  [inline, static]

Returns RTTI info associated with this class type

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.

00184         {
00185                 return _rtti ;
00186         }


Member Data Documentation

template<class TOwner, class TAttribute, unsigned long typeID>
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().

template<class TOwner, class TAttribute, unsigned long typeID>
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().

template<class TOwner, class TAttribute, unsigned long typeID>
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().


Generated on Wed Oct 1 11:34:18 2008 for OBT by  doxygen 1.5.3