OBT::AbstractAttribute Class Reference

Base class for inspectable attributes. More...

#include <OBTAbstractAttribute.h>

Inheritance diagram for OBT::AbstractAttribute:
[legend]
Collaboration diagram for OBT::AbstractAttribute:
[legend]

List of all members.

Public Member Functions

virtual ~AbstractAttribute ()
 destructor
const char * getName () const
 get the inspectable attribute name
virtual bool isReadOnly () const =0
 test if the attribute can be set
virtual const RTTIgetOwnerRTTI () const =0
 returns RTTI info associated with the owner of the attribute
virtual const RTTIgetRTTI () const
 Returns RTTI info associated with this class instance.

Static Public Member Functions

static const RTTIgetClassRTTI ()
 Returns RTTI info associated with this class type.

Protected Member Functions

 AbstractAttribute (const char *name)
 constructor

Static Private Member Functions

static void initRTTI ()
 Initialize RTTI information for this class.
static void destroyRTTI ()
 Called on application exit to destroy _rtti.

Private Attributes

std::string _name
 Attribute name.

Static Private Attributes

static RTTI_rtti
 RTTI information.

Detailed Description

Base class for inspectable attributes.

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

This class specifies the interface for all inspectable attributes. Note that you cannot set the value of an inspectable attribute if you reference it through the AbstractAttribute class without upcasting it to a proper type.

Definition at line 20 of file OBTAbstractAttribute.h.


Constructor & Destructor Documentation

AbstractAttribute::~AbstractAttribute (  )  [virtual]

destructor

Definition at line 30 of file OBTAbstractAttribute.cpp.

00031 {
00032 }

AbstractAttribute::AbstractAttribute ( const char *  name  )  [protected]

constructor

Parameters:
name name of this attribute.

Definition at line 13 of file OBTAbstractAttribute.cpp.

References _rtti, and initRTTI().

00014 :
00015 _name( name )
00016 {
00017         // On the contrary to all other classes supporting RTTI, this class stores RTTI
00018         // information as a pointer. This is to avoid a dependency cycle, since RTTI.h
00019         // includes AbstractAttribute.h
00020         if ( _rtti == NULL )
00021         {
00022                 // creating the first instance, initialize the RTTI.
00023                 initRTTI() ;
00024         }
00025 }


Member Function Documentation

void AbstractAttribute::destroyRTTI (  )  [static, private]

Called on application exit to destroy _rtti.

Definition at line 51 of file OBTAbstractAttribute.cpp.

References _rtti.

Referenced by initRTTI().

00052 {
00053         delete _rtti ;
00054 }

const RTTI & AbstractAttribute::getClassRTTI (  )  [static]
const char * OBT::AbstractAttribute::getName (  )  const [inline]

get the inspectable attribute name

Returns:
the name of the inspectable attribute

Definition at line 93 of file OBTAbstractAttribute.h.

References _name.

00094         {
00095                 return _name.c_str() ;
00096         }

virtual const RTTI& OBT::AbstractAttribute::getOwnerRTTI (  )  const [pure virtual]
const RTTI & AbstractAttribute::getRTTI (  )  const [virtual]
void AbstractAttribute::initRTTI (  )  [static, private]

Initialize RTTI information for this class.

Called on creation of the first instance, or on the first call to the static member method getClassRTTI if no instance has been created yet.

Definition at line 38 of file OBTAbstractAttribute.cpp.

References _rtti, destroyRTTI(), and OBT_DBG_ASSERT.

Referenced by AbstractAttribute(), and getClassRTTI().

00039 {
00040         OBT_DBG_ASSERT( _rtti == NULL ) ;
00041         _rtti = new RTTI( 2353935542, typeid( AbstractAttribute ).name(), NULL, 0 ) ;
00042         // _rtti must be destroyed on application exit.
00043         std::atexit( destroyRTTI ) ;
00044 }

virtual bool OBT::AbstractAttribute::isReadOnly (  )  const [pure virtual]

Member Data Documentation

std::string OBT::AbstractAttribute::_name [private]

Attribute name.

Definition at line 86 of file OBTAbstractAttribute.h.

Referenced by getName().

RTTI * AbstractAttribute::_rtti [static, private]

Generated on 1 Jan 2010 for OBT by  doxygen 1.6.1