Changeset 879 for code/branches/core2/src/orxonox
- Timestamp:
- Mar 10, 2008, 5:07:48 PM (17 years ago)
- Location:
- code/branches/core2/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/BaseObject.h
r877 r879 79 79 const std::string& getLevelfile() const; 80 80 81 inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }81 virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; } 82 82 inline Namespace* getNamespace() const { return this->namespace_; } 83 83 -
code/branches/core2/src/orxonox/core/Namespace.cc
r878 r879 38 38 RegisterObject(Namespace); 39 39 40 this->representingNamespace_ = 0;40 this->representingNamespace_ = this; 41 41 } 42 42 … … 55 55 BaseObject::XMLPort(xmlelement, loading); 56 56 57 XMLPortObject(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, loading, true );57 XMLPortObject(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, loading, true, false); 58 58 } 59 59 60 60 void Namespace::loadObjects(BaseObject* object) 61 61 { 62 object->setNamespace(this); 62 object->setNamespace(this->representingNamespace_); 63 64 if (object->isA(Class(Namespace))) 65 this->addSubnamespace((Namespace*)object); 66 } 67 68 void Namespace::addSubnamespace(Namespace* ns) 69 { 70 std::string name = ns->getName().substr(ns->getName().find("::" 71 72 if (!this->hasSubnamespace(ns->getName())) 73 this->namespaces_[ns->getName()] = ns; 74 else 75 ns->representingNamespace_ = object; 76 } 77 78 bool Namespace::hasSubnamespace(const std::string& name) const 79 { 80 return (this->namespaces_.find(name) != this->namespaces_.end()); 63 81 } 64 82 -
code/branches/core2/src/orxonox/core/Namespace.h
r878 r879 29 29 #define _Namespace_H__ 30 30 31 #include < list>31 #include <map> 32 32 33 33 #include "BaseObject.h" … … 49 49 const BaseObject* saveObjects(unsigned int index) const; 50 50 51 void addSubnamespace(Namespace* ns); 52 bool hasSubnamespace(const std::string& name) const; 53 51 54 private: 52 std:: list<Namespace*> namespaces_;55 std::map<std::string, Namespace*> namespaces_; 53 56 Namespace* representingNamespace_; 54 57 }; -
code/branches/core2/src/orxonox/core/XMLPort.h
r878 r879 59 59 xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading) 60 60 61 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, loading, bApplyLoaderMask ) \61 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, loading, bApplyLoaderMask, bLoadBefore) \ 62 62 orxonox::XMLPortClassObjectContainer<classname, objectclass>* xmlcontainer##loadfunction##savefunction = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \ 63 63 if (!xmlcontainer##loadfunction##savefunction) \ 64 64 { \ 65 xmlcontainer##loadfunction##savefunction = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(this->getIdentifier()->getName(), std::string(sectionname), &classname::loadfunction, &classname::savefunction, bApplyLoaderMask ); \65 xmlcontainer##loadfunction##savefunction = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(this->getIdentifier()->getName(), std::string(sectionname), &classname::loadfunction, &classname::savefunction, bApplyLoaderMask, bLoadBefore); \ 66 66 this->getIdentifier()->addXMLPortObjectContainer(sectionname, xmlcontainer##loadfunction##savefunction); \ 67 67 } \ … … 202 202 std::string sectionname_; 203 203 bool bApplyLoaderMask_; 204 bool bLoadBefore_; 204 205 205 206 private: … … 212 213 { 213 214 public: 214 XMLPortClassObjectContainer(const std::string classname, const std::string sectionname, void (T::*loadfunction)(O*), const O* (T::*savefunction)(unsigned int) const, bool bApplyLoaderMask )215 XMLPortClassObjectContainer(const std::string classname, const std::string sectionname, void (T::*loadfunction)(O*), const O* (T::*savefunction)(unsigned int) const, bool bApplyLoaderMask, bool bLoadBefore) 215 216 { 216 217 this->classname_ = classname; … … 219 220 this->savefunction_ = savefunction; 220 221 this->bApplyLoaderMask_ = bApplyLoaderMask; 222 this->bLoadBefore_ = bLoadBefore; 221 223 } 222 224 … … 248 250 newObject->setLoaderIndentation(object->getLoaderIndentation() + " "); 249 251 newObject->setLevel(object->getLevel()); 250 newObject->XMLPort(*child, true); 252 newObject->setNamespace(object->getNamespace()); 253 if (this->bLoadBefore_) 254 newObject->XMLPort(*child, true); 251 255 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_ << " (objectname " << object->getName() << ")" << std::endl; 252 256 (*object.*this->loadfunction_)(newObject); 257 if (!this->bLoadBefore_) 258 newObject->XMLPort(*child, true); 253 259 COUT(5) << " ...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 254 260 } -
code/branches/core2/src/orxonox/objects/WorldEntity.cc
r878 r879 182 182 XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, loading); 183 183 184 XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, loading, false );184 XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, loading, false, true); 185 185 } 186 186
Note: See TracChangeset
for help on using the changeset viewer.