- Timestamp:
- Nov 30, 2007, 1:20:20 AM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/Factory.cc
r258 r363 11 11 pointer_s = new Factory; 12 12 13 return pointer_s->identifierMap_[name]; 13 return pointer_s->identifierStringMap_[name]; 14 } 15 16 Identifier* Factory::getIdentifier(const unsigned int id) 17 { 18 if (!pointer_s) 19 pointer_s = new Factory; 20 21 return pointer_s->identifierNetworkIDMap_[id]; 14 22 } 15 23 … … 19 27 pointer_s = new Factory; 20 28 21 pointer_s->identifierMap_[name] = identifier; 29 pointer_s->identifierStringMap_[name] = identifier; 30 pointer_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 31 } 32 33 void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID) 34 { 35 pointer_s->identifierNetworkIDMap_.erase(oldID); 36 pointer_s->identifierNetworkIDMap_[newID] = identifier; 22 37 } 23 38 } -
code/branches/FICN/src/orxonox/core/Factory.h
r258 r363 17 17 public: 18 18 static Identifier* getIdentifier(const std::string& name); 19 static Identifier* getIdentifier(const unsigned int id); 19 20 static void add(const std::string& name, Identifier* identifier); 21 static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID); 20 22 21 23 private: … … 25 27 26 28 static Factory* pointer_s; 27 std::map<std::string, Identifier*> identifierMap_; 29 std::map<std::string, Identifier*> identifierStringMap_; 30 std::map<unsigned int, Identifier*> identifierNetworkIDMap_; 28 31 }; 29 32 -
code/branches/FICN/src/orxonox/core/Identifier.cc
r258 r363 7 7 // ############################### 8 8 int Identifier::hierarchyCreatingCounter_s = 0; 9 unsigned int Identifier::classIDcounter_s = 0; 9 10 10 11 Identifier::Identifier() … … 14 15 15 16 this->children_ = new IdentifierList; 17 this->classID_ = Identifier::classIDcounter_s++; 16 18 } 17 19 … … 57 59 } 58 60 61 void Identifier::setNetworkID(unsigned int id) 62 { 63 Factory::changeNetworkID(this, this->classID_, id); 64 this->classID_ = id; 65 } 66 59 67 bool Identifier::isA(const Identifier* identifier) const 60 68 { -
code/branches/FICN/src/orxonox/core/Identifier.h
r346 r363 8 8 #include "Factory.h" 9 9 10 #define HIERARCHY_VERBOSE 010 #define HIERARCHY_VERBOSE false 11 11 12 12 … … 43 43 44 44 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } 45 46 inline const unsigned int getNetworkID() const { return this->classID_; } 47 void setNetworkID(unsigned int id); 45 48 46 49 private: … … 74 77 bool bCreatedOneObject_; 75 78 static int hierarchyCreatingCounter_s; 79 static unsigned int classIDcounter_s; 80 unsigned int classID_; 76 81 }; 77 82 -
code/branches/FICN/src/orxonox/core/IdentifierIncludes.h
r258 r363 41 41 bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create() 42 42 43 #define ID(Name ) \44 Factory::getIdentifier(Name )43 #define ID(NameOrID) \ 44 Factory::getIdentifier(NameOrID)
Note: See TracChangeset
for help on using the changeset viewer.