Changeset 552
- Timestamp:
- Dec 17, 2007, 1:11:28 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
r551 r552 38 38 namespace orxonox 39 39 { 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 } 40 Factory* Factory::pointer_s = NULL; // Set the static member variable pointer_s to zero 66 41 67 42 /** … … 73 48 Factory::checkPointer(); 74 49 75 return pointer 1_s->identifierStringMap_[name];50 return pointer_s->identifierStringMap_[name]; 76 51 } 77 52 … … 84 59 Factory::checkPointer(); 85 60 86 return pointer 1_s->identifierNetworkIDMap_[id];61 return pointer_s->identifierNetworkIDMap_[id]; 87 62 } 88 63 … … 96 71 Factory::checkPointer(); 97 72 98 pointer 1_s->identifierStringMap_[name] = identifier;99 pointer 1_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;73 pointer_s->identifierStringMap_[name] = identifier; 74 pointer_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 100 75 } 101 76 … … 110 85 Factory::checkPointer(); 111 86 112 pointer 1_s->identifierNetworkIDMap_.erase(oldID);113 pointer 1_s->identifierNetworkIDMap_[newID] = identifier;87 pointer_s->identifierNetworkIDMap_.erase(oldID); 88 pointer_s->identifierNetworkIDMap_[newID] = identifier; 114 89 } 115 90 … … 123 98 COUT(4) << "*** Factory -> Create class-hierarchy\n"; 124 99 std::map<std::string, Identifier*>::iterator it; 125 it = pointer 1_s->identifierStringMap_.begin();126 (*pointer 1_s->identifierStringMap_.begin()).second->startCreatingHierarchy();127 for (it = pointer 1_s->identifierStringMap_.begin(); it != pointer1_s->identifierStringMap_.end(); ++it)100 it = pointer_s->identifierStringMap_.begin(); 101 (*pointer_s->identifierStringMap_.begin()).second->startCreatingHierarchy(); 102 for (it = pointer_s->identifierStringMap_.begin(); it != pointer_s->identifierStringMap_.end(); ++it) 128 103 { 129 104 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 131 106 delete temp; 132 107 } 133 (*pointer 1_s->identifierStringMap_.begin()).second->stopCreatingHierarchy();108 (*pointer_s->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 134 109 COUT(4) << "*** Factory -> Finished class-hierarchy creation\n"; 135 110 } -
code/branches/FICN/src/orxonox/core/Factory.h
r551 r552 42 42 Factory(const Factory& factory) {} // don't copy 43 43 ~Factory() {} // don't delete 44 static void checkPointer();45 44 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 45 /** 46 @brief Checks if the pointer to the only Factory-object exists and creates it, if not. 47 */ 48 inline static void checkPointer() 49 { 50 if (!pointer_s) 51 pointer_s = new Factory; 52 } 53 54 static Factory* pointer_s; //!< The pointer to the singleton 51 55 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 52 56 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.