Changeset 2019 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 27, 2008, 4:08:51 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.cc
r2010 r2019 47 47 @brief Constructor: Registers the object in the BaseObject-list. 48 48 */ 49 BaseObject::BaseObject( ) : bInitialized_(false)49 BaseObject::BaseObject(BaseObject* creator) : bInitialized_(false) 50 50 { 51 51 RegisterRootObject(BaseObject); … … 55 55 this->bActive_ = true; 56 56 this->bVisible_ = true; 57 this->oldGametype_ = 0; 57 58 58 this->file_ = 0; 59 this->namespace_ = 0; 59 this->setCreator(creator); 60 if (this->creator_) 61 { 62 this->setFile(this->creator_->getFile()); 63 this->setNamespace(this->creator_->getNamespace()); 64 this->setScene(this->creator_->getScene()); 65 this->setGametype(this->creator_->getGametype()); 66 } 67 else 68 { 69 this->file_ = 0; 70 this->namespace_ = 0; 71 this->scene_ = 0; 72 this->gametype_ = 0; 73 } 60 74 } 61 75 … … 79 93 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 80 94 81 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, const std::string&);95 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*); 82 96 } 83 97 … … 91 105 return this->file_->getFilename(); 92 106 else 93 return blankString;107 return BLANKSTRING; 94 108 } 95 109 -
code/branches/objecthierarchy/src/core/BaseObject.h
r2010 r2019 45 45 namespace orxonox 46 46 { 47 class Scene; 48 class Gametype; 49 47 50 //! The BaseObject is the parent of all classes representing an instance in the game. 48 51 class _CoreExport BaseObject : virtual public OrxonoxClass … … 51 54 52 55 public: 53 BaseObject( );56 BaseObject(BaseObject* creator); 54 57 virtual ~BaseObject(); 55 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 96 99 inline Namespace* getNamespace() const { return this->namespace_; } 97 100 101 inline void setCreator(BaseObject* creator) { this->creator_ = creator; } 102 inline BaseObject* getCreator() const { return this->creator_; } 103 104 inline void setScene(Scene* scene) { this->scene_ = scene; } 105 inline Scene* getScene() const { return this->scene_; } 106 107 inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); } 108 inline Gametype* getGametype() const { return this->gametype_; } 109 inline Gametype* getOldGametype() const { return this->oldGametype_; } 110 virtual inline void changedGametype() {} 111 98 112 /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */ 99 113 inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; } … … 110 124 Template* getTemplate(unsigned int index) const; 111 125 112 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 113 const XMLFile* file_; //!< The XMLFile that loaded this object 114 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 115 Namespace* namespace_; 126 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 127 const XMLFile* file_; //!< The XMLFile that loaded this object 128 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 129 Namespace* namespace_; 130 BaseObject* creator_; 131 Scene* scene_; 132 Gametype* gametype_; 133 Gametype* oldGametype_; 116 134 std::set<Template*> templates_; 117 135 }; -
code/branches/objecthierarchy/src/core/ClassFactory.h
r1940 r2019 56 56 public: 57 57 static bool create(const std::string& name, bool bLoadable = true); 58 BaseObject* fabricate( );58 BaseObject* fabricate(BaseObject* creator); 59 59 60 60 private: … … 63 63 virtual ~ClassFactory() {} // Don't delete 64 64 65 static T* createNewObject( );65 static T* createNewObject(BaseObject* creator); 66 66 }; 67 67 … … 88 88 */ 89 89 template <class T> 90 BaseObject* ClassFactory<T>::fabricate( )90 BaseObject* ClassFactory<T>::fabricate(BaseObject* creator) 91 91 { 92 return ClassFactory<T>::createNewObject( );92 return ClassFactory<T>::createNewObject(creator); 93 93 } 94 94 … … 98 98 */ 99 99 template <class T> 100 T* ClassFactory<T>::createNewObject( )100 T* ClassFactory<T>::createNewObject(BaseObject* creator) 101 101 { 102 return new T ;102 return new T(creator); 103 103 } 104 104 } -
code/branches/objecthierarchy/src/core/Factory.cc
r1940 r2019 104 104 { 105 105 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 106 BaseObject* temp = (*it).second->fabricate( );106 BaseObject* temp = (*it).second->fabricate(0); 107 107 delete temp; 108 108 } -
code/branches/objecthierarchy/src/core/Factory.h
r1856 r2019 93 93 { 94 94 public: 95 virtual BaseObject* fabricate( ) = 0;95 virtual BaseObject* fabricate(BaseObject* creator) = 0; 96 96 virtual ~BaseFactory() {}; 97 97 }; -
code/branches/objecthierarchy/src/core/Functor.h
r1889 r2019 106 106 inline const MultiType& getReturnvalue() const { return this->returnedValue_; } 107 107 108 const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : blankString; }108 const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; } 109 109 const std::string& getTypenameReturnvalue() const { return this->typeReturnvalue_; } 110 110 -
code/branches/objecthierarchy/src/core/Identifier.cc
r1940 r2019 214 214 @return The new object 215 215 */ 216 BaseObject* Identifier::fabricate( )216 BaseObject* Identifier::fabricate(BaseObject* creator) 217 217 { 218 218 if (this->factory_) 219 219 { 220 return this->factory_->fabricate( ); // We have to return a BaseObject, because we don't know the exact type.220 return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type. 221 221 } 222 222 else -
code/branches/objecthierarchy/src/core/Identifier.h
r1952 r2019 100 100 inline void addFactory(BaseFactory* factory) { this->factory_ = factory; } 101 101 102 BaseObject* fabricate( );102 BaseObject* fabricate(BaseObject* creator); 103 103 bool isA(const Identifier* identifier) const; 104 104 bool isExactlyA(const Identifier* identifier) const; … … 502 502 @brief Overloading of the * operator: returns the assigned identifier. 503 503 */ 504 inline Identifier* operator*() 504 inline Identifier* operator*() const 505 505 { 506 506 return this->identifier_; … … 527 527 @return The new object 528 528 */ 529 T* fabricate( )530 { 531 BaseObject* newObject = this->identifier_->fabricate( );529 T* fabricate(BaseObject* creator) const 530 { 531 BaseObject* newObject = this->identifier_->fabricate(creator); 532 532 533 533 // Check if the creation was successful -
code/branches/objecthierarchy/src/core/Loader.cc
r2010 r2019 144 144 145 145 COUT(4) << " creating root-namespace..." << std::endl; 146 Namespace* rootNamespace = new Namespace( );146 Namespace* rootNamespace = new Namespace(0); 147 147 rootNamespace->setLoaderIndentation(" "); 148 148 rootNamespace->setFile(file); -
code/branches/objecthierarchy/src/core/Namespace.cc
r1889 r2019 37 37 CreateFactory(Namespace); 38 38 39 Namespace::Namespace( ) :39 Namespace::Namespace(BaseObject* creator) : BaseObject(creator), 40 40 bAutogeneratedFileRootNamespace_(false), 41 41 bRoot_(false), -
code/branches/objecthierarchy/src/core/Namespace.h
r1841 r2019 42 42 { 43 43 public: 44 Namespace( );44 Namespace(BaseObject* creator); 45 45 virtual ~Namespace(); 46 46 -
code/branches/objecthierarchy/src/core/Template.cc
r2013 r2019 38 38 CreateFactory(Template); 39 39 40 Template::Template( ) :xmlelement_("")40 Template::Template(BaseObject* creator) : BaseObject(creator), xmlelement_("") 41 41 { 42 42 RegisterObject(Template); … … 59 59 XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode); 60 60 61 this->setXMLElement(*dynamic_cast<TiXmlElement*>(xmlelement.FirstChildElement(false)->GetTiXmlPointer())); 61 Element* element = xmlelement.FirstChildElement(false); 62 if (element) 63 { 64 TiXmlElement* tixmlelement = dynamic_cast<TiXmlElement*>(element->GetTiXmlPointer()); 65 if (tixmlelement) 66 this->setXMLElement(*tixmlelement); 67 } 62 68 } 63 69 -
code/branches/objecthierarchy/src/core/Template.h
r1993 r2019 42 42 { 43 43 public: 44 Template( );44 Template(BaseObject* creator); 45 45 virtual ~Template(); 46 46 -
code/branches/objecthierarchy/src/core/XMLPort.h
r2010 r2019 479 479 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 480 480 481 BaseObject* newObject = identifier->fabricate( );481 BaseObject* newObject = identifier->fabricate((BaseObject*)object); 482 482 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 483 newObject->setFile(((BaseObject*)object)->getFile());484 newObject->setNamespace(((BaseObject*)object)->getNamespace());483 // newObject->setFile(((BaseObject*)object)->getFile()); 484 // newObject->setNamespace(((BaseObject*)object)->getNamespace()); 485 485 486 486 if (this->bLoadBefore_) … … 515 515 else 516 516 { 517 COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl; 517 if (this->sectionname_ != "") 518 { 519 COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl; 520 } 521 else 522 { 523 // It's probably just another subsection 524 } 518 525 } 519 526 }
Note: See TracChangeset
for help on using the changeset viewer.