OBTAbstractAttribute.cpp

Go to the documentation of this file.
00001 #include "OBTAbstractAttribute.h"
00002 #include "OBTRTTI.h"
00003 
00004 #include <typeinfo>
00005 
00006 using namespace OBT ;
00007 
00008 RTTI* AbstractAttribute::_rtti( NULL ) ;
00009 
00010 //-------------------------------------------------------------------------
00011 // AbstractAttribute
00012 //-------------------------------------------------------------------------
00013 AbstractAttribute::AbstractAttribute( const char* name )
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 }
00026 
00027 //-------------------------------------------------------------------------
00028 // ~AbstractAttribute
00029 //-------------------------------------------------------------------------
00030 AbstractAttribute::~AbstractAttribute( )
00031 {
00032 }
00033 
00034 //-------------------------------------------------------------------------
00035 // initRTTI
00036 //-------------------------------------------------------------------------
00037 void 
00038 AbstractAttribute::initRTTI()
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 }
00045 
00046 
00047 //-------------------------------------------------------------------------
00048 // destroyRTTI
00049 //-------------------------------------------------------------------------
00050 void 
00051 AbstractAttribute::destroyRTTI()
00052 {
00053         delete _rtti ;
00054 }
00055 
00056 //-------------------------------------------------------------------------
00057 // getClassRTTI
00058 //-------------------------------------------------------------------------
00059 const RTTI&
00060 AbstractAttribute::getClassRTTI()
00061 {
00062         if ( _rtti == NULL )
00063         {
00064                 // First call to getClassRTTI and no instance has been created yet :
00065                 // initialize RTTI.
00066                 initRTTI() ;
00067         }
00068         return *_rtti ;
00069 }
00070 
00071 //-------------------------------------------------------------------------
00072 // getRTTI
00073 //-------------------------------------------------------------------------
00074 const RTTI&
00075 AbstractAttribute::getRTTI() const
00076 {
00077         return *_rtti ;
00078 }
00079 

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