Changeset 551 for code/branches/FICN
- Timestamp:
- Dec 17, 2007, 1:02:01 AM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/Factory.cc
r513 r551 38 38 namespace orxonox 39 39 { 40 Factory* Factory::pointer_s = NULL; // Set the static member variable pointer_s to zero 40 Factory* Factory::pointer1_s; 41 Factory* Factory::pointer2_s; 42 Factory* Factory::pointer3_s; 43 Factory* Factory::pointer4_s; 44 Factory* Factory::pointer5_s = NULL; // Set the static member variable pointer5_s to zero 45 46 /** 47 @brief Checks if the pointer to the only Factory-object exists and creates it, if not. 48 */ 49 void Factory::checkPointer() 50 { 51 if ((!pointer5_s) || (pointer1_s != pointer2_s) || (pointer2_s != pointer3_s) || (pointer3_s != pointer4_s) || (pointer4_s != pointer5_s)) 52 { 53 std::cout << pointer1_s << std::endl; 54 std::cout << pointer2_s << std::endl; 55 std::cout << pointer3_s << std::endl; 56 std::cout << pointer4_s << std::endl; 57 std::cout << pointer5_s << std::endl; 58 pointer1_s = pointer2_s = pointer3_s = pointer4_s = pointer5_s = new Factory; 59 std::cout << pointer1_s << std::endl; 60 std::cout << pointer2_s << std::endl; 61 std::cout << pointer3_s << std::endl; 62 std::cout << pointer4_s << std::endl; 63 std::cout << pointer5_s << std::endl; 64 } 65 } 41 66 42 67 /** … … 46 71 Identifier* Factory::getIdentifier(const std::string& name) 47 72 { 48 if (!pointer_s) 49 pointer_s = new Factory; 73 Factory::checkPointer(); 50 74 51 return pointer _s->identifierStringMap_[name];75 return pointer1_s->identifierStringMap_[name]; 52 76 } 53 77 … … 58 82 Identifier* Factory::getIdentifier(const unsigned int id) 59 83 { 60 if (!pointer_s) 61 pointer_s = new Factory; 84 Factory::checkPointer(); 62 85 63 return pointer _s->identifierNetworkIDMap_[id];86 return pointer1_s->identifierNetworkIDMap_[id]; 64 87 } 65 88 … … 71 94 void Factory::add(const std::string& name, Identifier* identifier) 72 95 { 73 if (!pointer_s) 74 pointer_s = new Factory; 96 Factory::checkPointer(); 75 97 76 pointer _s->identifierStringMap_[name] = identifier;77 pointer _s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;98 pointer1_s->identifierStringMap_[name] = identifier; 99 pointer1_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 78 100 } 79 101 … … 86 108 void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID) 87 109 { 88 pointer_s->identifierNetworkIDMap_.erase(oldID); 89 pointer_s->identifierNetworkIDMap_[newID] = identifier; 110 Factory::checkPointer(); 111 112 pointer1_s->identifierNetworkIDMap_.erase(oldID); 113 pointer1_s->identifierNetworkIDMap_[newID] = identifier; 90 114 } 91 115 … … 95 119 void Factory::createClassHierarchy() 96 120 { 97 if (!pointer_s) 98 pointer_s = new Factory; 121 Factory::checkPointer(); 99 122 100 123 COUT(4) << "*** Factory -> Create class-hierarchy\n"; 101 124 std::map<std::string, Identifier*>::iterator it; 102 it = pointer _s->identifierStringMap_.begin();103 (*pointer _s->identifierStringMap_.begin()).second->startCreatingHierarchy();104 for (it = pointer _s->identifierStringMap_.begin(); it != pointer_s->identifierStringMap_.end(); ++it)125 it = pointer1_s->identifierStringMap_.begin(); 126 (*pointer1_s->identifierStringMap_.begin()).second->startCreatingHierarchy(); 127 for (it = pointer1_s->identifierStringMap_.begin(); it != pointer1_s->identifierStringMap_.end(); ++it) 105 128 { 106 129 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 108 131 delete temp; 109 132 } 110 (*pointer _s->identifierStringMap_.begin()).second->stopCreatingHierarchy();133 (*pointer1_s->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 111 134 COUT(4) << "*** Factory -> Finished class-hierarchy creation\n"; 112 135 } -
code/branches/FICN/src/orxonox/core/Factory.h
r496 r551 39 39 40 40 private: 41 Factory() {} // don't create 42 Factory(const Factory& factory) {} // don't copy 43 ~Factory() {} // don't delete 41 Factory() {} // don't create 42 Factory(const Factory& factory) {} // don't copy 43 ~Factory() {} // don't delete 44 static void checkPointer(); 44 45 45 static Factory* pointer_s; //!< The pointer to the singleton 46 static Factory* pointer1_s; //!< The 1st pointer to the singleton 47 static Factory* pointer2_s; //!< The 2nd pointer to the singleton 48 static Factory* pointer3_s; //!< The 3rd pointer to the singleton 49 static Factory* pointer4_s; //!< The 4th pointer to the singleton 50 static Factory* pointer5_s; //!< The 5th pointer to the singleton 46 51 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 47 52 std::map<unsigned int, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier
Note: See TracChangeset
for help on using the changeset viewer.