Changeset 811
- Timestamp:
- Feb 13, 2008, 6:39:53 PM (17 years ago)
- Location:
- code/branches/core/src/orxonox
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/Orxonox.cc
r808 r811 754 754 std::cout << "2\n"; 755 755 */ 756 756 757 std::cout << "Test 13\n"; 757 758 … … 833 834 std::cout << "Mask 2:\n"; 834 835 TestClassTreeMask(test13_2); 835 836 /* 836 837 ClassTreeMask test13_3; 837 838 test13_3.include(Class(A1)); … … 967 968 968 969 std::cout << "9\n"; 970 */ 971 972 std::cout << "Test 14\n"; 973 std::cout << "1\n"; 974 975 SubclassIdentifier<A1> test14_1; 976 test14_1 = Class(A1B1C1); 977 std::cout << test14_1.getIdentifier()->getName() << std::endl; 978 979 SubclassIdentifier<A1> test14_2 = Class(A1B1C2); 980 std::cout << test14_2.getIdentifier()->getName() << std::endl; 981 982 SubclassIdentifier<Interface1> test14_3; 983 test14_3 = Class(A2B2C1); 984 std::cout << test14_3.getIdentifier()->getName() << std::endl; 985 986 SubclassIdentifier<A1B2> test14_4; 987 test14_4 = Class(A1B2C1); 988 std::cout << test14_4.getIdentifier()->getName() << std::endl; 989 990 SubclassIdentifier<BaseObject> test14_5 = Class(Test1); 991 std::cout << test14_5.getIdentifier()->getName() << std::endl; 969 992 970 993 // startRenderLoop(); -
code/branches/core/src/orxonox/core/ClassFactory.h
r805 r811 72 72 bool ClassFactory<T>::create(const std::string& name) 73 73 { 74 COUT(4) << "*** C reate entry for " << name << " in Factory." << std::endl;75 ClassManager<T>::getIdentifier( name)->addFactory(new ClassFactory<T>);76 Factory::add(name, ClassManager<T>::getIdentifier( name));74 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 75 ClassManager<T>::getIdentifier()->addFactory(new ClassFactory<T>); 76 Factory::add(name, ClassManager<T>::getIdentifier()); 77 77 78 78 return true; -
code/branches/core/src/orxonox/core/ClassManager.h
r810 r811 63 63 public: 64 64 static ClassManager<T>* getSingleton(); 65 static ClassIdentifier<T>* getIdentifier( const std::string& name);65 static ClassIdentifier<T>* getIdentifier(); 66 66 static const std::string& getName(); 67 67 … … 96 96 97 97 /** 98 @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier .98 @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name. 99 99 @return The unique Identifier 100 100 */ 101 101 template <class T> 102 ClassIdentifier<T>* ClassManager<T>::getIdentifier( const std::string& name)102 ClassIdentifier<T>* ClassManager<T>::getIdentifier() 103 103 { 104 104 // Check if the ClassManager is already initialized 105 105 if (!ClassManager<T>::getSingleton()->bInitialized_) 106 106 { 107 // Get the name of the class 108 std::string name = typeid(T).name(); 109 107 110 // It's not -> retrieve the ClassIdentifier through IdentifierDistributor 108 COUT(4) << "*** C reate Identifier Singleton." << std::endl;111 COUT(4) << "*** ClassManager: Request Identifier Singleton for " << name << "." << std::endl; 109 112 110 113 // First create a ClassIdentifier in case there's no instance existing yet … … 116 119 // If the retrieved Identifier differs from our proposal, we don't need the proposal any more 117 120 if (temp != ClassManager<T>::getSingleton()->identifier_) 121 { 122 COUT(4) << "*** ClassManager: Requested Identifier for " << name << " was already existing and got assigned." << std::endl; 123 124 // Delete the unnecessary proposal 118 125 delete temp; 126 } 127 else 128 { 129 COUT(4) << "*** ClassManager: Requested Identifier for " << name << " was not yet existing and got created." << std::endl; 130 } 119 131 120 132 ClassManager<T>::getSingleton()->bInitialized_ = true; -
code/branches/core/src/orxonox/core/ClassTreeMask.cc
r809 r811 247 247 ClassTreeMask::ClassTreeMask() 248 248 { 249 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier( "BaseObject"), true);249 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier(), true); 250 250 } 251 251 … … 256 256 ClassTreeMask::ClassTreeMask(const ClassTreeMask& other) 257 257 { 258 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier( "BaseObject"), true);258 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier(), true); 259 259 for (ClassTreeMaskIterator it = other.root_; it; ++it) 260 260 this->add(it->getClass(), it->isIncluded()); … … 354 354 { 355 355 delete this->root_; 356 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier( "BaseObject"), true);356 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier(), true); 357 357 } 358 358 -
code/branches/core/src/orxonox/core/ConfigValueContainer.cc
r797 r811 870 870 if (!file.is_open()) 871 871 { 872 COUT(1) << "An error occurred in ConfigValueContainer:" << std::endl; 872 873 COUT(1) << "Error: Couldn't open config-file " << filename << " to read the config values!" << std::endl; 873 874 return; … … 916 917 if (!file.is_open()) 917 918 { 919 COUT(1) << "An error occurred in ConfigValueContainer:" << std::endl; 918 920 COUT(1) << "Error: Couldn't open config-file " << filename << " to write the config values!" << std::endl; 919 921 return; -
code/branches/core/src/orxonox/core/CoreIncludes.h
r805 r811 58 58 */ 59 59 #define InternRegisterObject(ClassName, bRootClass) \ 60 this->setIdentifier(orxonox::ClassManager<ClassName>::getIdentifier( #ClassName)->registerClass(this->getParents(), #ClassName, bRootClass)); \60 this->setIdentifier(orxonox::ClassManager<ClassName>::getIdentifier()->registerClass(this->getParents(), #ClassName, bRootClass)); \ 61 61 if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \ 62 62 this->getParents()->add(this->getIdentifier()); \ 63 orxonox::ClassManager<ClassName>::getIdentifier( #ClassName)->addObject(this)63 orxonox::ClassManager<ClassName>::getIdentifier()->addObject(this) 64 64 65 65 /** … … 112 112 */ 113 113 #define Class(ClassName) \ 114 ClassManager<ClassName>::getIdentifier( #ClassName)114 ClassManager<ClassName>::getIdentifier() 115 115 116 116 /** -
code/branches/core/src/orxonox/core/Factory.cc
r790 r811 84 84 void Factory::createClassHierarchy() 85 85 { 86 COUT(3) << "*** Factory ->Create class-hierarchy" << std::endl;86 COUT(3) << "*** Factory: Create class-hierarchy" << std::endl; 87 87 std::map<std::string, Identifier*>::iterator it; 88 88 it = getFactoryPointer()->identifierStringMap_.begin(); … … 95 95 } 96 96 (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy(); 97 COUT(3) << "*** Factory ->Finished class-hierarchy creation" << std::endl;97 COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl; 98 98 } 99 99 -
code/branches/core/src/orxonox/core/Identifier.cc
r806 r811 70 70 void Identifier::initialize(const IdentifierList* parents) 71 71 { 72 COUT(4) << "*** I nitialize " << this->name_ << "-Singleton." << std::endl;72 COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl; 73 73 this->bCreatedOneObject_ = true; 74 74 … … 99 99 { 100 100 // Abstract classes don't have a factory and therefore can't create new objects 101 COUT(1) << "An error occurred in Identifier:" << std::endl; 101 102 COUT(1) << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract." << std::endl; 102 103 COUT(1) << "Aborting..." << std::endl; -
code/branches/core/src/orxonox/core/Identifier.h
r810 r811 147 147 { 148 148 hierarchyCreatingCounter_s++; 149 COUT(4) << "*** I ncreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;149 COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl; 150 150 } 151 151 … … 156 156 { 157 157 hierarchyCreatingCounter_s--; 158 COUT(4) << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;158 COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl; 159 159 } 160 160 … … 228 228 ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass) 229 229 { 230 COUT(4) << "*** Register Class in " << name << "-Singleton." << std::endl;230 COUT(4) << "*** ClassIdentifier: Register Class in " << name << "-Singleton." << std::endl; 231 231 232 232 // Check if at least one object of the given type was created … … 236 236 this->setName(name); 237 237 238 COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl;238 COUT(4) << "*** ClassIdentifier: Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl; 239 239 if (bRootClass) 240 240 this->initialize(NULL); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case. … … 267 267 void ClassIdentifier<T>::addObject(T* object) 268 268 { 269 COUT(4) << "*** Added object to " << this->getName() << "-list." << std::endl;269 COUT(4) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 270 270 object->getMetaList().add(this->objects_, this->objects_->add(object)); 271 271 } … … 299 299 SubclassIdentifier() 300 300 { 301 std::string name = ClassManager<T>::getName(); 302 303 if (name != "unknown") 304 this->subclassIdentifier_ = ClassManager<T>::getIdentifier(name); 305 else 306 this->subclassIdentifier_ = 0; 307 308 this->identifier_ = this->subclassIdentifier_; 301 this->identifier_ = ClassManager<T>::getIdentifier(); 309 302 } 310 303 … … 315 308 SubclassIdentifier(Identifier* identifier) 316 309 { 317 std::string name = ClassManager<T>::getName();318 319 if (name != "unknown")320 this->subclassIdentifier_ = ClassManager<T>::getIdentifier(name);321 else322 this->subclassIdentifier_ = 0;323 324 310 this->identifier_ = identifier; 325 311 } … … 332 318 SubclassIdentifier<T>& operator=(Identifier* identifier) 333 319 { 334 if (!identifier->isA( this->subclassIdentifier_))320 if (!identifier->isA(ClassManager<T>::getIdentifier())) 335 321 { 336 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl; 337 COUT(1) << "Error: SubclassIdentifier<" << this->subclassIdentifier_->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl; 322 COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl; 323 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl; 324 COUT(1) << "Error: SubclassIdentifier<" << ClassManager<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl; 338 325 COUT(1) << "Aborting..." << std::endl; 339 326 abort(); … … 380 367 if (this->identifier_) 381 368 { 382 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl; 369 COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl; 370 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl; 383 371 COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl; 384 372 COUT(1) << "Aborting..." << std::endl; … … 386 374 else 387 375 { 376 COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl; 388 377 COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl; 389 378 COUT(1) << "Aborting..." << std::endl; … … 416 405 private: 417 406 Identifier* identifier_; //!< The assigned identifier 418 Identifier* subclassIdentifier_; //!< The identifier of the subclass419 407 }; 420 408 } -
code/branches/core/src/orxonox/core/Language.cc
r790 r811 161 161 void Language::addEntry(const LanguageEntryName& name, const std::string& entry) 162 162 { 163 COUT(5) << " Called addEntry with\n name: " << name << "\n entry: " << entry << std::endl;163 COUT(5) << "Language: Called addEntry with\n name: " << name << "\n entry: " << entry << std::endl; 164 164 std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(name); 165 165 if (it == this->languageEntries_.end()) … … 197 197 { 198 198 // Uh, oh, an undefined entry was requested: return the default string 199 COUT(2) << " Error: Language entry \"" << name << "\" not found!" << std::endl;199 COUT(2) << "Warning: Language entry \"" << name << "\" not found!" << std::endl; 200 200 return this->defaultTranslation_; 201 201 } … … 230 230 if (!file.is_open()) 231 231 { 232 COUT(1) << "An error occurred in Language:" << std::endl; 232 233 COUT(1) << "Error: Couldn't open file " << getFileName(this->defaultLanguage_) << " to read the default language entries!" << std::endl; 233 234 return; … … 271 272 if (!file.is_open()) 272 273 { 274 COUT(1) << "An error occurred in Language:" << std::endl; 273 275 COUT(1) << "Error: Couldn't open file " << getFileName(this->language_) << " to read the translated language entries!" << std::endl; 274 276 ResetConfigValue(language_); … … 314 316 void Language::writeDefaultLanguageFile() const 315 317 { 316 COUT(4) << " Write default language file." << std::endl;318 COUT(4) << "Language: Write default language file." << std::endl; 317 319 318 320 // Open the file … … 322 324 if (!file.is_open()) 323 325 { 326 COUT(1) << "An error occurred in Language:" << std::endl; 324 327 COUT(1) << "Error: Couldn't open file " << getFileName(this->defaultLanguage_) << " to write the default language entries!" << std::endl; 325 328 return; -
code/branches/core/src/orxonox/core/MetaObjectList.h
r805 r811 99 99 100 100 101 COUT(4) << "*** Removing Object from " << this->element_->object_->getIdentifier()->getName() << "-list." << std::endl;101 COUT(4) << "*** MetaObjectList: Removing Object from " << this->element_->object_->getIdentifier()->getName() << "-list." << std::endl; 102 102 delete this->element_; 103 103 } -
code/branches/core/src/orxonox/objects/Test.h
r790 r811 74 74 public: 75 75 A1B2() { RegisterObject(A1B2); } 76 virtual void test() = 0; 76 77 }; 77 78 … … 116 117 public: 117 118 A1B2C1() { RegisterObject(A1B2C1); } 119 void test() { std::cout << "test!\n"; } 118 120 }; 119 121 … … 158 160 CreateFactory(A3); 159 161 CreateFactory(A1B1); 160 CreateFactory(A1B2);162 // CreateFactory(A1B2); 161 163 CreateFactory(A2B1); 162 164 CreateFactory(A2B2);
Note: See TracChangeset
for help on using the changeset viewer.