Changeset 9667 for code/trunk/src/libraries/core/class/IdentifierManager.h
- Timestamp:
- Aug 25, 2013, 9:08:42 PM (12 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core6 merged: 9552-9554,9556-9574,9577-9579,9585-9593,9596-9612,9626-9662
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/class/IdentifierManager.h
r9564 r9667 38 38 39 39 #include <map> 40 #include <set> 40 41 #include <string> 41 42 … … 44 45 class _CoreExport IdentifierManager 45 46 { 46 friend class Identifier;47 template <class T> friend class ClassIdentifier;47 public: 48 static IdentifierManager& getInstance(); 48 49 49 public: 50 Identifier* getGloballyUniqueIdentifier(Identifier* proposal); 51 void addIdentifierToLookupMaps(Identifier* identifier); 52 53 unsigned int getUniqueClassId() 54 { return this->classIDCounter_s++; } 55 56 50 57 ///////////////////////////// 51 58 ////// Class Hierarchy ////// 52 59 ///////////////////////////// 53 static void createClassHierarchy(); 60 void createClassHierarchy(); 61 void destroyAllIdentifiers(); 62 63 void createdObject(Identifiable* identifiable); 54 64 55 65 /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. 56 inline staticbool isCreatingHierarchy()66 inline bool isCreatingHierarchy() 57 67 { return (hierarchyCreatingCounter_s > 0); } 58 68 … … 61 71 ///// Identifier Map ///// 62 72 ////////////////////////// 63 static void destroyAllIdentifiers(); 73 Identifier* getIdentifierByString(const std::string& name); 74 Identifier* getIdentifierByLowercaseString(const std::string& name); 75 Identifier* getIdentifierByID(uint32_t id); 64 76 65 static Identifier* getIdentifierByString(const std::string& name); 66 static Identifier* getIdentifierByLowercaseString(const std::string& name); 67 static Identifier* getIdentifierByID(uint32_t id); 68 69 static void clearNetworkIDs(); 77 void clearNetworkIDs(); 70 78 71 79 /// Returns the map that stores all Identifiers with their names. 72 static inline const std::map<std::string, Identifier*>& getStringIdentifierMap() 73 { return IdentifierManager::getStringIdentifierMapIntern(); } 74 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. 75 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() 76 { return IdentifierManager::getStringIdentifierMap().begin(); } 77 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names. 78 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() 79 { return IdentifierManager::getStringIdentifierMap().end(); } 80 80 inline const std::map<std::string, Identifier*>& getIdentifierByStringMap() 81 { return this->identifierByString_; } 81 82 /// Returns the map that stores all Identifiers with their names in lowercase. 82 static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() 83 { return IdentifierManager::getLowercaseStringIdentifierMapIntern(); } 84 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. 85 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() 86 { return IdentifierManager::getLowercaseStringIdentifierMap().begin(); } 87 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. 88 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() 89 { return IdentifierManager::getLowercaseStringIdentifierMap().end(); } 90 83 inline const std::map<std::string, Identifier*>& getIdentifierByLowercaseStringMap() 84 { return this->identifierByLowercaseString_; } 91 85 /// Returns the map that stores all Identifiers with their IDs. 92 static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() 93 { return IdentifierManager::getIDIdentifierMapIntern(); } 94 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. 95 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() 96 { return IdentifierManager::getIDIdentifierMap().begin(); } 97 /// Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. 98 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() 99 { return IdentifierManager::getIDIdentifierMap().end(); } 100 101 protected: 102 static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 103 104 /// Returns the map that stores all Identifiers with their names. 105 static std::map<std::string, Identifier*>& getStringIdentifierMapIntern(); 106 /// Returns the map that stores all Identifiers with their names in lowercase. 107 static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern(); 108 /// Returns the map that stores all Identifiers with their network IDs. 109 static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern(); 86 inline const std::map<uint32_t, Identifier*>& getIdentifierByNetworkIdMap() 87 { return this->identifierByNetworkId_; } 110 88 111 89 private: 90 IdentifierManager(); 91 IdentifierManager(const IdentifierManager&); 92 ~IdentifierManager() {} 93 112 94 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. 113 inline staticvoid startCreatingHierarchy()95 inline void startCreatingHierarchy() 114 96 { hierarchyCreatingCounter_s++; } 115 97 /// Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. 116 inline staticvoid stopCreatingHierarchy()98 inline void stopCreatingHierarchy() 117 99 { hierarchyCreatingCounter_s--; } 118 100 119 st atic std::map<std::string, Identifier*>& getTypeIDIdentifierMap();101 std::map<std::string, Identifier*> identifierByTypeidName_; //!< Map with the names as received by typeid(). This is only used internally. 120 102 121 static int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 122 static unsigned int classIDCounter_s; //!< Static counter for the unique classIDs 103 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 104 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 105 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 106 107 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 108 std::set<const Identifier*> identifiersOfNewObject_; //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object 109 unsigned int classIDCounter_s; //!< counter for the unique classIDs 123 110 }; 124 111 }
Note: See TracChangeset
for help on using the changeset viewer.