Changeset 690 for code/branches/FICN
- Timestamp:
- Dec 26, 2007, 11:28:31 PM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/ClassFactory.h
r682 r690 73 73 { 74 74 COUT(4) << "*** Create entry for " << name << " in Factory." << std::endl; 75 ClassIdentifier<T>::createIdentifier(name); 75 76 ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>); 76 77 Factory::add(name, ClassIdentifier<T>::getIdentifier()); -
code/branches/FICN/src/orxonox/core/Identifier.cc
r677 r690 40 40 int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero 41 41 unsigned int Identifier::classIDcounter_s = 0; // Set the static member variable classIDcounter_s to zero 42 std::map<std::string, Identifier*> Identifier::identifierMap_s; 42 43 43 44 /** -
code/branches/FICN/src/orxonox/core/Identifier.h
r682 r690 172 172 unsigned int classID_; //!< The network ID to identify a class through the network 173 173 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 174 static std::map<std::string, Identifier*> identifierMap_s; //!< A map, containing all existing ClassIdentifiers 174 175 }; 175 176 … … 189 190 public: 190 191 static ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass); 191 static ClassIdentifier<T>* getIdentifier();192 static void createIdentifier(const std::string& name); 192 193 static void addObject(T* object); 193 194 195 /** @returns the Identifier itself (createIdentifier() has to be called first). */ 196 inline static ClassIdentifier<T>* getIdentifier() { return pointer_s; } 197 194 198 private: 195 ClassIdentifier( );199 ClassIdentifier(const std::string& name); 196 200 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 197 201 ~ClassIdentifier(); … … 206 210 /** 207 211 @brief Constructor: Creates the ObjectList. 208 */ 209 template <class T> 210 ClassIdentifier<T>::ClassIdentifier() 212 @param name The name of the Class 213 */ 214 template <class T> 215 ClassIdentifier<T>::ClassIdentifier(const std::string& name) 211 216 { 212 217 this->objects_ = new ObjectList<T>; 218 this->name_ = name; 219 this->identifierMap_s[name] = this; 213 220 } 214 221 … … 236 243 237 244 // It's a singleton, so maybe we have to create it first 238 if (!pointer_s) 239 { 240 COUT(4) << "*** Register Class in " << name << "-Singleton -> Create Singleton." << std::endl; 241 pointer_s = new ClassIdentifier(); 242 } 245 ClassIdentifier<T>::createIdentifier(name); 243 246 244 247 // Check if at least one object of the given type was created … … 258 261 259 262 /** 260 @returns the Identifier itself. 261 */ 262 template <class T> 263 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 264 { 265 if (!pointer_s) 263 @brief Creates the only instance of this class for the template class T. 264 @param name The name of the Class 265 */ 266 template <class T> 267 void ClassIdentifier<T>::createIdentifier(const std::string& name) 268 { 269 static bool bFirstCeateIdentifierFunctionCall = true; 270 static ClassIdentifier<T> classIdentifierObject = ClassIdentifier<T>(name); 271 272 if (bFirstCeateIdentifierFunctionCall) 266 273 { 267 COUT(4) << "*** Create Singleton." << std::endl; 268 pointer_s = new ClassIdentifier(); 274 COUT(4) << "*** Create Identifier Singleton for " << name << "." << std::endl; 275 pointer_s = &classIdentifierObject; 276 bFirstCeateIdentifierFunctionCall = false; 269 277 } 270 271 return pointer_s;272 278 } 273 279
Note: See TracChangeset
for help on using the changeset viewer.