Changeset 457 for code/branches
- Timestamp:
- Dec 10, 2007, 8:34:48 PM (17 years ago)
- Location:
- code/branches/objecthierarchy/src/orxonox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/core/ClassFactory.h
r453 r457 10 10 11 11 #include "Identifier.h" 12 #include "Debug.h"13 12 14 13 namespace orxonox … … 22 21 { 23 22 public: 24 static bool create( );23 static bool create(const std::string& name); 25 24 BaseObject* fabricate(); 26 25 … … 34 33 35 34 /** 36 @brief Adds the ClassFactory to the Identifier of the same type and creates a new object to retrieve the parents.35 @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory. 37 36 @return Always true (this is needed because the compiler only allows assignments before main()) 38 37 */ 39 38 template <class T> 40 bool ClassFactory<T>::create( )39 bool ClassFactory<T>::create(const std::string& name) 41 40 { 42 // Add the ClassFactory to the Classidentifier of type T43 41 ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>); 44 45 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 46 ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy(); 47 COUT(4) << "*** Create Factory -> Create Class\n"; 48 BaseObject* temp = ClassIdentifier<T>::getIdentifier()->fabricate(); 49 delete temp; 50 ClassIdentifier<T>::getIdentifier()->stopCreatingHierarchy(); 42 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 51 43 52 44 return true; -
code/branches/objecthierarchy/src/orxonox/core/ConfigValueContainer.cc
r456 r457 421 421 if (!ConfigValueContainer::readConfigFile_s) 422 422 ConfigValueContainer::readConfigFile(CONFIGFILEPATH); 423 424 423 425 424 // The string of the section we're searching -
code/branches/objecthierarchy/src/orxonox/core/CoreIncludes.h
r453 r457 81 81 */ 82 82 #define CreateFactory(ClassName) \ 83 bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create( )83 bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create(#ClassName) 84 84 85 85 /** -
code/branches/objecthierarchy/src/orxonox/core/Factory.cc
r447 r457 6 6 #include "Factory.h" 7 7 #include "Identifier.h" 8 #include "Debug.h" 9 #include "../objects/BaseObject.h" 8 10 9 11 namespace orxonox … … 60 62 pointer_s->identifierNetworkIDMap_[newID] = identifier; 61 63 } 64 65 /** 66 @brief Creates the class-hierarchy by creating and destroying one object of each type. 67 */ 68 void Factory::createClassHierarchy() 69 { 70 if (!pointer_s) 71 pointer_s = new Factory; 72 73 COUT(4) << "*** Factory -> Create class-hierarchy\n"; 74 std::map<std::string, Identifier*>::iterator it; 75 it = pointer_s->identifierStringMap_.begin(); 76 (*pointer_s->identifierStringMap_.begin()).second->startCreatingHierarchy(); 77 for (it = pointer_s->identifierStringMap_.begin(); it != pointer_s->identifierStringMap_.end(); ++it) 78 { 79 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 80 BaseObject* temp = (*it).second->fabricate(); 81 delete temp; 82 } 83 (*pointer_s->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 84 COUT(4) << "*** Factory -> Finished class-hierarchy creation\n"; 85 } 62 86 } -
code/branches/objecthierarchy/src/orxonox/core/Factory.h
r447 r457 36 36 static void add(const std::string& name, Identifier* identifier); 37 37 static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID); 38 static void createClassHierarchy(); 38 39 39 40 private: -
code/branches/objecthierarchy/src/orxonox/core/Identifier.h
r453 r457 64 64 friend class SubclassIdentifier; // Forward declaration 65 65 66 template <class T> 67 friend class ClassFactory; // Forward declaration 66 friend class Factory; // Forward declaration 68 67 69 68 public: … … 216 215 COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n"; 217 216 pointer_s->name_ = name; 218 Factory::add(name, pointer_s); // Add the Identifier to the Factory217 // Factory::add(name, pointer_s); // Add the Identifier to the Factory 219 218 220 219 if (bRootClass) -
code/branches/objecthierarchy/src/orxonox/orxonox.cc
r454 r457 119 119 setupCEGUI(); 120 120 createFrameListener(); 121 121 Factory::createClassHierarchy(); 122 122 123 123 #define testandcout(code) \
Note: See TracChangeset
for help on using the changeset viewer.