OBT::TypedAttribute< TOwner, TAttribute > Class Template Reference

#include <OBTTypedAttribute.h>

Inheritance diagram for OBT::TypedAttribute< TOwner, TAttribute >:

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

Collaboration graph
[legend]

List of all members.

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 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


Detailed Description

template<class TOwner, class TAttribute>
class OBT::TypedAttribute< TOwner, TAttribute >

Template class for inspectable attributes giving access to non primitive data types.

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

Definition at line 19 of file OBTTypedAttribute.h.


Member Typedef Documentation

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

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

template<class TOwner, class TAttribute>
typedef const TAttribute& OBT::TypedAttribute< TOwner, TAttribute >::value_type

Definition at line 29 of file OBTTypedAttribute.h.

template<class TOwner, class TAttribute>
typedef TOwner OBT::TypedAttribute< TOwner, TAttribute >::owner_type

Definition at line 30 of file OBTTypedAttribute.h.


Constructor & Destructor Documentation

template<class TOwner, class TAttribute>
OBT::TypedAttribute< TOwner, TAttribute >::TypedAttribute ( 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

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         }

template<class TOwner, class TAttribute>
OBT::TypedAttribute< TOwner, TAttribute >::~TypedAttribute (  )  [inline, virtual]

destructor

Definition at line 109 of file OBTTypedAttribute.h.

00110         {
00111 
00112         }


Member Function Documentation

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

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 const reference to the attribute value

Definition at line 129 of file OBTTypedAttribute.h.

References OBT::TypedAttribute< TOwner, TAttribute >::_getter.

00130         {
00131                 return ( owner.*_getter )() ;
00132         }

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

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

template<class TOwner, class TAttribute>
bool OBT::TypedAttribute< TOwner, TAttribute >::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 119 of file OBTTypedAttribute.h.

References OBT::TypedAttribute< TOwner, TAttribute >::_setter.

Referenced by OBT::TypedAttribute< TOwner, TAttribute >::setValue().

00120         {
00121                 return ( _setter == NULL ) ;
00122         }

template<class TOwner, class TAttribute>
const OBT::RTTI & OBT::TypedAttribute< TOwner, TAttribute >::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 150 of file OBTTypedAttribute.h.

00151         {
00152                 return TOwner::getClassRTTI() ;
00153         }

template<class TOwner, class TAttribute>
const RTTI & OBT::TypedAttribute< TOwner, TAttribute >::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 160 of file OBTTypedAttribute.h.

00161         {
00162                 return TAttribute::getClassRTTI() ;
00163         }

template<class TOwner, class TAttribute>
const RTTI & OBT::TypedAttribute< TOwner, TAttribute >::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 170 of file OBTTypedAttribute.h.

00171         {
00172                 return TAttribute::getClassRTTI() ;
00173         }


Member Data Documentation

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

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


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