Changeset 805 for code/branches
- Timestamp:
- Feb 12, 2008, 4:24:14 PM (17 years ago)
- Location:
- code/branches/core/src/orxonox/core
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/core/CMakeLists.txt
r802 r805 14 14 Language.cc 15 15 ClassTreeMask.cc 16 IdentifierDistributor.cc 16 17 ) 17 18 -
code/branches/core/src/orxonox/core/ClassFactory.h
r790 r805 73 73 { 74 74 COUT(4) << "*** Create entry for " << name << " in Factory." << std::endl; 75 Class Identifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);76 Factory::add(name, Class Identifier<T>::getIdentifier());75 ClassManager<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 76 Factory::add(name, ClassManager<T>::getIdentifier(name)); 77 77 78 78 return true; -
code/branches/core/src/orxonox/core/ClassTreeMask.cc
r804 r805 156 156 ClassTreeMask::ClassTreeMask() 157 157 { 158 this->root_ = new ClassTreeMaskNode(Class Identifier<BaseObject>::getIdentifier(), true);158 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier("BaseObject"), true); 159 159 } 160 160 … … 227 227 { 228 228 delete this->root_; 229 this->root_ = new ClassTreeMaskNode(Class Identifier<BaseObject>::getIdentifier(), true);229 this->root_ = new ClassTreeMaskNode(ClassManager<BaseObject>::getIdentifier("BaseObject"), true); 230 230 } 231 231 … … 237 237 bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const 238 238 { 239 std::cout << "1_0: " << ClassIdentifier<BaseObject>::getIdentifier() << std::endl;240 239 std::cout << "1_1: " << subclass->getName() << " (" << subclass << ") / " << node->getClass()->getName() << " (" << node->getClass() << ")" << std::endl; 241 240 // Check if the searched subclass is of the same type as the class in the current node or a derivative -
code/branches/core/src/orxonox/core/CoreIncludes.h
r792 r805 44 44 // All needed header-files 45 45 #include "Identifier.h" 46 #include "ClassManager.h" 46 47 #include "Factory.h" 47 48 #include "ClassFactory.h" … … 57 58 */ 58 59 #define InternRegisterObject(ClassName, bRootClass) \ 59 this->setIdentifier(orxonox::Class Identifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \60 this->setIdentifier(orxonox::ClassManager<ClassName>::getIdentifier(#ClassName)->registerClass(this->getParents(), #ClassName, bRootClass)); \ 60 61 if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \ 61 62 this->getParents()->add(this->getIdentifier()); \ 62 orxonox::Class Identifier<ClassName>::addObject(this)63 orxonox::ClassManager<ClassName>::getIdentifier(#ClassName)->addObject(this) 63 64 64 65 /** … … 111 112 */ 112 113 #define Class(ClassName) \ 113 Class Identifier<ClassName>::getIdentifier()114 ClassManager<ClassName>::getIdentifier(#ClassName) 114 115 115 116 /** -
code/branches/core/src/orxonox/core/CorePrereqs.h
r801 r805 70 70 template <class T> 71 71 class ClassIdentifier; 72 template <class T> 73 class ClassManager; 72 74 class ConfigValueContainer; 73 75 class DebugLevel; … … 75 77 class Factory; 76 78 class Identifier; 79 class IdentifierDistributor; 77 80 class IdentifierList; 78 81 class IdentifierListElement; -
code/branches/core/src/orxonox/core/Identifier.cc
r790 r805 118 118 /** 119 119 @returns a reference to the Identifier map, containing all Identifiers. 120 */ 120 *//* 121 121 std::map<std::string, Identifier*>& Identifier::getIdentifierMap() 122 122 { 123 123 static std::map<std::string, Identifier*> identifierMapStaticReference = std::map<std::string, Identifier*>(); 124 124 return identifierMapStaticReference; 125 } 125 }*/ 126 126 127 127 /** -
code/branches/core/src/orxonox/core/Identifier.h
r790 r805 89 89 { 90 90 template <class T> 91 friend class ClassIdentifier; // Forward declaration91 friend class ClassIdentifier; 92 92 93 93 template <class T> 94 friend class SubclassIdentifier; // Forward declaration95 96 friend class Factory; // Forward declaration94 friend class SubclassIdentifier; 95 96 friend class Factory; 97 97 98 98 public: … … 106 106 bool isParentOf(const Identifier* identifier) const; 107 107 108 static std::map<std::string, Identifier*>& getIdentifierMap();108 // static std::map<std::string, Identifier*>& getIdentifierMap(); 109 109 110 110 /** @brief Removes all objects of the corresponding class. */ … … 186 186 class ClassIdentifier : public Identifier 187 187 { 188 template <class TT> 189 friend class ClassManager; 190 188 191 public: 189 staticClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass);190 staticvoid addObject(T* object);191 static ClassIdentifier<T>* getIdentifier();192 ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass); 193 void addObject(T* object); 194 // static ClassIdentifier<T>* getIdentifier(); 192 195 void removeObjects() const; 193 196 void setName(const std::string& name); … … 225 228 226 229 // Check if at least one object of the given type was created 227 if (! getIdentifier()->bCreatedOneObject_)230 if (!this->bCreatedOneObject_) 228 231 { 229 232 // If no: We have to store the informations and initialize the Identifier 230 getIdentifier()->setName(name);233 this->setName(name); 231 234 232 235 COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl; 233 236 if (bRootClass) 234 getIdentifier()->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.237 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. 235 238 else 236 getIdentifier()->initialize(parents);239 this->initialize(parents); 237 240 } 238 241 239 return getIdentifier();242 return this; 240 243 } 241 244 … … 243 246 @brief Creates the only instance of this class for the template class T. 244 247 @return The Identifier itself 245 */ 248 *//* 246 249 template <class T> 247 250 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() … … 258 261 return &theOneAndOnlyInstance; 259 262 } 260 263 */ 261 264 /** 262 265 @brief Sets the name of the class. … … 266 269 void ClassIdentifier<T>::setName(const std::string& name) 267 270 { 268 // Make sure we didn't already set the name, to avoid duplicate entries in the Identifier map271 // // Make sure we didn't already set the name, to avoid duplicate entries in the Identifier map 269 272 if (!this->bSetName_) 270 273 { 271 274 this->name_ = name; 272 this->getIdentifierMap().insert(std::pair<std::string, Identifier*>(name, this));275 // this->getIdentifierMap().insert(std::pair<std::string, Identifier*>(name, this)); 273 276 this->bSetName_ = true; 274 277 } … … 282 285 void ClassIdentifier<T>::addObject(T* object) 283 286 { 284 COUT(4) << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;285 object->getMetaList().add( ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));287 COUT(4) << "*** Added object to " << this->getName() << "-list." << std::endl; 288 object->getMetaList().add(this->objects_, this->objects_->add(object)); 286 289 } 287 290 … … 314 317 SubclassIdentifier() 315 318 { 316 this->identifier_ = ClassIdentifier<T>::getIdentifier(); 319 T* temp = new T; 320 this->subclassIdentifier_ = temp->getIdentifier(); 321 delete temp; 322 323 this->identifier_ = this->subclassIdentifier_; 317 324 } 318 325 … … 324 331 SubclassIdentifier<T>& operator=(Identifier* identifier) 325 332 { 326 if (!identifier->isA( ClassIdentifier<T>::getIdentifier()))333 if (!identifier->isA(this->subclassIdentifier_)) 327 334 { 328 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;329 COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;335 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl; 336 COUT(1) << "Error: SubclassIdentifier<" << this->subclassIdentifier_->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl; 330 337 COUT(1) << "Aborting..." << std::endl; 331 338 abort(); … … 372 379 if (this->identifier_) 373 380 { 374 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;381 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl; 375 382 COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl; 376 383 COUT(1) << "Aborting..." << std::endl; … … 407 414 408 415 private: 409 Identifier* identifier_; //!< The assigned identifier 416 Identifier* identifier_; //!< The assigned identifier 417 Identifier* subclassIdentifier_; //!< The identifier of the subclass 410 418 }; 411 419 } -
code/branches/core/src/orxonox/core/Iterator.h
r790 r805 150 150 @return True if the iterator points to an existing object. 151 151 */ 152 bool operator!=( intcompare)152 bool operator!=(ObjectListElement<T>* compare) 153 153 { 154 // Comparing with anything except zero makes no sense 155 if (compare != 0) 156 COUT(2) << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works." << std::endl; 157 158 return (this->element_ != 0); 154 return (this->element_ != compare); 159 155 } 160 156 -
code/branches/core/src/orxonox/core/MetaObjectList.h
r790 r805 99 99 100 100 101 COUT(4) << "*** Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;101 COUT(4) << "*** Removing Object from " << this->element_->object_->getIdentifier()->getName() << "-list." << std::endl; 102 102 delete this->element_; 103 103 }
Note: See TracChangeset
for help on using the changeset viewer.