Changeset 10392 for code/branches/core7/src/libraries/core
- Timestamp:
- Apr 23, 2015, 10:44:57 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/Core.cc
r10362 r10392 70 70 #include "class/Identifier.h" 71 71 #include "Language.h" 72 #include "Loader.h" 72 73 #include "LuaState.h" 73 74 #include "command/ConsoleCommandManager.h" … … 102 103 , configFileManager_(NULL) 103 104 , languageInstance_(NULL) 105 , loaderInstance_(NULL) 104 106 , ioConsole_(NULL) 105 107 , tclBind_(NULL) … … 208 210 IdentifierManager::getInstance().createClassHierarchy(); 209 211 212 // Loader 213 this->loaderInstance_ = new Loader(); 214 210 215 // Load OGRE excluding the renderer and the render window 211 216 orxout(internal_info) << "creating GraphicsManager:" << endl; … … 253 258 safeObjectDelete(&tclBind_); 254 259 safeObjectDelete(&ioConsole_); 260 safeObjectDelete(&loaderInstance_); 255 261 safeObjectDelete(&languageInstance_); 256 262 safeObjectDelete(&configFileManager_); -
code/branches/core7/src/libraries/core/Core.h
r9667 r10392 125 125 ConfigFileManager* configFileManager_; 126 126 Language* languageInstance_; 127 Loader* loaderInstance_; 127 128 IOConsole* ioConsole_; 128 129 TclBind* tclBind_; -
code/branches/core7/src/libraries/core/CorePrereqs.h
r10346 r10392 165 165 class Language; 166 166 class Listable; 167 class Loader; 167 168 class LuaFunctor; 168 169 class LuaState; -
code/branches/core7/src/libraries/core/GraphicsManager.cc
r10380 r10392 117 117 resources_.reset(new XMLFile("DefaultResources.oxr")); 118 118 resources_->setLuaSupport(false); 119 Loader:: open(resources_.get(), ClassTreeMask(), false);119 Loader::getInstance().open(resources_.get(), ClassTreeMask(), false); 120 120 121 121 // Only for runs in the build directory (not installed) … … 125 125 extResources_.reset(new XMLFile("resources.oxr")); 126 126 extResources_->setLuaSupport(false); 127 Loader:: open(extResources_.get(), ClassTreeMask(), false);127 Loader::getInstance().open(extResources_.get(), ClassTreeMask(), false); 128 128 129 129 if (bLoadRenderer) … … 140 140 orxout(internal_status) << "destroying GraphicsManager..." << endl; 141 141 142 Loader:: unload(debugOverlay_.get());142 Loader::getInstance().unload(debugOverlay_.get()); 143 143 144 144 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_); … … 149 149 150 150 // Undeclare the resources 151 Loader:: unload(resources_.get());152 Loader:: unload(extResources_.get());151 Loader::getInstance().unload(resources_.get()); 152 Loader::getInstance().unload(extResources_.get()); 153 153 154 154 safeObjectDelete(&ogreRoot_); … … 330 330 orxout(internal_info) << "Loading Debug Overlay..." << endl; 331 331 debugOverlay_.reset(new XMLFile("debug.oxo")); 332 Loader:: open(debugOverlay_.get(), ClassTreeMask(), false);332 Loader::getInstance().open(debugOverlay_.get(), ClassTreeMask(), false); 333 333 } 334 334 -
code/branches/core7/src/libraries/core/Loader.cc
r10278 r10392 48 48 namespace orxonox 49 49 { 50 std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s; 51 ClassTreeMask Loader::currentMask_s; 50 Loader* Loader::singletonPtr_s = 0; 52 51 53 52 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 54 53 { 55 Loader::add(file, mask);56 return Loader::load(file, mask, bVerbose);54 this->add(file, mask); 55 return this->load(file, mask, bVerbose); 57 56 } 58 57 59 58 void Loader::close() 60 59 { 61 Loader::unload();62 Loader::files_s.clear();60 this->unload(); 61 this->files_.clear(); 63 62 } 64 63 65 64 void Loader::close(const XMLFile* file) 66 65 { 67 Loader::unload(file);68 Loader::remove(file);66 this->unload(file); 67 this->remove(file); 69 68 } 70 69 … … 73 72 if (!file) 74 73 return; 75 Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));74 this->files_.insert(this->files_.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask)); 76 75 } 77 76 … … 80 79 if (!file) 81 80 return; 82 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)81 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = this->files_.begin(); it != this->files_.end(); ++it) 83 82 { 84 83 if (it->first == file) 85 84 { 86 Loader::files_s.erase(it);85 this->files_.erase(it); 87 86 break; 88 87 } … … 103 102 { 104 103 bool success = true; 105 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)106 if (! Loader::load(it->first, it->second * mask, bVerbose))104 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = this->files_.begin(); it != this->files_.end(); ++it) 105 if (!this->load(it->first, it->second * mask, bVerbose)) 107 106 success = false; 108 107 … … 133 132 bool Loader::reload(const ClassTreeMask& mask, bool bVerbose) 134 133 { 135 Loader::unload(mask);136 return Loader::load(mask, bVerbose);134 this->unload(mask); 135 return this->load(mask, bVerbose); 137 136 } 138 137 … … 156 155 return false; 157 156 158 Loader::currentMask_s= file->getMask() * mask;157 this->currentMask_ = file->getMask() * mask; 159 158 160 159 std::string xmlInput; … … 189 188 // start of the program. 190 189 // Assumption: the LevelInfo tag does not use Lua scripting 191 xmlInput = removeLuaTags(xmlInput);190 xmlInput = Loader::removeLuaTags(xmlInput); 192 191 } 193 192 } … … 198 197 { 199 198 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl; 200 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s<< endl;199 orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl; 201 200 } 202 201 else 203 202 { 204 203 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl; 205 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s<< endl;204 orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl; 206 205 } 207 206 … … 319 318 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 320 319 { 321 Loader::unload(file, mask);322 return Loader::load(file, mask, bVerbose);320 this->unload(file, mask); 321 return this->load(file, mask, bVerbose); 323 322 } 324 323 -
code/branches/core7/src/libraries/core/Loader.h
r8858 r10392 44 44 #include <map> 45 45 #include <vector> 46 47 #include "util/Singleton.h" 46 48 #include "ClassTreeMask.h" 47 49 48 50 namespace orxonox 49 51 { 50 class _CoreExport Loader 52 class _CoreExport Loader : public Singleton<Loader> 51 53 { 54 friend class Singleton<Loader>; 55 52 56 public: 53 staticbool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);54 staticvoid close();55 staticvoid close(const XMLFile* file);57 bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 58 void close(); 59 void close(const XMLFile* file); 56 60 57 staticvoid add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());58 staticvoid remove(const XMLFile* file);61 void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 62 void remove(const XMLFile* file); 59 63 60 staticbool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);61 staticvoid unload(const ClassTreeMask& mask = ClassTreeMask());62 staticbool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);64 bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 65 void unload(const ClassTreeMask& mask = ClassTreeMask()); 66 bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 63 67 64 staticbool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),65 66 staticvoid unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());67 staticbool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);68 bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), 69 bool bVerbose = true, bool bRemoveLuaTags = false); 70 void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask()); 71 bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true); 68 72 69 73 static std::string replaceLuaTags(const std::string& text); 70 74 static std::string removeLuaTags(const std::string& text); 71 75 72 static ClassTreeMask currentMask_s;76 ClassTreeMask currentMask_; 73 77 74 78 private: 75 79 static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags); 76 80 77 static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s; 81 std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_; 82 83 static Loader* singletonPtr_s; 78 84 }; 79 85 } -
code/branches/core7/src/libraries/core/XMLPort.cc
r9667 r10392 40 40 bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier) 41 41 { 42 return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader:: currentMask_s.isIncluded(identifier));42 return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::getInstance().currentMask_.isIncluded(identifier)); 43 43 } 44 44
Note: See TracChangeset
for help on using the changeset viewer.