Changeset 9640 for code/branches/core6/src/libraries
- Timestamp:
- Aug 11, 2013, 9:07:38 PM (11 years ago)
- Location:
- code/branches/core6/src/libraries
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/Core.cc
r9564 r9640 198 198 // creates the class hierarchy for all classes with factories 199 199 orxout(internal_info) << "creating class hierarchy" << endl; 200 IdentifierManager:: createClassHierarchy();200 IdentifierManager::getInstance().createClassHierarchy(); 201 201 202 202 // Load OGRE excluding the renderer and the render window … … 248 248 safeObjectDelete(&configFileManager_); 249 249 ConsoleCommand::destroyAll(); 250 IdentifierManager:: destroyAllIdentifiers();250 IdentifierManager::getInstance().destroyAllIdentifiers(); 251 251 safeObjectDelete(&signalHandler_); 252 252 safeObjectDelete(&dynLibManager_); -
code/branches/core6/src/libraries/core/CoreIncludes.h
r9638 r9640 179 179 inline Identifier* ClassByString(const std::string& name) 180 180 { 181 return IdentifierManager::getI dentifierByString(name);181 return IdentifierManager::getInstance().getIdentifierByString(name); 182 182 } 183 183 … … 188 188 inline Identifier* ClassByLowercaseString(const std::string& name) 189 189 { 190 return IdentifierManager::getI dentifierByLowercaseString(name);190 return IdentifierManager::getInstance().getIdentifierByLowercaseString(name); 191 191 } 192 192 … … 197 197 inline Identifier* ClassByID(uint32_t id) 198 198 { 199 return IdentifierManager::getI dentifierByID(id);199 return IdentifierManager::getInstance().getIdentifierByID(id); 200 200 } 201 201 -
code/branches/core6/src/libraries/core/Template.cc
r9638 r9640 150 150 151 151 // check if the template is applied on an object of the right type 152 Identifier* identifier = IdentifierManager::getIdentifierByString(this->getXMLElement().Value());152 Identifier* identifier = ClassByString(this->getXMLElement().Value()); 153 153 if (!object->getIdentifier()->isA(identifier)) 154 154 orxout(internal_warning, context::templates) << "Template was defined for " << identifier->getName() << " but the object is of type " << object->getIdentifier()->getName() << endl; -
code/branches/core6/src/libraries/core/XMLPort.cc
r9629 r9640 29 29 #include "XMLPort.h" 30 30 31 #include "CoreIncludes.h" 31 32 #include "Loader.h" 32 33 #include "Namespace.h" … … 59 60 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 60 61 { 61 Identifier* identifier = IdentifierManager::getIdentifierByString(child->Value());62 Identifier* identifier = ClassByString(child->Value()); 62 63 if (!identifier) 63 64 { -
code/branches/core6/src/libraries/core/class/Identifier.cc
r9632 r9640 50 50 */ 51 51 Identifier::Identifier() 52 : classID_(IdentifierManager:: classIDCounter_s++)52 : classID_(IdentifierManager::getInstance().classIDCounter_s++) 53 53 { 54 54 this->bCreatedOneObject_ = false; … … 87 87 { 88 88 // Check if at least one object of the given type was created 89 if (!this->bCreatedOneObject_ && IdentifierManager:: isCreatingHierarchy())89 if (!this->bCreatedOneObject_ && IdentifierManager::getInstance().isCreatingHierarchy()) 90 90 { 91 91 // If no: We have to store the information and initialize the Identifier … … 155 155 this->name_ = name; 156 156 this->bSetName_ = true; 157 IdentifierManager::get StringIdentifierMapIntern()[name] = this;158 IdentifierManager::get LowercaseStringIdentifierMapIntern()[getLowercase(name)] = this;159 IdentifierManager::getI DIdentifierMapIntern()[this->networkID_] = this;157 IdentifierManager::getInstance().identifierByString_[name] = this; 158 IdentifierManager::getInstance().identifierByLowercaseString_[getLowercase(name)] = this; 159 IdentifierManager::getInstance().identifierByNetworkId_[this->networkID_] = this; 160 160 } 161 161 } … … 196 196 { 197 197 // Identifier::getIDIdentifierMapIntern().erase(this->networkID_); 198 IdentifierManager::getI DIdentifierMapIntern()[id] = this;198 IdentifierManager::getInstance().identifierByNetworkId_[id] = this; 199 199 this->networkID_ = id; 200 200 } -
code/branches/core6/src/libraries/core/class/Identifier.h
r9634 r9640 346 346 347 347 // Get the entry from the map 348 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getI dentifierSingleton(name, proposal);348 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getIdentifierSingleton(name, proposal); 349 349 350 350 if (ClassIdentifier<T>::classIdentifier_s == proposal) … … 373 373 374 374 object->identifier_ = this; 375 if (IdentifierManager:: isCreatingHierarchy())375 if (IdentifierManager::getInstance().isCreatingHierarchy()) 376 376 { 377 377 if (bRootClass && !object->parents_) -
code/branches/core6/src/libraries/core/class/IdentifierManager.cc
r9634 r9640 43 43 namespace orxonox 44 44 { 45 int IdentifierManager::hierarchyCreatingCounter_s = 0; 46 unsigned int IdentifierManager::classIDCounter_s = 0; 45 /* static */ IdentifierManager& IdentifierManager::getInstance() 46 { 47 static IdentifierManager instance; 48 return instance; 49 } 47 50 48 /** 49 @brief Returns the identifier map with the names as received by typeid(). This is only used internally. 50 */ 51 std::map<std::string, Identifier*>& IdentifierManager::getTypeIDIdentifierMap() 51 IdentifierManager::IdentifierManager() 52 52 { 53 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers.54 return identifiers;53 this->hierarchyCreatingCounter_s = 0; 54 this->classIDCounter_s = 0; 55 55 } 56 56 … … 63 63 Identifier* IdentifierManager::getIdentifierSingleton(const std::string& name, Identifier* proposal) 64 64 { 65 std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name);65 std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeId_.find(name); 66 66 67 if (it != getTypeIDIdentifierMap().end())67 if (it != this->identifierByTypeId_.end()) 68 68 { 69 69 // There is already an entry: return it and delete the proposal … … 74 74 { 75 75 // There is no entry: put the proposal into the map and return it 76 getTypeIDIdentifierMap()[name] = proposal;76 this->identifierByTypeId_[name] = proposal; 77 77 return proposal; 78 78 } … … 85 85 { 86 86 orxout(internal_status) << "Create class-hierarchy" << endl; 87 IdentifierManager::startCreatingHierarchy();88 for (std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getTypeIDIdentifierMap().begin(); it != IdentifierManager::getTypeIDIdentifierMap().end(); ++it)87 this->startCreatingHierarchy(); 88 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeId_.begin(); it != this->identifierByTypeId_.end(); ++it) 89 89 { 90 90 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 95 95 } 96 96 } 97 IdentifierManager::stopCreatingHierarchy();97 this->stopCreatingHierarchy(); 98 98 orxout(internal_status) << "Finished class-hierarchy creation" << endl; 99 99 } … … 104 104 void IdentifierManager::destroyAllIdentifiers() 105 105 { 106 for (std::map<std::string, Identifier*>::iterator it = IdentifierManager::getTypeIDIdentifierMap().begin(); it != IdentifierManager::getTypeIDIdentifierMap().end(); ++it)106 for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeId_.begin(); it != this->identifierByTypeId_.end(); ++it) 107 107 delete (it->second); 108 108 109 IdentifierManager::getTypeIDIdentifierMap().clear(); 110 IdentifierManager::getStringIdentifierMapIntern().clear(); 111 IdentifierManager::getLowercaseStringIdentifierMapIntern().clear(); 112 IdentifierManager::getIDIdentifierMapIntern().clear(); 113 } 114 115 /** 116 @brief Returns the map that stores all Identifiers with their names. 117 @return The map 118 */ 119 std::map<std::string, Identifier*>& IdentifierManager::getStringIdentifierMapIntern() 120 { 121 static std::map<std::string, Identifier*> identifierMap; 122 return identifierMap; 123 } 124 125 /** 126 @brief Returns the map that stores all Identifiers with their names in lowercase. 127 @return The map 128 */ 129 std::map<std::string, Identifier*>& IdentifierManager::getLowercaseStringIdentifierMapIntern() 130 { 131 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 132 return lowercaseIdentifierMap; 133 } 134 135 /** 136 @brief Returns the map that stores all Identifiers with their network IDs. 137 @return The map 138 */ 139 std::map<uint32_t, Identifier*>& IdentifierManager::getIDIdentifierMapIntern() 140 { 141 static std::map<uint32_t, Identifier*> identifierMap; 142 return identifierMap; 109 this->identifierByTypeId_.clear(); 110 this->identifierByString_.clear(); 111 this->identifierByLowercaseString_.clear(); 112 this->identifierByNetworkId_.clear(); 143 113 } 144 114 … … 150 120 Identifier* IdentifierManager::getIdentifierByString(const std::string& name) 151 121 { 152 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getStringIdentifierMapIntern().find(name);153 if (it != IdentifierManager::getStringIdentifierMapIntern().end())122 std::map<std::string, Identifier*>::const_iterator it = this->identifierByString_.find(name); 123 if (it != this->identifierByString_.end()) 154 124 return it->second; 155 125 else … … 164 134 Identifier* IdentifierManager::getIdentifierByLowercaseString(const std::string& name) 165 135 { 166 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getLowercaseStringIdentifierMapIntern().find(name);167 if (it != IdentifierManager::getLowercaseStringIdentifierMapIntern().end())136 std::map<std::string, Identifier*>::const_iterator it = this->identifierByLowercaseString_.find(name); 137 if (it != this->identifierByLowercaseString_.end()) 168 138 return it->second; 169 139 else … … 178 148 Identifier* IdentifierManager::getIdentifierByID(const uint32_t id) 179 149 { 180 std::map<uint32_t, Identifier*>::const_iterator it = IdentifierManager::getIDIdentifierMapIntern().find(id);181 if (it != IdentifierManager::getIDIdentifierMapIntern().end())150 std::map<uint32_t, Identifier*>::const_iterator it = this->identifierByNetworkId_.find(id); 151 if (it != this->identifierByNetworkId_.end()) 182 152 return it->second; 183 153 else … … 190 160 void IdentifierManager::clearNetworkIDs() 191 161 { 192 IdentifierManager::getIDIdentifierMapIntern().clear();162 this->identifierByNetworkId_.clear(); 193 163 } 194 164 } -
code/branches/core6/src/libraries/core/class/IdentifierManager.h
r9564 r9640 48 48 49 49 public: 50 static IdentifierManager& getInstance(); 51 50 52 ///////////////////////////// 51 53 ////// Class Hierarchy ////// 52 54 ///////////////////////////// 53 staticvoid createClassHierarchy();55 void createClassHierarchy(); 54 56 55 57 /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. 56 inline staticbool isCreatingHierarchy()58 inline bool isCreatingHierarchy() 57 59 { return (hierarchyCreatingCounter_s > 0); } 58 60 … … 61 63 ///// Identifier Map ///// 62 64 ////////////////////////// 63 staticvoid destroyAllIdentifiers();65 void destroyAllIdentifiers(); 64 66 65 staticIdentifier* getIdentifierByString(const std::string& name);66 staticIdentifier* getIdentifierByLowercaseString(const std::string& name);67 staticIdentifier* getIdentifierByID(uint32_t id);67 Identifier* getIdentifierByString(const std::string& name); 68 Identifier* getIdentifierByLowercaseString(const std::string& name); 69 Identifier* getIdentifierByID(uint32_t id); 68 70 69 staticvoid clearNetworkIDs();71 void clearNetworkIDs(); 70 72 71 73 /// Returns the map that stores all Identifiers with their names. 72 staticinline const std::map<std::string, Identifier*>& getStringIdentifierMap()73 { return IdentifierManager::getStringIdentifierMapIntern(); }74 inline const std::map<std::string, Identifier*>& getStringIdentifierMap() 75 { return this->identifierByString_; } 74 76 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. 75 staticinline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin()76 { return IdentifierManager::getStringIdentifierMap().begin(); }77 inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() 78 { return this->identifierByString_.begin(); } 77 79 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names. 78 staticinline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd()79 { return IdentifierManager::getStringIdentifierMap().end(); }80 inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() 81 { return this->identifierByString_.end(); } 80 82 81 83 /// Returns the map that stores all Identifiers with their names in lowercase. 82 staticinline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap()83 { return IdentifierManager::getLowercaseStringIdentifierMapIntern(); }84 inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() 85 { return this->identifierByLowercaseString_; } 84 86 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. 85 staticinline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin()86 { return IdentifierManager::getLowercaseStringIdentifierMap().begin(); }87 inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() 88 { return this->identifierByLowercaseString_.begin(); } 87 89 /// Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. 88 staticinline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd()89 { return IdentifierManager::getLowercaseStringIdentifierMap().end(); }90 inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() 91 { return this->identifierByLowercaseString_.end(); } 90 92 91 93 /// Returns the map that stores all Identifiers with their IDs. 92 staticinline const std::map<uint32_t, Identifier*>& getIDIdentifierMap()93 { return IdentifierManager::getIDIdentifierMapIntern(); }94 inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() 95 { return this->identifierByNetworkId_; } 94 96 /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. 95 staticinline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin()96 { return IdentifierManager::getIDIdentifierMap().begin(); }97 inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() 98 { return this->identifierByNetworkId_.begin(); } 97 99 /// Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. 98 staticinline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd()99 { return IdentifierManager::getIDIdentifierMap().end(); }100 inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() 101 { return this->identifierByNetworkId_.end(); } 100 102 101 103 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(); 104 Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 110 105 111 106 private: 107 IdentifierManager(); 108 IdentifierManager(const IdentifierManager&); 109 ~IdentifierManager() {} 110 112 111 /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. 113 inline staticvoid startCreatingHierarchy()112 inline void startCreatingHierarchy() 114 113 { hierarchyCreatingCounter_s++; } 115 114 /// Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. 116 inline staticvoid stopCreatingHierarchy()115 inline void stopCreatingHierarchy() 117 116 { hierarchyCreatingCounter_s--; } 118 117 119 st atic std::map<std::string, Identifier*>& getTypeIDIdentifierMap();118 std::map<std::string, Identifier*> identifierByTypeId_; //!< Map with the names as received by typeid(). This is only used internally. 120 119 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 120 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names. 121 std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase. 122 std::map<uint32_t, Identifier*> identifierByNetworkId_; //!< Returns the map that stores all Identifiers with their network IDs. 123 124 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) 125 unsigned int classIDCounter_s; //!< counter for the unique classIDs 123 126 }; 124 127 } -
code/branches/core6/src/libraries/core/config/ConfigValueContainer.h
r9564 r9640 70 70 inline virtual void call(void* object) 71 71 { 72 if (!IdentifierManager:: isCreatingHierarchy())72 if (!IdentifierManager::getInstance().isCreatingHierarchy()) 73 73 (static_cast<T*>(object)->*this->function_)(); 74 74 } -
code/branches/core6/src/libraries/network/packet/ClassID.cc
r9564 r9640 55 55 56 56 //calculate total needed size (for all strings and integers) 57 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::get StringIdentifierMapBegin();58 for(;it != IdentifierManager::get StringIdentifierMapEnd();++it){57 std::map<std::string, Identifier*>::const_iterator it = IdentifierManager::getInstance().getStringIdentifierMapBegin(); 58 for(;it != IdentifierManager::getInstance().getStringIdentifierMapEnd();++it){ 59 59 id = it->second; 60 60 if(id == NULL || !id->hasFactory()) … … 129 129 130 130 //clear the map of network ids 131 IdentifierManager:: clearNetworkIDs();131 IdentifierManager::getInstance().clearNetworkIDs(); 132 132 133 133 orxout(verbose, context::packets) << "=== processing classids: " << endl; -
code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc
r9631 r9640 80 80 { 81 81 // delete callback function objects 82 if(!IdentifierManager:: isCreatingHierarchy()){82 if(!IdentifierManager::getInstance().isCreatingHierarchy()){ 83 83 // remove object from the static objectMap 84 84 if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
Note: See TracChangeset
for help on using the changeset viewer.