Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::TypeFactory Class Reference
[TypeSystem]

#include <OSGTypeFactory.h>

List of all members.

Types

typedef TypeNameMap::iterator TypeNameMapIt
typedef TypeNameMap::const_iterator TypeNameMapConstIt
typedef std::vector< TypeBase * > TypeStore
typedef TypeStore::iterator TypeStoreIt
typedef TypeStore::const_iterator TypeStoreConstIt
typedef std::vector< TypeNameMap * > TypeMapsStore
*typedef std::map< IDStringLink,
UInt32
TypeNameMap

Public Member Functions

Type Info
*UInt32 registerType (TypeBase *pType)
UInt32 findTypeId (const Char8 *szName, const UInt32 uiNameSpace=0)
TypeBasefindType (UInt32 uiTypeId)
TypeBasefindType (const Char8 *szName, const UInt32 uiNameSpace=0)
UInt32 getNumTypes (void)
void writeTypeGraph (const Char8 *szFilename)

Static Public Member Functions

Get
*static TypeFactorythe (void)

Protected Member Functions

Constructors
TypeFactory (void)
Destructor
*virtual ~TypeFactory (void)

Static Protected Member Functions

Helper
*static void writeTypeDot (FILE *pOut, TypeBase *pTypeBase)

Protected Attributes

Members
*TypeMapsStore _vTypeNameMaps
TypeStore _vTypeStore

Static Protected Attributes

Static Variables
*static TypeFactory_the = NULL

Private Member Functions

 TypeFactory (const TypeFactory &source)
 prohibit default function (move to 'public' if needed)
void operator= (const TypeFactory &source)
 prohibit default function (move to 'public' if needed)


Detailed Description

Definition at line 58 of file OSGTypeFactory.h.


Member Typedef Documentation

typedef TypeNameMap::iterator osg::TypeFactory::TypeNameMapIt [protected]
 

Definition at line 100 of file OSGTypeFactory.h.

typedef TypeNameMap::const_iterator osg::TypeFactory::TypeNameMapConstIt [protected]
 

Definition at line 101 of file OSGTypeFactory.h.

typedef std::vector<TypeBase *> osg::TypeFactory::TypeStore [protected]
 

Definition at line 104 of file OSGTypeFactory.h.

typedef TypeStore::iterator osg::TypeFactory::TypeStoreIt [protected]
 

Definition at line 106 of file OSGTypeFactory.h.

typedef TypeStore::const_iterator osg::TypeFactory::TypeStoreConstIt [protected]
 

Definition at line 107 of file OSGTypeFactory.h.

typedef std::vector<TypeNameMap *> osg::TypeFactory::TypeMapsStore [protected]
 

Definition at line 110 of file OSGTypeFactory.h.


Constructor & Destructor Documentation

TypeFactory::TypeFactory void   )  [protected]
 

Definition at line 224 of file OSGTypeFactory.cpp.

References _vTypeNameMaps, _vTypeStore, and TypeNameMap.

00224                              :
00225     _vTypeNameMaps(),
00226     _vTypeStore   ()
00227 {
00228     _vTypeStore.reserve  (512 );
00229     _vTypeStore.push_back(NULL);
00230 
00231     _vTypeNameMaps.push_back(new TypeNameMap);
00232 
00233 //    FactoryController::the()->registerTypeFactory(this);
00234 }

TypeFactory::~TypeFactory void   )  [protected, virtual]
 

Definition at line 239 of file OSGTypeFactory.cpp.

00240 {
00241 }

osg::TypeFactory::TypeFactory const TypeFactory source  )  [private]
 


Member Function Documentation

TypeFactory * TypeFactory::the void   )  [static]
 

Definition at line 61 of file OSGTypeFactory.cpp.

References _the.

Referenced by osg::TypeBase::TypeBase().

00062 {
00063     if(_the == NULL)
00064         _the = new TypeFactory;
00065 
00066     return _the;
00067 }

UInt32 TypeFactory::registerType TypeBase pType  ) 
 

findType(uiTypeId)->dump();

Definition at line 72 of file OSGTypeFactory.cpp.

References _vTypeNameMaps, _vTypeStore, FDEBUG, findType(), findTypeId(), osg::TypeBase::getCName(), osg::TypeBase::getName(), osg::TypeBase::getNameSpace(), osg::IDString::isEmpty(), PINFO, SWARNING, and TypeNameMap.

Referenced by osg::TypeBase::TypeBase().

00073 {
00074     UInt32 returnValue = 0;
00075 
00076     if(pType == NULL)
00077     {
00078         SWARNING << "no data store given" << std::endl;
00079 
00080         return returnValue;        
00081     }
00082 
00083     if(pType->getName().isEmpty() == true) 
00084     {
00085         SWARNING << "DataElementType without name" << std::endl;
00086 
00087         return returnValue;
00088     }
00089 
00090     UInt32 uiTypeId = findTypeId(pType->getCName    (),
00091                                  pType->getNameSpace());
00092 
00093     if(uiTypeId != 0)
00094     {
00095         if(pType != findType(uiTypeId))
00096         {
00097             SWARNING << "ERROR: Can't add a second "
00098                      << "type with the name " << pType->getCName() 
00099                      << "(" << pType << ")"
00100                      << std::endl;
00101         }
00102         else
00103         {
00104             SWARNING << "Do not run ctr twice "
00105                      << "type with the name " << pType->getCName() 
00106                      << "(" << pType << ")"
00107                      << std::endl;
00108 
00109 
00111 
00112             returnValue = uiTypeId;
00113         }
00114 
00115         return returnValue;
00116     }
00117 
00118     returnValue = _vTypeStore.size();
00119 
00120     _vTypeStore.push_back(pType);
00121 
00122     while(_vTypeNameMaps.size() <= pType->getNameSpace())
00123     {
00124         _vTypeNameMaps.push_back(new TypeNameMap);
00125 
00126         PINFO << "Added namespace : " << _vTypeNameMaps.size() << std::endl;
00127     }
00128 
00129     (*(_vTypeNameMaps[pType->getNameSpace()]))
00130         [IDStringLink(pType->getCName())] = returnValue;
00131 
00132     FDEBUG(("Registered type %s | %d (%d)\n", pType->getCName(), returnValue,
00133                                               pType)); 
00134 
00135     return returnValue;
00136 }

UInt32 TypeFactory::findTypeId const Char8 szName,
const UInt32  uiNameSpace = 0
 

findType(uiTypeId)->dump();

Definition at line 139 of file OSGTypeFactory.cpp.

References _vTypeNameMaps, and TypeNameMap.

Referenced by findType(), and registerType().

00141 {
00142     TypeNameMapConstIt typeIt;
00143     UInt32             uiTypeId = 0;
00144 
00145     if(szName == NULL)
00146         return uiTypeId;
00147 
00148     if(_vTypeNameMaps.size() <= uiNameSpace)
00149         return uiTypeId;
00150 
00151     TypeNameMap *pMap = _vTypeNameMaps[uiNameSpace];
00152 
00153     typeIt   = pMap->find(IDStringLink(szName));
00154 
00155     uiTypeId = (typeIt == pMap->end()) ? 0 : (*typeIt).second;
00156 
00157     return uiTypeId;
00158 }

TypeBase * TypeFactory::findType UInt32  uiTypeId  ) 
 

findType(uiTypeId)->dump();

Definition at line 161 of file OSGTypeFactory.cpp.

References _vTypeStore.

Referenced by findType(), and registerType().

00162 {
00163     if(uiTypeId < _vTypeStore.size())
00164     {
00165         return _vTypeStore[uiTypeId];
00166     }
00167     else
00168     {
00169         return NULL;
00170     }
00171 }

TypeBase * TypeFactory::findType const Char8 szName,
const UInt32  uiNameSpace = 0
 

findType(uiTypeId)->dump();

Definition at line 174 of file OSGTypeFactory.cpp.

References findType(), and findTypeId().

00176 {
00177     UInt32 uiTypeId = findTypeId(szName, uiNameSpace);
00178 
00179     return findType(uiTypeId);
00180 }

UInt32 TypeFactory::getNumTypes void   ) 
 

findType(uiTypeId)->dump();

Definition at line 183 of file OSGTypeFactory.cpp.

References _vTypeStore.

00184 {
00185     return _vTypeStore.size();
00186 }

void TypeFactory::writeTypeGraph const Char8 szFilename  ) 
 

findType(uiTypeId)->dump();

Definition at line 189 of file OSGTypeFactory.cpp.

References _vTypeStore, and writeTypeDot().

00190 {
00191     if(szFilename == NULL)
00192         return;
00193 
00194     FILE *pOut = fopen(szFilename, "w");
00195 
00196     if(pOut == NULL)
00197         return;
00198 
00199     fprintf(pOut, "digraph OSGTypeGraph\n{\n");
00200 
00201 /* CHECK
00202     for_each(_vTypeStore.begin(), 
00203              _vTypeStore.end(),
00204              bind1st(ptr_fun(writeTypeDot), pOut));
00205  */
00206 
00207     fprintf(pOut, "    rankdir=LR;\n");
00208     fprintf(pOut, "    size=\"8,60\";\n");
00209     fprintf(pOut, "    page=\"8.2677,11.69\";\n");
00210     fprintf(pOut, "    radio=auto;\n");
00211 
00212     for(UInt32 i = 1; i < _vTypeStore.size(); i++)
00213     {
00214         writeTypeDot(pOut, _vTypeStore[i]);
00215     }
00216 
00217     fprintf(pOut, "}\n");
00218     fclose(pOut);
00219 }

void TypeFactory::writeTypeDot FILE *  pOut,
TypeBase pTypeBase
[static, protected]
 

Definition at line 247 of file OSGTypeFactory.cpp.

References osg::TypeBase::getCName(), and osg::TypeBase::getCParentName().

Referenced by writeTypeGraph().

00249 {
00250     fprintf(pOut, "    OpenSG%s [shape=record,label=\"%s\"]\n", 
00251             pTypeBase->getCName(),
00252             pTypeBase->getCName());
00253 
00254     if(pTypeBase->getCParentName() != NULL)
00255     {
00256         fprintf(pOut, 
00257                 "    OpenSG%s -> OpenSG%s\n", 
00258                 pTypeBase->getCParentName(), 
00259                 pTypeBase->getCName());
00260     }
00261 }

void osg::TypeFactory::operator= const TypeFactory source  )  [private]
 


Member Data Documentation

* typedef std::map<IDStringLink, UInt32> osg::TypeFactory::TypeNameMap [protected]
 

Definition at line 98 of file OSGTypeFactory.h.

Referenced by findTypeId(), registerType(), and TypeFactory().

TypeFactory * TypeFactory::_the = NULL [static, protected]
 

Definition at line 56 of file OSGTypeFactory.cpp.

Referenced by the().

* TypeMapsStore osg::TypeFactory::_vTypeNameMaps [protected]
 

Definition at line 124 of file OSGTypeFactory.h.

Referenced by findTypeId(), registerType(), and TypeFactory().

TypeStore osg::TypeFactory::_vTypeStore [protected]
 

Definition at line 125 of file OSGTypeFactory.h.

Referenced by findType(), getNumTypes(), registerType(), TypeFactory(), and writeTypeGraph().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:12:37 2005 for OpenSG by  doxygen 1.4.3