00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSGFIELDCONTAINERFACTORYIMPL_H_
00040 #define _OSGFIELDCONTAINERFACTORYIMPL_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #ifdef OSG_DOC_FILES_IN_MODULE
00046
00049 #endif
00050
00051 #include <OSGSystemDef.h>
00052 #include <OSGBaseTypes.h>
00053 #include <OSGIDStringLink.h>
00054 #include <map>
00055 #include <vector>
00056
00057 OSG_BEGIN_NAMESPACE
00058
00059 class Lock;
00060 class FieldContainerType;
00061
00062
00063
00064
00065
00069 struct OSG_SYSTEMLIB_DLLMAPPING FieldContainerMapper
00070 {
00071 virtual ~FieldContainerMapper();
00072
00073 virtual UInt32 map(UInt32 uiId) = 0;
00074 };
00075
00076
00077
00078
00079
00083 class OSG_SYSTEMLIB_DLLMAPPING FieldContainerFactory
00084 {
00085
00086
00087 protected:
00088
00089 typedef std::map <UInt32,
00090 FieldContainerType *> TypeIdMap;
00091 typedef std::map <IDStringLink,
00092 FieldContainerType *> TypeNameMap;
00093 typedef std::map <IDStringLink,
00094 UInt16 > GroupMap;
00095
00096 typedef std::vector<FieldContainerType *> UninitializedTypeStore;
00097 typedef std::vector<FieldContainerPtr > FieldContainerStore;
00098
00099 typedef TypeIdMap ::iterator TypeIdMapIt;
00100 typedef TypeNameMap ::iterator TypeNameMapIt;
00101 typedef GroupMap ::iterator GroupMapIt;
00102 typedef UninitializedTypeStore::iterator UninitTypeStoreIt;
00103 typedef FieldContainerStore ::iterator FieldContainerStoreIt;
00104
00105 typedef TypeIdMap ::const_iterator TypeIdMapConstIt;
00106 typedef TypeNameMap ::const_iterator TypeNameMapCnstIt;
00107 typedef GroupMap ::const_iterator GroupMapConstIt;
00108
00109
00110
00111
00112 public :
00113
00114 typedef TypeIdMapIt TypeMapIterator;
00115
00116 static FieldContainerFactory *the(void);
00117
00118
00122 FieldContainerType *findType ( UInt32 uiTypeId) const;
00123 FieldContainerType *findType (const Char8 *szName ) const;
00124 UInt32 getNumTypes (void ) const;
00125
00126
00127 FieldContainerType *findUninitializedType (const Char8 *szName) const;
00128
00129 bool initializePendingTypes( void );
00130
00131 TypeMapIterator beginTypes ( void );
00132 TypeMapIterator endTypes ( void );
00133
00135
00139 UInt16 findGroupId (const Char8 *szName ) const;
00140 const Char8 *findGroupName( UInt16 uiGroupId) const;
00141
00142 UInt16 getNumGroups ( void ) const;
00143
00145
00149 void setMapper(FieldContainerMapper *pMapper);
00150
00152
00156 FieldContainerPtr getContainer (UInt32 uiFieldContainerId) const;
00157 FieldContainerPtr getMappedContainer(UInt32 uiFieldContainerId) const;
00158
00160
00164 FieldContainerPtr createFieldContainer(const Char8 *name) const;
00165 NodePtr createNode (const Char8 *name) const;
00166 NodeCorePtr createNodeCore (const Char8 *name) const;
00167 AttachmentPtr createAttachment (const Char8 *name) const;
00168
00170
00174 void writeFCD(Char8 *name = NULL, std::ostream *out = NULL);
00175
00177
00181 const FieldContainerStore *getFieldContainerStore(void) const;
00182
00184
00185
00186 protected:
00187
00188 static FieldContainerFactory *_the;
00189
00190 static TypeMapIterator _defaultTypeMapIt;
00191
00192
00196 static bool initializeFactory(void);
00197 static bool terminateFactory (void);
00198
00200
00204 bool _bInitialized;
00205
00206 TypeIdMap *_pTypeIdMap;
00207 TypeNameMap *_pTypeNameMap;
00208 GroupMap *_pGroupMap;
00209 UninitializedTypeStore *_pUnitTypesStore;
00210 FieldContainerStore *_pFieldContainerStore;
00211
00212 Lock *_pStoreLock;
00213 Lock *_pMapLock;
00214
00215 FieldContainerMapper *_pMapper;
00216
00218
00222 FieldContainerFactory(void);
00223
00225
00229 virtual ~FieldContainerFactory(void);
00230
00232
00236 bool initialize (void);
00237 bool terminate (void);
00238
00239 void initTypeMap(void);
00240
00242
00246 bool unregisterFieldContainer(const FieldContainerPtr &pFieldContainer);
00247 UInt32 registerFieldContainer(const FieldContainerPtr &pFieldContainer);
00248
00249 UInt32 registerType ( FieldContainerType *pType );
00250 UInt16 registerGroup (const Char8 *szName );
00251 void unregisterType ( FieldContainerType *pType );
00252
00254
00258 void writeSingleTypeFCD(std::ostream &out, const FieldContainerType *type);
00259
00261
00262
00263 private:
00264
00265 friend class FieldContainerType;
00266 friend class FieldContainer;
00267 friend class FieldContainerPtrBase;
00268
00270 FieldContainerFactory(const FieldContainerFactory &source);
00272 void operator =(const FieldContainerFactory &source);
00273 };
00274
00275 OSG_END_NAMESPACE
00276
00277 #define OSGFIELDCONTAINERFACTORY_HEADER_CVSID "@(#)$Id: $"
00278
00279 #endif