osg::FieldContainerFactory Class Reference
[Field Container]

#include <OSGFieldContainerFactoryImpl.h>

List of all members.

Public Types

typedef TypeIdMapIt TypeMapIterator

Public Member Functions

Types


FieldContainerTypefindType (UInt32 uiTypeId) const
FieldContainerTypefindType (const Char8 *szName) const
UInt32 getNumTypes (void) const
FieldContainerTypefindUninitializedType (const Char8 *szName) const
bool initializePendingTypes (void)
TypeMapIterator beginTypes (void)
TypeMapIterator endTypes (void)
Groups


UInt16 findGroupId (const Char8 *szName) const
const Char8findGroupName (UInt16 uiGroupId) const
UInt16 getNumGroups (void) const
Mapper


void setMapper (FieldContainerMapper *pMapper)
Get FieldContainer


FieldContainerPtr getContainer (UInt32 uiFieldContainerId) const
FieldContainerPtr getMappedContainer (UInt32 uiFieldContainerId) const
Create Base FieldContainer


FieldContainerPtr createFieldContainer (const Char8 *name) const
NodePtr createNode (const Char8 *name) const
NodeCorePtr createNodeCore (const Char8 *name) const
AttachmentPtr createAttachment (const Char8 *name) const
Write FCD From Name


void writeFCD (Char8 *name=NULL, std::ostream *out=NULL)
Get Containerstore


const FieldContainerStoregetFieldContainerStore (void) const

Static Public Member Functions

static FieldContainerFactorythe (void)

Protected Types

typedef std::map< UInt32,
FieldContainerType * > 
TypeIdMap
typedef std::map< IDStringLink,
FieldContainerType * > 
TypeNameMap
typedef std::map< IDStringLink,
UInt16
GroupMap
typedef std::vector
< FieldContainerType * > 
UninitializedTypeStore
typedef std::vector
< FieldContainerPtr
FieldContainerStore
typedef TypeIdMap::iterator TypeIdMapIt
typedef TypeNameMap::iterator TypeNameMapIt
typedef GroupMap::iterator GroupMapIt
typedef
UninitializedTypeStore::iterator 
UninitTypeStoreIt
typedef
FieldContainerStore::iterator 
FieldContainerStoreIt
typedef TypeIdMap::const_iterator TypeIdMapConstIt
typedef TypeNameMap::const_iterator TypeNameMapCnstIt
typedef GroupMap::const_iterator GroupMapConstIt

Protected Member Functions

Constructors


 FieldContainerFactory (void)
Destructor


virtual ~FieldContainerFactory (void)
Instance Initialization / Termination


bool initialize (void)
bool terminate (void)
void initTypeMap (void)
Register


bool unregisterFieldContainer (const FieldContainerPtr &pFieldContainer)
UInt32 registerFieldContainer (const FieldContainerPtr &pFieldContainer)
UInt32 registerType (FieldContainerType *pType)
UInt16 registerGroup (const Char8 *szName)
void unregisterType (FieldContainerType *pType)
Write FCD From Type


void writeSingleTypeFCD (std::ostream &out, const FieldContainerType *type)

Static Protected Member Functions

Intialization / Termination


static bool initializeFactory (void)
static bool terminateFactory (void)

Protected Attributes

Member


bool _bInitialized
TypeIdMap_pTypeIdMap
TypeNameMap_pTypeNameMap
GroupMap_pGroupMap
UninitializedTypeStore_pUnitTypesStore
FieldContainerStore_pFieldContainerStore
Lock_pStoreLock
Lock_pMapLock
FieldContainerMapper_pMapper

Static Protected Attributes

static FieldContainerFactory_the = NULL
static TypeMapIterator _defaultTypeMapIt

Private Member Functions

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

Friends

class FieldContainerType
class FieldContainer
class FieldContainerPtrBase


Detailed Description

Definition at line 83 of file OSGFieldContainerFactoryImpl.h.


Member Typedef Documentation

Definition at line 90 of file OSGFieldContainerFactoryImpl.h.

Definition at line 92 of file OSGFieldContainerFactoryImpl.h.

typedef std::map<IDStringLink, UInt16 > osg::FieldContainerFactory::GroupMap [protected]

Definition at line 94 of file OSGFieldContainerFactoryImpl.h.

Definition at line 96 of file OSGFieldContainerFactoryImpl.h.

Definition at line 97 of file OSGFieldContainerFactoryImpl.h.

typedef TypeIdMap ::iterator osg::FieldContainerFactory::TypeIdMapIt [protected]

Definition at line 99 of file OSGFieldContainerFactoryImpl.h.

Definition at line 100 of file OSGFieldContainerFactoryImpl.h.

typedef GroupMap ::iterator osg::FieldContainerFactory::GroupMapIt [protected]

Definition at line 101 of file OSGFieldContainerFactoryImpl.h.

typedef UninitializedTypeStore::iterator osg::FieldContainerFactory::UninitTypeStoreIt [protected]

Definition at line 102 of file OSGFieldContainerFactoryImpl.h.

Definition at line 103 of file OSGFieldContainerFactoryImpl.h.

typedef TypeIdMap ::const_iterator osg::FieldContainerFactory::TypeIdMapConstIt [protected]

Definition at line 105 of file OSGFieldContainerFactoryImpl.h.

typedef TypeNameMap ::const_iterator osg::FieldContainerFactory::TypeNameMapCnstIt [protected]

Definition at line 106 of file OSGFieldContainerFactoryImpl.h.

typedef GroupMap ::const_iterator osg::FieldContainerFactory::GroupMapConstIt [protected]

Definition at line 107 of file OSGFieldContainerFactoryImpl.h.

Definition at line 114 of file OSGFieldContainerFactoryImpl.h.


Constructor & Destructor Documentation

FieldContainerFactory::FieldContainerFactory ( void   )  [protected]

FieldContainerFactory::~FieldContainerFactory ( void   )  [protected, virtual]

Definition at line 468 of file OSGFieldContainerFactory.cpp.

00469 {
00470 }

osg::FieldContainerFactory::FieldContainerFactory ( const FieldContainerFactory source  )  [private]


Member Function Documentation

FieldContainerFactory * FieldContainerFactory::the ( void   )  [static]

FieldContainerType * FieldContainerFactory::findType ( UInt32  uiTypeId  )  const

Definition at line 88 of file OSGFieldContainerFactory.cpp.

References _pTypeIdMap.

Referenced by createAttachment(), createFieldContainer(), createNode(), createNodeCore(), osg::deepClone(), osg::deepCloneAttachments(), osg::FieldContainerType::initParentFields(), osg::SharePtrGraphOp::isInList(), osg::RemoteAspect::receiveSync(), and writeFCD().

00089 {
00090     TypeIdMapConstIt  typeIt;
00091     FieldContainerType    *pType = NULL;
00092 
00093     if(_pTypeIdMap)
00094     {
00095         typeIt = _pTypeIdMap->find(uiTypeId);
00096         pType   = (typeIt == _pTypeIdMap->end()) ? NULL : (*typeIt).second;
00097     }
00098 
00099     return pType;
00100 }

FieldContainerType * FieldContainerFactory::findType ( const Char8 szName  )  const

Definition at line 102 of file OSGFieldContainerFactory.cpp.

References _pTypeNameMap.

00103 {
00104     TypeNameMapCnstIt   typeIt;
00105     FieldContainerType *pType = NULL;
00106 
00107     if(_pTypeNameMap)
00108     {
00109         typeIt = _pTypeNameMap->find(IDStringLink(szName));
00110         pType  = (typeIt == _pTypeNameMap->end()) ? NULL : (*typeIt).second;
00111     }
00112 
00113     return pType;
00114 }

UInt32 FieldContainerFactory::getNumTypes ( void   )  const

Definition at line 116 of file OSGFieldContainerFactory.cpp.

References _pTypeNameMap.

00117 {
00118     return _pTypeNameMap ? _pTypeNameMap->size() : 0;
00119 }

FieldContainerType * FieldContainerFactory::findUninitializedType ( const Char8 szName  )  const

Definition at line 121 of file OSGFieldContainerFactory.cpp.

References _pUnitTypesStore, and osg::stringcmp().

Referenced by osg::FieldContainerType::initParentFields().

00123 {
00124     FieldContainerType *returnValue = NULL;
00125 
00126     if(_pUnitTypesStore == NULL || szName == NULL)
00127         return returnValue;
00128 
00129     for(UInt32 i = 0; i < _pUnitTypesStore->size(); i++)
00130     {
00131         if(stringcmp(szName, (*_pUnitTypesStore)[i]->getCName()) == 0)
00132         {
00133             returnValue = (*_pUnitTypesStore)[i];
00134             break;
00135         }
00136     }
00137 
00138     return returnValue;
00139 }

bool FieldContainerFactory::initializePendingTypes ( void   ) 

Definition at line 145 of file OSGFieldContainerFactory.cpp.

References _bInitialized, _pMapLock, _pTypeIdMap, _pUnitTypesStore, osg::Lock::aquire(), osg::TypeBase::getCName(), osg::TypeBase::getId(), osg::FieldContainerType::initialize(), osg::FieldContainerType::isInitialized(), PINFO, osg::Lock::release(), and SINFO.

Referenced by initialize().

00146 {
00147     bool                returnValue = true;
00148     FieldContainerType *pType       = NULL;
00149 
00150     if(_bInitialized == false)
00151         return false;
00152 
00153     SINFO << "OSGFieldContainerFactory init pending types" << std::endl;
00154 
00155     if(_pUnitTypesStore != NULL)
00156     {
00157         if(_pMapLock != NULL)
00158             _pMapLock->aquire();
00159 
00160         UninitTypeStoreIt uninitIt = _pUnitTypesStore->begin();
00161 
00162         while(uninitIt != _pUnitTypesStore->end())
00163         {
00164             pType = *uninitIt;
00165 
00166             if(pType->isInitialized() == true)
00167             {
00168                 uninitIt = _pUnitTypesStore->erase(uninitIt);
00169 
00170 //                (*_pTypeIdMap  )[pType->getId()                 ] = pType;
00171 
00172                 TypeIdMap::value_type val(pType->getId(), pType);
00173 
00174                 _pTypeIdMap->insert(val);
00175 
00176                 (*_pTypeNameMap)[IDStringLink(pType->getCName())] = pType;
00177             }
00178             else
00179             {
00180                 if(pType->initialize() == true)
00181                 {
00182                     uninitIt = _pUnitTypesStore->erase(uninitIt);
00183 
00184 //                  (*_pTypeIdMap  )[pType->getId()                 ] = pType;
00185 
00186                     TypeIdMap::value_type val(pType->getId(), pType);
00187                     
00188                     _pTypeIdMap->insert(val);
00189 
00190                     (*_pTypeNameMap)[IDStringLink(pType->getCName())] = pType;
00191                 }
00192                 else
00193                 {
00194                     returnValue = false;
00195 
00196                     uninitIt++;
00197                 }
00198             }
00199         }
00200 
00201         if(_pMapLock != NULL)
00202             _pMapLock->release();
00203 
00204         PINFO << "("
00205                  << returnValue
00206                  << "|"
00207                  << _pUnitTypesStore->size()
00208                  << ")"
00209                  << std::endl;
00210     }
00211 
00212     return returnValue;
00213 }

FieldContainerFactory::TypeMapIterator FieldContainerFactory::beginTypes ( void   ) 

Definition at line 219 of file OSGFieldContainerFactory.cpp.

References _defaultTypeMapIt, and _pTypeIdMap.

00220 {
00221     TypeMapIterator returnValue = _defaultTypeMapIt;
00222 
00223     if(_pTypeIdMap != NULL)
00224     {
00225         returnValue = _pTypeIdMap->begin();
00226     }
00227 
00228     return returnValue;
00229 }

FieldContainerFactory::TypeMapIterator FieldContainerFactory::endTypes ( void   ) 

Definition at line 231 of file OSGFieldContainerFactory.cpp.

References _defaultTypeMapIt, and _pTypeIdMap.

Referenced by osg::RemoteAspect::RemoteAspect().

00232 {
00233     TypeMapIterator returnValue = _defaultTypeMapIt;
00234 
00235     if(_pTypeIdMap != NULL)
00236     {
00237         returnValue = _pTypeIdMap->end();
00238     }
00239 
00240     return returnValue;
00241 }

UInt16 FieldContainerFactory::findGroupId ( const Char8 szName  )  const

Definition at line 247 of file OSGFieldContainerFactory.cpp.

References _pGroupMap.

Referenced by registerGroup().

00248 {
00249     GroupMapConstIt gIt;
00250 
00251     if (_pGroupMap)
00252     {
00253         gIt = _pGroupMap->find(IDStringLink(szName));
00254         return ((gIt == _pGroupMap->end()) ? 0 : (*gIt).second);
00255     }
00256 
00257     return 0;
00258 }

const Char8 * FieldContainerFactory::findGroupName ( UInt16  uiGroupId  )  const

Definition at line 260 of file OSGFieldContainerFactory.cpp.

References _pGroupMap.

Referenced by osg::deepClone(), osg::deepCloneAttachments(), and osg::deepCloneTree().

00261 {
00262     GroupMapConstIt gIt;
00263 
00264     for(gIt = _pGroupMap->begin(); gIt != _pGroupMap->end(); gIt++)
00265     {
00266         if((*gIt).second == uiGroupId)
00267             return (*gIt).first.str();
00268     }
00269 
00270     return NULL;
00271 }

UInt16 FieldContainerFactory::getNumGroups ( void   )  const

Definition at line 273 of file OSGFieldContainerFactory.cpp.

References _pGroupMap.

00274 {
00275     return _pGroupMap ? _pGroupMap->size() : 0;
00276 }

void osg::FieldContainerFactory::setMapper ( FieldContainerMapper pMapper  )  [inline]

Definition at line 54 of file OSGFieldContainerFactoryImpl.inl.

References _pMapper.

Referenced by osg::BINLoader::chargeFieldContainers(), and osg::RemoteAspect::receiveSync().

00055 {
00056     _pMapper = pMapper;
00057 }

FieldContainerPtr osg::FieldContainerFactory::getContainer ( UInt32  uiFieldContainerId  )  const [inline]

Definition at line 63 of file OSGFieldContainerFactoryImpl.inl.

References _pStoreLock, osg::Lock::aquire(), osg::NullFC, and osg::Lock::release().

Referenced by osg::ChangeList::apply(), osg::ChangeList::applyTo(), osg::ChangeList::dump(), getMappedContainer(), osg::RemoteAspect::receiveSync(), osg::RemoteAspect::restoreChangeList(), osg::RemoteAspect::sendSync(), and osg::RemoteAspect::~RemoteAspect().

00065 {
00066     FieldContainerPtr returnValue = NullFC;
00067 
00068     _pStoreLock->aquire();
00069 
00070     if(uiContainerId < _pFieldContainerStore->size())
00071     {
00072         returnValue = (*_pFieldContainerStore)[uiContainerId];
00073     }
00074 
00075     _pStoreLock->release();
00076 
00077     return returnValue;
00078 }

FieldContainerPtr osg::FieldContainerFactory::getMappedContainer ( UInt32  uiFieldContainerId  )  const [inline]

Definition at line 81 of file OSGFieldContainerFactoryImpl.inl.

References _pMapper, getContainer(), and osg::FieldContainerMapper::map().

00083 {
00084     if(_pMapper != NULL)
00085     {
00086         return getContainer(_pMapper->map(uiContainerId));
00087     }
00088     else
00089     {
00090         return getContainer(uiContainerId);
00091     }
00092 }

FieldContainerPtr FieldContainerFactory::createFieldContainer ( const Char8 name  )  const

Definition at line 282 of file OSGFieldContainerFactory.cpp.

References osg::FieldContainerType::createFieldContainer(), and findType().

Referenced by osg::OSGLoader::beginNode(), osg::BINLoader::createFieldContainers(), osg::deepClone(), and osg::VRMLGeometryPartDesc::init().

00284 {
00285     FieldContainerPtr returnValue;
00286 
00287     const FieldContainerType *pType = findType(name);
00288 
00289     if(pType != NULL)
00290         returnValue = pType->createFieldContainer();
00291 
00292     return returnValue;
00293 }

NodePtr FieldContainerFactory::createNode ( const Char8 name  )  const

Definition at line 295 of file OSGFieldContainerFactory.cpp.

References osg::FieldContainerType::createNode(), and findType().

00296 {
00297     NodePtr returnValue;
00298 
00299     const FieldContainerType *pType = findType(name);
00300 
00301     if(pType != NULL)
00302         returnValue = pType->createNode();
00303 
00304     return returnValue;
00305 }

NodeCorePtr FieldContainerFactory::createNodeCore ( const Char8 name  )  const

Definition at line 307 of file OSGFieldContainerFactory.cpp.

References osg::FieldContainerType::createNodeCore(), and findType().

00309 {
00310     NodeCorePtr returnValue;
00311 
00312     const FieldContainerType *pType = findType(name);
00313 
00314     if(pType != NULL)
00315         returnValue = pType->createNodeCore();
00316 
00317     return returnValue;
00318 }

AttachmentPtr FieldContainerFactory::createAttachment ( const Char8 name  )  const

Definition at line 320 of file OSGFieldContainerFactory.cpp.

References osg::FieldContainerType::createAttachment(), and findType().

00322 {
00323     AttachmentPtr returnValue;
00324 
00325     const FieldContainerType *pType = findType(name);
00326 
00327     if(pType != NULL)
00328         returnValue = pType->createAttachment();
00329 
00330     return returnValue;
00331 }

void FieldContainerFactory::writeFCD ( Char8 name = NULL,
std::ostream *  out = NULL 
)

Definition at line 342 of file OSGFieldContainerFactory.cpp.

References _pTypeIdMap, findType(), osg::TypeBase::getCName(), SWARNING, and writeSingleTypeFCD().

00343 {
00344           TypeIdMapIt         type;
00345     const FieldContainerType *pType = NULL;
00346 
00347     if(_pTypeIdMap == NULL)
00348         return;
00349 
00350     if(name != NULL)
00351     {
00352         pType  = findType(name);
00353 
00354         if(pType == NULL)
00355         {
00356             SWARNING << "FieldContainerFactory::writeFCD: type " << name
00357                      << " is unknown!" << std::endl;
00358             return;
00359         }
00360 
00361         if(out != NULL)
00362         {
00363             writeSingleTypeFCD(*out, pType);
00364         }
00365         else
00366         {
00367             std::string s(pType->getCName());
00368 
00369             s.append(".fcd");
00370 
00371             std::ofstream f(s.c_str());
00372 
00373             writeSingleTypeFCD(f, pType);
00374         }
00375 
00376         return;
00377     }
00378 
00379     // write header once?
00380     if(out != NULL)
00381     {
00382         *out << "<?xml version=\"1.0\" ?>" << std::endl << std::endl;
00383     }
00384 
00385     for(  type  = _pTypeIdMap->begin();
00386           type != _pTypeIdMap->end  ();
00387         ++type)
00388     {
00389         if(out != NULL)
00390         {
00391             writeSingleTypeFCD(*out, (*type).second);
00392         }
00393         else
00394         {
00395             std::string s((*type).second->getCName());
00396 
00397             s.append(".fcd");
00398 
00399             std::ofstream f(s.c_str());
00400 
00401             f << "<?xml version=\"1.0\" ?>" << std::endl << std::endl;
00402 
00403             writeSingleTypeFCD(f, (*type).second);
00404         }
00405 
00406         if(out != NULL)
00407         {
00408             *out << std::endl;
00409         }
00410     }
00411 }

const FieldContainerFactory::FieldContainerStore * FieldContainerFactory::getFieldContainerStore ( void   )  const

bool FieldContainerFactory::initializeFactory ( void   )  [static, protected]

Definition at line 426 of file OSGFieldContainerFactory.cpp.

References initialize(), and the().

Referenced by FieldContainerFactory().

00427 {
00428     bool returnValue = the()->initialize();
00429 
00430     // CHECKCHECK
00431     // clear changelist from prototypes, move this to a different place soon
00432     OSG::Thread::getCurrentChangeList()->clearAll();
00433 
00434     return returnValue;
00435 }

bool FieldContainerFactory::terminateFactory ( void   )  [static, protected]

Definition at line 437 of file OSGFieldContainerFactory.cpp.

References terminate(), and the().

Referenced by FieldContainerFactory().

00438 {
00439     return the()->terminate();
00440 }

bool FieldContainerFactory::initialize ( void   )  [protected]

Definition at line 475 of file OSGFieldContainerFactory.cpp.

References _bInitialized, _pMapLock, _pStoreLock, osg::addRefP(), FDEBUG, osg::ThreadManager::getLock(), initializePendingTypes(), SINFO, and osg::ThreadManager::the().

Referenced by initializeFactory().

00476 {
00477     TypeIdMapIt typeIt;
00478 
00479     if(_bInitialized == true)
00480         return true;
00481 
00482     SINFO << "init singleton FieldContainerFactory" << std::endl;
00483 
00484     _pStoreLock = ThreadManager::the()->getLock(
00485         "OSGFieldContainerFactory::_pStoreLock");
00486 
00487     addRefP(_pStoreLock);
00488 
00489     _pMapLock   = ThreadManager::the()->getLock(
00490         "OSGFieldContainerFactory::_pMaoLock");
00491 
00492     addRefP(_pMapLock);
00493 
00494     FDEBUG( ("Got shore lock %p, Got map %p",
00495              _pStoreLock, _pMapLock) );
00496 
00497     _bInitialized = true;
00498 
00499     initializePendingTypes();
00500 
00501     return _pStoreLock != NULL && _pMapLock != NULL;
00502 }

bool FieldContainerFactory::terminate ( void   )  [protected]

Definition at line 504 of file OSGFieldContainerFactory.cpp.

References _bInitialized, _pMapLock, _pStoreLock, _pTypeIdMap, SINFO, and osg::subRefP().

Referenced by terminateFactory().

00505 {
00506     TypeIdMapIt typeIt;
00507 
00508     SINFO << "terminate singleton FieldContainerFactory" << std::endl;
00509 
00510     if(_bInitialized == false)
00511         return true;
00512 
00513     if(_pTypeIdMap != NULL)
00514     {
00515         int i = 0;
00516         for(  typeIt  = _pTypeIdMap->begin();
00517               typeIt != _pTypeIdMap->end();
00518             ++typeIt)
00519         {
00520             (*typeIt).second->terminate();
00521 
00522             i++;
00523         }
00524     }
00525 
00526     subRefP(_pStoreLock);
00527     subRefP(_pMapLock);
00528 
00529     _bInitialized = false;
00530 
00531     return true;
00532 }

void FieldContainerFactory::initTypeMap ( void   )  [protected]

Definition at line 534 of file OSGFieldContainerFactory.cpp.

References _pGroupMap, _pTypeIdMap, _pTypeNameMap, and _pUnitTypesStore.

Referenced by FieldContainerFactory().

00535 {
00536     if(_pTypeIdMap   == NULL &&
00537        _pTypeNameMap == NULL)
00538     {
00539         _pTypeIdMap      = new TypeIdMap;
00540         _pTypeNameMap    = new TypeNameMap;
00541         _pGroupMap       = new GroupMap;
00542         _pUnitTypesStore = new UninitializedTypeStore;
00543     }
00544 }

bool osg::FieldContainerFactory::unregisterFieldContainer ( const FieldContainerPtr pFieldContainer  )  [inline, protected]

Definition at line 124 of file OSGFieldContainerFactoryImpl.inl.

References _pFieldContainerStore, _pStoreLock, osg::Lock::aquire(), FWARNING, osg::FieldContainerPtrBase::getFieldContainerId(), osg::NullFC, and osg::Lock::release().

00126 {
00127     if(pFieldContainer == NullFC)
00128         return false;
00129 
00130     if(_pStoreLock != NULL)
00131         _pStoreLock->aquire();
00132 
00133     if(_pFieldContainerStore != NULL)
00134     {
00135 #ifdef OSG_DEBUG
00136         if (pFieldContainer.getFieldContainerId() >=
00137                     (*_pFieldContainerStore).size())
00138         {
00139             FWARNING(("FieldContainerFactory::unregisterFieldContainer:"
00140                 "id %d inconsistent with store size %d!\n", 
00141                 pFieldContainer.getFieldContainerId(), 
00142                 (*_pFieldContainerStore).size() ));   
00143             return true;         
00144         }
00145         else
00146 #endif
00147 
00148         (*_pFieldContainerStore)[pFieldContainer.getFieldContainerId()] =
00149             NullFC;
00150     }
00151 
00152     if(_pStoreLock != NULL)
00153         _pStoreLock->release();
00154     
00155     return false;
00156 }

UInt32 osg::FieldContainerFactory::registerFieldContainer ( const FieldContainerPtr pFieldContainer  )  [inline, protected]

Definition at line 98 of file OSGFieldContainerFactoryImpl.inl.

References _pFieldContainerStore, _pStoreLock, osg::Lock::aquire(), osg::NullFC, and osg::Lock::release().

Referenced by osg::FieldContainer::newPtr().

00100 {
00101     UInt32 returnValue = 0;
00102 
00103     if(_pStoreLock != NULL)
00104         _pStoreLock->aquire();
00105 
00106     if(_pFieldContainerStore == NULL)
00107     {
00108         _pFieldContainerStore = new FieldContainerStore;
00109 
00110         _pFieldContainerStore->push_back(NullFC);
00111     }
00112 
00113     _pFieldContainerStore->push_back(pFieldContainer);
00114 
00115     returnValue = _pFieldContainerStore->size() - 1;
00116 
00117     if(_pStoreLock != NULL)
00118         _pStoreLock->release();
00119 
00120     return returnValue;
00121 }

UInt32 FieldContainerFactory::registerType ( FieldContainerType pType  )  [protected]

Definition at line 549 of file OSGFieldContainerFactory.cpp.

References _pMapLock, _pUnitTypesStore, osg::Lock::aquire(), osg::TypeBase::getId(), and osg::Lock::release().

Referenced by osg::FieldContainerType::registerType().

00550 {
00551     UInt32 returnValue = 0;
00552 
00553     if(_pMapLock != NULL)
00554         _pMapLock->aquire();
00555 
00556     if(pType->getId() != 0)
00557     {
00558         _pUnitTypesStore->push_back(pType);
00559     }
00560 
00561     if(_pMapLock != NULL)
00562         _pMapLock->release();
00563 
00564     return returnValue;
00565 }

UInt16 FieldContainerFactory::registerGroup ( const Char8 szName  )  [protected]

Definition at line 567 of file OSGFieldContainerFactory.cpp.

References _pGroupMap, _pMapLock, osg::Lock::aquire(), findGroupId(), osg::Lock::release(), and SWARNING.

Referenced by osg::FieldContainerType::registerType().

00568 {
00569     UInt16 returnValue;
00570 
00571     if(szName == NULL || *szName == '\0')
00572     {
00573         SWARNING << "Group without name" << std::endl;
00574         return 0;
00575     }
00576 
00577     returnValue = findGroupId(szName);
00578 
00579     if(returnValue == 0)
00580     {
00581         if(_pMapLock != NULL)
00582             _pMapLock->aquire();
00583 
00584         returnValue                         = _pGroupMap->size() + 1;
00585 
00586         (*_pGroupMap)[IDStringLink(szName)] = returnValue;
00587 
00588         if(_pMapLock != NULL)
00589             _pMapLock->release();
00590     }
00591 
00592     return returnValue;
00593 }

void FieldContainerFactory::unregisterType ( FieldContainerType pType  )  [protected]

Definition at line 595 of file OSGFieldContainerFactory.cpp.

References _pTypeIdMap, _pTypeNameMap, osg::TypeBase::getCName(), and osg::TypeBase::getId().

Referenced by osg::FieldContainerType::~FieldContainerType().

00596 {
00597     TypeIdMapIt   typeIdIt;
00598     TypeNameMapIt typeNameIt;
00599 
00600     if(pType == NULL)
00601         return;
00602 
00603     if(_pTypeIdMap)
00604     {
00605         UInt32 uiId =  pType->getId();
00606 
00607         typeIdIt    = _pTypeIdMap->find(uiId);
00608 
00609         if(typeIdIt != _pTypeIdMap->end())
00610         {
00611             _pTypeIdMap->erase(typeIdIt);
00612         }
00613     }
00614 
00615     if(_pTypeNameMap)
00616     {
00617         typeNameIt = _pTypeNameMap->find(IDStringLink(pType->getCName()));
00618 
00619         if(typeNameIt != _pTypeNameMap->end())
00620         {
00621             _pTypeNameMap->erase(typeNameIt);
00622         }
00623     }
00624 }

void FieldContainerFactory::writeSingleTypeFCD ( std::ostream &  out,
const FieldContainerType type 
) [protected]

Definition at line 629 of file OSGFieldContainerFactory.cpp.

References osg::FieldType::getCardinality(), osg::FieldDescription::getCName(), osg::TypeBase::getCName(), osg::FieldContainerType::getFieldDescription(), osg::FieldFactory::getFieldType(), osg::FieldContainerType::getNumFieldDescs(), osg::FieldContainerType::getParent(), osg::FieldDescription::getTypeId(), osg::FieldContainerType::isAbstract(), osg::FieldDescription::isInternal(), and osg::FieldFactory::the().

Referenced by writeFCD().

00631 {
00632     FieldContainerType *parent = t->getParent();
00633 
00634     out << "<FieldContainer"                          << std::endl;
00635     out << "\tname=\""       << t->getCName() << "\"" << std::endl;
00636 
00637     if(parent != NULL)
00638         out << "\tparent=\"" << parent->getCName() << "\"" << std::endl;
00639     
00640     out << "\tlibrary=\""
00641         << "???"
00642         << "\"" 
00643         << std::endl;
00644     out << "\tstructure=\"" 
00645         << ( t->isAbstract()?"abstract":"concrete" ) 
00646         << "\""
00647         << std::endl;
00648 
00649     // look for pointerfield types
00650            std::string s;
00651            Int32       pt        = 0;
00652     static Char8 *pftypes[] = {"none", "single", "multi", "both"};
00653 
00654     s  = "SF";
00655     s += t->getCName();
00656     s += "Ptr";
00657 
00658     if(FieldFactory::the().getFieldType(s.c_str()) != NULL)
00659     {
00660         pt |= 1;
00661     }
00662 
00663     s  = "MF";
00664     s += t->getCName();
00665     s += "Ptr";
00666     
00667     if(FieldFactory::the().getFieldType(s.c_str()) != NULL)
00668     {
00669         pt |= 2;
00670     }
00671 
00672     out << "\tpointerfieldtypes=\"" << pftypes[pt] << "\"" << std::endl;
00673     out << ">"                                             << std::endl;
00674 
00675     // Print the fields in this FC, ignore the parents' fields
00676     // !!! This should start at 0, FIX ME
00677 
00678     for(UInt32 i  = parent ? parent->getNumFieldDescs() + 1 : 1;
00679                i <= t->getNumFieldDescs();
00680                i++)
00681     {
00682         const FieldDescription *f  = t->getFieldDescription(i);
00683               FieldType        *ft = NULL;
00684 
00685         ft = FieldFactory::the().getFieldType(f->getTypeId());
00686 
00687         out << "\t<Field"                             << std::endl;
00688         out << "\t\tname=\"" << f->getCName() << "\"" << std::endl;
00689 
00690         // Filter the SF/MF from the type
00691         const Char8 *c = ft->getCName();
00692 
00693         if (! strncmp(c, "SF", 2) || ! strncmp(c, "MF", 2))
00694         {
00695             c += 2;
00696         }
00697 
00698         out << "\t\ttype=\"" << c << "\"" << std::endl;
00699 
00700         out << "\t\tcardinality=\""
00701             << (ft->getCardinality() ? "multi" : "single")
00702             << "\"" << std::endl;
00703 
00704         out << "\t\tvisibility=\"" 
00705             << (f->isInternal() ? "internal" : "external")
00706             << "\"" 
00707             << std::endl;
00708         
00709         out << "\t>"        << std::endl;
00710         out << "\t</Field>" << std::endl;
00711     }
00712 
00713     out << "</FieldContainer>" << std::endl;
00714 }

void osg::FieldContainerFactory::operator= ( const FieldContainerFactory source  )  [private]


Friends And Related Function Documentation

friend class FieldContainerType [friend]

Definition at line 265 of file OSGFieldContainerFactoryImpl.h.

friend class FieldContainer [friend]

Definition at line 266 of file OSGFieldContainerFactoryImpl.h.

friend class FieldContainerPtrBase [friend]

Definition at line 267 of file OSGFieldContainerFactoryImpl.h.


Member Data Documentation

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

Definition at line 188 of file OSGFieldContainerFactoryImpl.h.

Referenced by the().

Definition at line 190 of file OSGFieldContainerFactoryImpl.h.

Referenced by beginTypes(), and endTypes().

Definition at line 204 of file OSGFieldContainerFactoryImpl.h.

Referenced by initialize(), initializePendingTypes(), and terminate().

Definition at line 207 of file OSGFieldContainerFactoryImpl.h.

Referenced by findType(), getNumTypes(), initTypeMap(), and unregisterType().

Definition at line 215 of file OSGFieldContainerFactoryImpl.h.

Referenced by getMappedContainer(), and setMapper().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 12:04:57 2008 for OpenSG by  doxygen 1.5.5