- Timestamp:
- Dec 17, 2007, 1:19:13 AM (17 years ago)
- Location:
- code/branches/FICN/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/loader/loader_platform.h
r382 r553 34 34 #ifdef LOADER_BUILD 35 35 #define _LoaderExport __declspec( dllexport ) 36 #elif defined(LOADER_STATIC) 37 #define _LoaderExport 36 38 #else 37 39 #define _LoaderExport __declspec( dllimport ) -
code/branches/FICN/src/orxonox/core/Factory.cc
r552 r553 38 38 namespace orxonox 39 39 { 40 Factory* Factory::pointer_s = NULL; // Set the static member variable pointer_s to zero41 42 40 /** 43 41 @returns the Identifier with a given name. … … 46 44 Identifier* Factory::getIdentifier(const std::string& name) 47 45 { 48 Factory::checkPointer(); 49 50 return pointer_s->identifierStringMap_[name]; 46 return getFactoryPointer()->identifierStringMap_[name]; 51 47 } 52 48 … … 57 53 Identifier* Factory::getIdentifier(const unsigned int id) 58 54 { 59 Factory::checkPointer(); 60 61 return pointer_s->identifierNetworkIDMap_[id]; 55 return getFactoryPointer()->identifierNetworkIDMap_[id]; 62 56 } 63 57 … … 69 63 void Factory::add(const std::string& name, Identifier* identifier) 70 64 { 71 Factory::checkPointer(); 72 73 pointer_s->identifierStringMap_[name] = identifier; 74 pointer_s->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 65 getFactoryPointer()->identifierStringMap_[name] = identifier; 66 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 75 67 } 76 68 … … 83 75 void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID) 84 76 { 85 Factory::checkPointer(); 86 87 pointer_s->identifierNetworkIDMap_.erase(oldID); 88 pointer_s->identifierNetworkIDMap_[newID] = identifier; 77 getFactoryPointer()->identifierNetworkIDMap_.erase(oldID); 78 getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier; 89 79 } 90 80 … … 94 84 void Factory::createClassHierarchy() 95 85 { 96 Factory::checkPointer();97 98 86 COUT(4) << "*** Factory -> Create class-hierarchy\n"; 99 87 std::map<std::string, Identifier*>::iterator 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)88 it = getFactoryPointer()->identifierStringMap_.begin(); 89 (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy(); 90 for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it) 103 91 { 104 92 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 106 94 delete temp; 107 95 } 108 (* pointer_s->identifierStringMap_.begin()).second->stopCreatingHierarchy();96 (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 109 97 COUT(4) << "*** Factory -> Finished class-hierarchy creation\n"; 110 98 } 99 100 /** 101 @brief blubb 102 */ 103 Factory* Factory::getFactoryPointer() 104 { 105 static Factory theOneAndOnlyInstance = Factory(); 106 return &theOneAndOnlyInstance; 107 } 111 108 } -
code/branches/FICN/src/orxonox/core/Factory.h
r552 r553 38 38 static void createClassHierarchy(); 39 39 40 static Factory* getFactoryPointer();// avoid overriding pointer_s in the static intialisation process 41 40 42 private: 41 43 Factory() {} // don't create 42 44 Factory(const Factory& factory) {} // don't copy 43 45 ~Factory() {} // don't delete 46 static void checkPointer(); 44 47 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 singleton55 48 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 56 49 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.