Changeset 5778 for code/branches/core5
- Timestamp:
- Sep 24, 2009, 2:47:53 AM (15 years ago)
- Location:
- code/branches/core5/src/libraries
- Files:
-
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/ArgumentCompletionFunctions.cc
r5738 r5778 100 100 ArgumentCompletionList classlist; 101 101 102 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::get IdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)102 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it) 103 103 if ((*it).second->hasConfigValues()) 104 104 classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first))); … … 110 110 { 111 111 ArgumentCompletionList configvalues; 112 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::get IdentifierMap().find(classname);112 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname); 113 113 114 if (identifier != Identifier::get IdentifierMapEnd() && (*identifier).second->hasConfigValues())114 if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues()) 115 115 { 116 116 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it) … … 124 124 { 125 125 ArgumentCompletionList oldvalue; 126 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));127 if (identifier != Identifier::getLowercase IdentifierMapEnd())126 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 127 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 128 128 { 129 129 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); -
code/branches/core5/src/libraries/core/CMakeLists.txt
r5738 r5778 49 49 50 50 # hierarchy 51 Factory.cc52 51 Identifier.cc 53 52 MetaObjectList.cc … … 68 67 TclBind.cc 69 68 TclThreadManager.cc 70 69 71 70 # multithreading 72 71 Thread.cc -
code/branches/core5/src/libraries/core/ClassFactory.h
r5777 r5778 42 42 43 43 #include "util/Debug.h" 44 #include "Factory.h"45 44 #include "Identifier.h" 46 45 … … 71 70 72 71 /** 73 @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.72 @brief Adds the ClassFactory to the Identifier of the same type. 74 73 @param name The name of the class 75 74 @param bLoadable True if the class can be loaded through XML 76 @return Always true (this is needed because the compiler only allows assignments before main())77 75 */ 78 76 template <class T> … … 82 80 ClassIdentifier<T>::getIdentifier(name)->addFactory(this); 83 81 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 84 Factory::add(name, ClassIdentifier<T>::getIdentifier());85 82 } 86 83 -
code/branches/core5/src/libraries/core/CommandExecutor.cc
r5738 r5778 468 468 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear(); 469 469 std::string lowercase = getLowercase(fragment); 470 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercase IdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)470 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it) 471 471 if ((*it).second->hasConsoleCommands()) 472 472 if ((*it).first.find(lowercase) == 0 || fragment == "") … … 516 516 { 517 517 std::string lowercase = getLowercase(name); 518 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercase IdentifierMap().find(lowercase);519 if ((it != Identifier::getLowercase IdentifierMapEnd()) && (*it).second->hasConsoleCommands())518 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase); 519 if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands()) 520 520 return (*it).second; 521 521 -
code/branches/core5/src/libraries/core/ConfigFileManager.cc
r5738 r5778 48 48 bool config(const std::string& classname, const std::string& varname, const std::string& value) 49 49 { 50 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));51 if (identifier != Identifier::getLowercase IdentifierMapEnd())50 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 51 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 52 52 { 53 53 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); … … 60 60 bool tconfig(const std::string& classname, const std::string& varname, const std::string& value) 61 61 { 62 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercase IdentifierMap().find(getLowercase(classname));63 if (identifier != Identifier::getLowercase IdentifierMapEnd())62 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname)); 63 if (identifier != Identifier::getLowercaseStringIdentifierMapEnd()) 64 64 { 65 65 std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname)); … … 376 376 for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); ) 377 377 { 378 std::map<std::string, Identifier*>::const_iterator it2 = Identifier::get IdentifierMap().find((*it1)->getName());379 if (it2 != Identifier::get IdentifierMapEnd() && (*it2).second->hasConfigValues())378 std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName()); 379 if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues()) 380 380 { 381 381 // The section exists, delete comment … … 455 455 if (this->type_ == ConfigFileType::Settings) 456 456 { 457 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::get IdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)457 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it) 458 458 { 459 459 if (it->second->hasConfigValues()) -
code/branches/core5/src/libraries/core/Core.cc
r5759 r5778 69 69 #include "CoreIncludes.h" 70 70 #include "DynLibManager.h" 71 #include "Factory.h"72 71 #include "GameMode.h" 73 72 #include "GraphicsManager.h" … … 334 333 335 334 // creates the class hierarchy for all classes with factories 336 Factory::createClassHierarchy();335 Identifier::createClassHierarchy(); 337 336 338 337 // Do this soon after the ConfigFileManager has been created to open up the -
code/branches/core5/src/libraries/core/CoreIncludes.h
r5777 r5778 29 29 /** 30 30 @file 31 @brief Definition of macros for Identifier and Factory.31 @brief Definition of macros for Identifiers 32 32 33 33 Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface … … 46 46 #include "Identifier.h" 47 47 #include "SubclassIdentifier.h" 48 #include "Factory.h"49 48 #include "ClassFactory.h" 50 49 #include "ObjectList.h" … … 77 76 78 77 /** 79 @brief Creates the entry in theFactory.78 @brief Creates the Factory. 80 79 @param ClassName The name of the class 81 80 */ … … 84 83 85 84 /** 86 @brief Creates the entry in theFactory for classes which should not be loaded through XML.85 @brief Creates the Factory for classes which should not be loaded through XML. 87 86 @param ClassName The name of the class 88 87 */ … … 106 105 inline Identifier* ClassByString(const std::string& name) 107 106 { 108 return Factory::getIdentifier(name);107 return Identifier::getIdentifierByString(name); 109 108 } 110 109 … … 115 114 inline Identifier* ClassByID(uint32_t id) 116 115 { 117 return Factory::getIdentifier(id);116 return Identifier::getIdentifierByID(id); 118 117 } 119 118 } -
code/branches/core5/src/libraries/core/Identifier.cc
r5777 r5778 196 196 197 197 /** 198 @brief Creates the class-hierarchy by creating and destroying one object of each type. 199 */ 200 void Identifier::createClassHierarchy() 201 { 202 COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl; 203 std::map<std::string, Identifier*>::const_iterator it; 204 it = Identifier::getStringIdentifierMap().begin(); 205 Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy(); 206 for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) 207 { 208 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 209 if (it->second->hasFactory()) 210 { 211 BaseObject* temp = it->second->fabricate(0); 212 delete temp; 213 } 214 } 215 Identifier::getStringIdentifierMap().begin()->second->stopCreatingHierarchy(); 216 COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl; 217 } 218 219 /** 198 220 @brief Destroys all Identifiers. Called when exiting the program. 199 221 */ … … 214 236 this->name_ = name; 215 237 this->bSetName_ = true; 216 Identifier::getIdentifierMapIntern()[name] = this; 217 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 238 Identifier::getStringIdentifierMapIntern()[name] = this; 239 Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this; 240 Identifier::getIDIdentifierMapIntern()[this->networkID_] = this; 218 241 } 219 242 } … … 240 263 241 264 /** 242 @brief Sets the network ID to a new value and changes the entry in the Factory.265 @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map. 243 266 @param id The new network ID 244 267 */ 245 268 void Identifier::setNetworkID(uint32_t id) 246 269 { 247 Factory::changeNetworkID(this, this->networkID_, id); 270 // Identifier::getIDIdentifierMapIntern().erase(this->networkID_); 271 Identifier::getIDIdentifierMapIntern()[id] = this; 248 272 this->networkID_ = id; 249 273 } … … 304 328 305 329 /** 306 @brief Returns the map that stores all Identifiers .330 @brief Returns the map that stores all Identifiers with their names. 307 331 @return The map 308 332 */ 309 std::map<std::string, Identifier*>& Identifier::get IdentifierMapIntern()333 std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern() 310 334 { 311 335 static std::map<std::string, Identifier*> identifierMap; … … 314 338 315 339 /** 316 @brief Returns the map that stores all Identifiers .340 @brief Returns the map that stores all Identifiers with their names in lowercase. 317 341 @return The map 318 342 */ 319 std::map<std::string, Identifier*>& Identifier::getLowercase IdentifierMapIntern()343 std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern() 320 344 { 321 345 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 322 346 return lowercaseIdentifierMap; 347 } 348 349 /** 350 @brief Returns the map that stores all Identifiers with their network IDs. 351 @return The map 352 */ 353 std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern() 354 { 355 static std::map<uint32_t, Identifier*> identifierMap; 356 return identifierMap; 357 } 358 359 /** 360 @brief Returns the Identifier with a given name. 361 @param name The name of the wanted Identifier 362 @return The Identifier 363 */ 364 Identifier* Identifier::getIdentifierByString(const std::string& name) 365 { 366 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name); 367 if (it != Identifier::getStringIdentifierMapIntern().end()) 368 return it->second; 369 else 370 return 0; 371 } 372 373 /** 374 @brief Returns the Identifier with a given network ID. 375 @param id The network ID of the wanted Identifier 376 @return The Identifier 377 */ 378 Identifier* Identifier::getIdentifierByID(const uint32_t id) 379 { 380 std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id); 381 if (it != Identifier::getIDIdentifierMapIntern().end()) 382 return it->second; 383 else 384 return 0; 385 } 386 387 /** 388 @brief Cleans the NetworkID map (needed on clients for correct initialization) 389 */ 390 void Identifier::clearNetworkIDs() 391 { 392 Identifier::getIDIdentifierMapIntern().clear(); 323 393 } 324 394 -
code/branches/core5/src/libraries/core/Identifier.h
r5776 r5778 87 87 class _CoreExport Identifier 88 88 { 89 template <class T>90 friend class SubclassIdentifier;91 92 friend class Factory;93 94 89 public: 90 /** @brief Returns the name of the class the Identifier belongs to. @return The name */ 91 inline const std::string& getName() const { return this->name_; } 92 void setName(const std::string& name); 93 94 /** @brief Returns the network ID to identify a class through the network. @return the network ID */ 95 inline const uint32_t getNetworkID() const { return this->networkID_; } 96 void setNetworkID(uint32_t id); 97 98 /** @brief Returns the unique ID of the class */ 99 FORCEINLINE unsigned int getClassID() const { return this->classID_; } 100 101 /** @brief Returns the list of all existing objects of this class. @return The list */ 102 inline ObjectListBase* getObjects() const { return this->objects_; } 103 95 104 /** @brief Sets the Factory. @param factory The factory to assign */ 96 105 inline void addFactory(BaseFactory* factory) { this->factory_ = factory; } 106 /** @brief Returns true if the Identifier has a Factory. */ 107 inline bool hasFactory() const { return (this->factory_ != 0); } 97 108 98 109 BaseObject* fabricate(BaseObject* creator); 110 111 /** @brief Returns true if the class can be loaded through XML. */ 112 inline bool isLoadable() const { return this->bLoadable_; } 113 /** @brief Set the class to be loadable through XML or not. */ 114 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 115 99 116 bool isA(const Identifier* identifier) const; 100 117 bool isExactlyA(const Identifier* identifier) const; … … 104 121 bool isDirectParentOf(const Identifier* identifier) const; 105 122 106 /** @brief Returns true if the class can be loaded through XML. */ 107 inline bool isLoadable() const { return this->bLoadable_; } 108 /** @brief Set the class to be loadable through XML or not. */ 109 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 110 111 /** @brief Returns the list of all existing objects of this class. @return The list */ 112 inline ObjectListBase* getObjects() const 113 { return this->objects_; } 114 115 /** @brief Returns the name of the class the Identifier belongs to. @return The name */ 116 inline const std::string& getName() const { return this->name_; } 117 void setName(const std::string& name); 118 119 virtual void updateConfigValues(bool updateChildren = true) const = 0; 123 124 ///////////////////////////// 125 ////// Class Hierarchy ////// 126 ///////////////////////////// 127 static void createClassHierarchy(); 128 129 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ 130 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } 120 131 121 132 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ … … 148 159 149 160 150 /** @brief Returns the map that stores all Identifiers. @return The map */ 151 static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); } 152 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */ 153 static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); } 154 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */ 155 static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); } 161 ////////////////////////// 162 ///// Identifier Map ///// 163 ////////////////////////// 164 static void destroyAllIdentifiers(); 165 166 static Identifier* getIdentifierByString(const std::string& name); 167 static Identifier* getIdentifierByID(uint32_t id); 168 169 static void clearNetworkIDs(); 170 171 /** @brief Returns the map that stores all Identifiers with their names. @return The map */ 172 static inline const std::map<std::string, Identifier*>& getStringIdentifierMap() { return Identifier::getStringIdentifierMapIntern(); } 173 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. @return The const_iterator */ 174 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() { return Identifier::getStringIdentifierMap().begin(); } 175 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names. @return The const_iterator */ 176 static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() { return Identifier::getStringIdentifierMap().end(); } 156 177 157 178 /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */ 158 static inline const std::map<std::string, Identifier*>& getLowercase IdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }179 static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() { return Identifier::getLowercaseStringIdentifierMapIntern(); } 159 180 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */ 160 static inline std::map<std::string, Identifier*>::const_iterator getLowercase IdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }181 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() { return Identifier::getLowercaseStringIdentifierMap().begin(); } 161 182 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */ 162 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); } 163 183 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() { return Identifier::getLowercaseStringIdentifierMap().end(); } 184 185 /** @brief Returns the map that stores all Identifiers with their IDs. @return The map */ 186 static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() { return Identifier::getIDIdentifierMapIntern(); } 187 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. @return The const_iterator */ 188 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() { return Identifier::getIDIdentifierMap().begin(); } 189 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. @return The const_iterator */ 190 static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() { return Identifier::getIDIdentifierMap().end(); } 191 192 193 ///////////////////////// 194 ///// Config Values ///// 195 ///////////////////////// 196 virtual void updateConfigValues(bool updateChildren = true) const = 0; 197 198 /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */ 199 inline bool hasConfigValues() const { return this->bHasConfigValues_; } 164 200 165 201 /** @brief Returns the map that stores all config values. @return The const_iterator */ … … 177 213 inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); } 178 214 215 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); 216 ConfigValueContainer* getConfigValueContainer(const std::string& varname); 217 ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname); 218 219 220 //////////////////////////// 221 ///// Console Commands ///// 222 //////////////////////////// 223 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */ 224 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; } 179 225 180 226 /** @brief Returns the map that stores all console commands. @return The const_iterator */ … … 192 238 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); } 193 239 240 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut); 241 ConsoleCommand* getConsoleCommand(const std::string& name) const; 242 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const; 243 244 245 /////////////////// 246 ///// XMLPort ///// 247 /////////////////// 194 248 /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */ 195 249 inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; } … … 213 267 inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); } 214 268 215 /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */216 inline bool hasConfigValues() const { return this->bHasConfigValues_; }217 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */218 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }219 220 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */221 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }222 223 /** @brief Returns the network ID to identify a class through the network. @return the network ID */224 inline const uint32_t getNetworkID() const { return this->networkID_; }225 226 /** @brief Sets the network ID to a new value. @param id The new value */227 void setNetworkID(uint32_t id);228 229 /** @brief Returns the unique ID of the class */230 FORCEINLINE unsigned int getClassID() const { return this->classID_; }231 232 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);233 ConfigValueContainer* getConfigValueContainer(const std::string& varname);234 ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);235 236 269 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container); 237 270 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname); … … 243 276 XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname); 244 277 245 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);246 ConsoleCommand* getConsoleCommand(const std::string& name) const;247 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;248 249 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);250 251 static void destroyAllIdentifiers();252 278 253 279 protected: … … 259 285 virtual void createSuperFunctionCaller() const = 0; 260 286 261 /** @brief Returns the map that stores all Identifiers. @return The map */ 262 static std::map<std::string, Identifier*>& getIdentifierMapIntern(); 287 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 288 289 /** @brief Returns the map that stores all Identifiers with their names. @return The map */ 290 static std::map<std::string, Identifier*>& getStringIdentifierMapIntern(); 263 291 /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */ 264 static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern(); 292 static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern(); 293 /** @brief Returns the map that stores all Identifiers with their network IDs. @return The map */ 294 static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern(); 265 295 266 296 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ … … 345 375 346 376 public: 347 static ClassIdentifier<T> *getIdentifier();348 static ClassIdentifier<T> *getIdentifier(const std::string& name);377 static ClassIdentifier<T>* getIdentifier(); 378 static ClassIdentifier<T>* getIdentifier(const std::string& name); 349 379 350 380 bool initialiseObject(T* object, const std::string& className, bool bRootClass); … … 377 407 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 378 408 { 379 // check if the static field has already been filled380 if ( ClassIdentifier<T>::classIdentifier_s == 0)409 // check if the Identifier already exists 410 if (!ClassIdentifier<T>::classIdentifier_s) 381 411 ClassIdentifier<T>::initialiseIdentifier(); 382 412 -
code/branches/core5/src/libraries/core/XMLPort.h
r5747 r5778 51 51 #include "util/MultiType.h" 52 52 #include "util/OrxAssert.h" 53 #include "Factory.h"54 53 #include "Identifier.h" 55 54 #include "Executor.h" … … 548 547 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 549 548 { 550 Identifier* identifier = Factory::getIdentifier(child->Value());549 Identifier* identifier = Identifier::getIdentifierByString(child->Value()); 551 550 if (identifier) 552 551 { -
code/branches/core5/src/libraries/network/packet/ClassID.cc
r5738 r5778 49 49 Identifier *id; 50 50 std::string classname; 51 unsigned int nrOfClasses=0; 51 unsigned int nrOfClasses=0; 52 52 unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses 53 53 uint32_t network_id; 54 54 flags_ = flags_ | PACKET_FLAGS_CLASSID; 55 55 std::queue<std::pair<uint32_t, std::string> > tempQueue; 56 56 57 57 //calculate total needed size (for all strings and integers) 58 std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();59 for(;it != Factory::getFactoryMapEnd();++it){58 std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); 59 for(;it != Identifier::getStringIdentifierMapEnd();++it){ 60 60 id = (*it).second; 61 if(id == NULL )61 if(id == NULL || !id->hasFactory()) 62 62 continue; 63 63 classname = id->getName(); … … 70 70 packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t); 71 71 } 72 72 73 73 this->data_=new uint8_t[ packetSize ]; 74 74 //set the appropriate packet id 75 75 assert(this->data_); 76 76 *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID; 77 77 78 78 uint8_t *temp=data_+sizeof(uint32_t); 79 79 // save the number of all classes 80 80 *(uint32_t*)temp = nrOfClasses; 81 81 temp += sizeof(uint32_t); 82 82 83 83 // now save all classids and classnames 84 84 std::pair<uint32_t, std::string> tempPair; … … 91 91 temp+=2*sizeof(uint32_t)+tempPair.second.size()+1; 92 92 } 93 93 94 94 COUT(5) << "classid packetSize is " << packetSize << endl; 95 95 96 96 } 97 97 … … 111 111 temp += sizeof(uint32_t); 112 112 totalsize += sizeof(uint32_t); // storage size for nr of all classes 113 113 114 114 for(unsigned int i=0; i<nrOfClasses; i++){ 115 115 totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t)); … … 125 125 uint32_t stringsize; 126 126 unsigned char *classname; 127 128 129 //clea nthe map of network ids130 Factory::cleanNetworkIDs();131 127 128 129 //clear the map of network ids 130 Identifier::clearNetworkIDs(); 131 132 132 COUT(4) << "=== processing classids: " << endl; 133 133 std::pair<uint32_t, std::string> tempPair; … … 136 136 nrOfClasses = *(uint32_t*)temp; 137 137 temp += sizeof(uint32_t); 138 138 139 139 for( int i=0; i<nrOfClasses; i++){ 140 140 networkID = *(uint32_t*)temp;
Note: See TracChangeset
for help on using the changeset viewer.