Changeset 2010 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 25, 2008, 5:13:35 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.cc
r1993 r2010 36 36 #include "CoreIncludes.h" 37 37 #include "XMLPort.h" 38 #include " Level.h"38 #include "XMLFile.h" 39 39 #include "Template.h" 40 40 #include "util/String.h" … … 56 56 this->bVisible_ = true; 57 57 58 this-> level_ = 0;58 this->file_ = 0; 59 59 this->namespace_ = 0; 60 60 } … … 86 86 @return The levelfile 87 87 */ 88 const std::string& BaseObject::get Levelfile() const88 const std::string& BaseObject::getFilename() const 89 89 { 90 if (this-> level_)91 return this-> level_->getFile();90 if (this->file_) 91 return this->file_->getFilename(); 92 92 else 93 93 return blankString; -
code/branches/objecthierarchy/src/core/BaseObject.h
r1989 r2010 81 81 virtual void changedVisibility() {} 82 82 83 /** @brief Sets a pointer to the level that loaded this object. @param level The pointer to the level*/84 inline void set Level(const Level* level) { this->level_ = level; }85 /** @brief Returns a pointer to the level that loaded this object. @return The level*/86 inline const Level* getLevel() const { return this->level_; }87 const std::string& get Levelfile() const;83 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ 84 inline void setFile(const XMLFile* file) { this->file_ = file; } 85 /** @brief Returns a pointer to the XMLFile that loaded this object. @return The XMLFile */ 86 inline const XMLFile* getFile() const { return this->file_; } 87 const std::string& getFilename() const; 88 88 89 89 void addTemplate(const std::string& name); … … 111 111 112 112 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 113 const Level* level_; //!< The levelthat loaded this object113 const XMLFile* file_; //!< The XMLFile that loaded this object 114 114 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 115 115 Namespace* namespace_; -
code/branches/objecthierarchy/src/core/CorePrereqs.h
r2003 r2010 129 129 class Language; 130 130 class LanguageEntry; 131 class Level;132 131 class Loader; 133 132 class MetaObjectList; … … 153 152 class Template; 154 153 class Tickable; 154 class XMLFile; 155 155 template <class T, class O> 156 156 class XMLPortClassObjectContainer; -
code/branches/objecthierarchy/src/core/Loader.cc
r1959 r2010 28 28 29 29 #include "Loader.h" 30 #include " Level.h"30 #include "XMLFile.h" 31 31 #include "BaseObject.h" 32 32 #include "Identifier.h" … … 42 42 namespace orxonox 43 43 { 44 std::vector<std::pair<const Level*, ClassTreeMask> > Loader::levels_s;44 std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s; 45 45 ClassTreeMask Loader::currentMask_s; 46 46 47 bool Loader::open(const Level* level, const ClassTreeMask& mask)47 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask) 48 48 { 49 Loader::add( level, mask);50 return Loader::load( level, mask);49 Loader::add(file, mask); 50 return Loader::load(file, mask); 51 51 } 52 52 … … 54 54 { 55 55 Loader::unload(); 56 Loader:: levels_s.clear();56 Loader::files_s.clear(); 57 57 } 58 58 59 void Loader::close(const Level* level)59 void Loader::close(const XMLFile* file) 60 60 { 61 Loader::unload( level);62 Loader::remove( level);61 Loader::unload(file); 62 Loader::remove(file); 63 63 } 64 64 65 void Loader::add(const Level* level, const ClassTreeMask& mask)65 void Loader::add(const XMLFile* file, const ClassTreeMask& mask) 66 66 { 67 if (! level)67 if (!file) 68 68 return; 69 Loader:: levels_s.insert(Loader::levels_s.end(), std::pair<const Level*, ClassTreeMask>(level, mask));69 Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask)); 70 70 } 71 71 72 void Loader::remove(const Level* level)72 void Loader::remove(const XMLFile* file) 73 73 { 74 if (! level)74 if (!file) 75 75 return; 76 for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)76 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 77 77 { 78 if ((*it).first == level)78 if ((*it).first == file) 79 79 { 80 Loader:: levels_s.erase(it);80 Loader::files_s.erase(it); 81 81 break; 82 82 } … … 87 87 { 88 88 bool success = true; 89 for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)89 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 90 90 if (!Loader::load((*it).first, (*it).second * mask)) 91 91 success = false; … … 111 111 } 112 112 113 bool Loader::load(const Level* level, const ClassTreeMask& mask)113 bool Loader::load(const XMLFile* file, const ClassTreeMask& mask) 114 114 { 115 if (! level)115 if (!file) 116 116 return false; 117 117 118 Loader::currentMask_s = level->getMask() * mask;118 Loader::currentMask_s = file->getMask() * mask; 119 119 120 120 // let Lua work this out: 121 121 LuaBind* lua = LuaBind::getInstance(); 122 122 lua->clearLuaOutput(); 123 lua->loadFile( level->getFile(), true);123 lua->loadFile(file->getFilename(), true); 124 124 lua->run(); 125 125 126 126 try 127 127 { 128 COUT(0) << "Start loading " << level->getFile() << "..." << std::endl;128 COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl; 129 129 COUT(3) << "Mask: " << Loader::currentMask_s << std::endl; 130 130 131 //ticpp::Document xmlfile( level->getFile());131 //ticpp::Document xmlfile(file->getFilename()); 132 132 //xmlfile.LoadFile(); 133 133 //ticpp::Element myelement(*Script::getFileString()); … … 146 146 Namespace* rootNamespace = new Namespace(); 147 147 rootNamespace->setLoaderIndentation(" "); 148 rootNamespace->set Level(level);148 rootNamespace->setFile(file); 149 149 rootNamespace->setNamespace(rootNamespace); 150 150 rootNamespace->setRoot(true); 151 151 rootNamespace->XMLPort(rootElement, XMLPort::LoadObject); 152 152 153 COUT(0) << "Finished loading " << level->getFile() << "." << std::endl;153 COUT(0) << "Finished loading " << file->getFilename() << "." << std::endl; 154 154 155 155 COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl; … … 160 160 { 161 161 COUT(1) << std::endl; 162 COUT(1) << "An error occurred in Loader.cc while loading " << level->getFile() << ":" << std::endl;162 COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 163 163 COUT(1) << ex.what() << std::endl; 164 164 COUT(1) << "Loading aborted." << std::endl; … … 167 167 } 168 168 169 void Loader::unload(const Level* level, const ClassTreeMask& mask)169 void Loader::unload(const XMLFile* file, const ClassTreeMask& mask) 170 170 { 171 if (! level)171 if (!file) 172 172 return; 173 173 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ) 174 174 { 175 if ((it->get Level() == level) && mask.isIncluded(it->getIdentifier()))175 if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier())) 176 176 delete (*(it++)); 177 177 else … … 180 180 } 181 181 182 bool Loader::reload(const Level* level, const ClassTreeMask& mask)182 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask) 183 183 { 184 Loader::unload( level, mask);185 return Loader::load( level, mask);184 Loader::unload(file, mask); 185 return Loader::load(file, mask); 186 186 } 187 187 } -
code/branches/objecthierarchy/src/core/Loader.h
r1505 r2010 35 35 36 36 #include "ClassTreeMask.h" 37 #include "Level.h"38 37 39 38 namespace orxonox … … 42 41 { 43 42 public: 44 static bool open(const Level* level, const ClassTreeMask& mask = ClassTreeMask());43 static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 45 44 static void close(); 46 static void close(const Level* level);45 static void close(const XMLFile* file); 47 46 48 static void add(const Level* level, const ClassTreeMask& mask = ClassTreeMask());49 static void remove(const Level* level);47 static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 48 static void remove(const XMLFile* file); 50 49 51 50 static bool load(const ClassTreeMask& mask = ClassTreeMask()); … … 53 52 static bool reload(const ClassTreeMask& mask = ClassTreeMask()); 54 53 55 static bool load(const Level* level, const ClassTreeMask& mask = ClassTreeMask());56 static void unload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());57 static bool reload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());54 static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 55 static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 56 static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 58 57 59 58 static ClassTreeMask currentMask_s; 60 59 61 60 private: 62 static std::vector<std::pair<const Level*, ClassTreeMask> > levels_s;61 static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s; 63 62 }; 64 63 } -
code/branches/objecthierarchy/src/core/XMLFile.h
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/code/branches/ceguilua/src/core/Level.h merged eligible /code/branches/core3/src/core/Level.h merged eligible /code/branches/gui/src/core/Level.h merged eligible /code/branches/script_trigger/src/core/Level.h merged eligible /code/branches/gcc43/src/core/Level.h 1580 /code/branches/input/src/core/Level.h 1629-1636
r2009 r2010 27 27 */ 28 28 29 #ifndef _ Level_H__30 #define _ Level_H__29 #ifndef _XMLFile_H__ 30 #define _XMLFile_H__ 31 31 32 32 #include "CorePrereqs.h" … … 38 38 namespace orxonox 39 39 { 40 class _CoreExport Level40 class _CoreExport XMLFile 41 41 { 42 42 public: 43 Level(const std::string& file) : file_(file) {}44 Level(const std::string& file, const ClassTreeMask& mask) : file_(file), mask_(mask) {};43 XMLFile(const std::string& filename) : filename_(filename) {} 44 XMLFile(const std::string& filename, const ClassTreeMask& mask) : filename_(filename), mask_(mask) {}; 45 45 46 const std::string& getFile () const { return this->file_; }46 const std::string& getFilename() const { return this->filename_; } 47 47 const ClassTreeMask& getMask() const { return this->mask_; } 48 48 49 49 private: 50 std::string file _;50 std::string filename_; 51 51 ClassTreeMask mask_; 52 52 }; 53 53 } 54 54 55 #endif /* _ Level_H__ */55 #endif /* _XMLFile_H__ */ -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
code/branches/objecthierarchy/src/core/XMLPort.h
r1989 r2010 336 336 { 337 337 COUT(1) << std::endl; 338 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->get Levelfile() << ":" << std::endl;338 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ":" << std::endl; 339 339 COUT(1) << ex.what() << std::endl; 340 340 } … … 481 481 BaseObject* newObject = identifier->fabricate(); 482 482 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 483 newObject->set Level(((BaseObject*)object)->getLevel());483 newObject->setFile(((BaseObject*)object)->getFile()); 484 484 newObject->setNamespace(((BaseObject*)object)->getNamespace()); 485 485 … … 523 523 { 524 524 COUT(1) << std::endl; 525 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->get Levelfile() << ":" << std::endl;525 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getFilename() << ":" << std::endl; 526 526 COUT(1) << ex.what() << std::endl; 527 527 }
Note: See TracChangeset
for help on using the changeset viewer.