Changeset 10624 for code/trunk/src/libraries/core/Loader.cc
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (10 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/libraries/core/Loader.cc
r10278 r10624 48 48 namespace orxonox 49 49 { 50 std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s; 51 ClassTreeMask Loader::currentMask_s; 52 53 bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose) 54 { 55 Loader::add(file, mask); 56 return Loader::load(file, mask, bVerbose); 57 } 58 59 void Loader::close() 60 { 61 Loader::unload(); 62 Loader::files_s.clear(); 63 } 64 65 void Loader::close(const XMLFile* file) 66 { 67 Loader::unload(file); 68 Loader::remove(file); 69 } 70 71 void Loader::add(const XMLFile* file, const ClassTreeMask& mask) 72 { 73 if (!file) 74 return; 75 Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask)); 76 } 77 78 void Loader::remove(const XMLFile* file) 79 { 80 if (!file) 81 return; 82 for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it) 83 { 84 if (it->first == file) 85 { 86 Loader::files_s.erase(it); 87 break; 88 } 89 } 90 } 91 92 /** 93 @brief 94 Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask. 95 @param mask 96 A ClassTreeMask, which defines which types of classes are loaded and which aren't. 97 @param bVerbose 98 Whether the loader is verbose (prints its progress in a low output level) or not. 99 @return 100 Returns true if successful. 101 */ 102 bool Loader::load(const ClassTreeMask& mask, bool bVerbose) 103 { 104 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)) 107 success = false; 108 109 return success; 110 } 111 112 void Loader::unload(const ClassTreeMask& mask) 113 { 114 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ) 115 { 116 if (mask.isIncluded(it->getIdentifier())) 117 (it++)->destroy(); 118 else 119 ++it; 120 } 121 } 122 123 /** 124 @brief 125 Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask. 126 @param mask 127 A ClassTreeMask, which defines which types of classes are reloaded and which aren't. 128 @param bVerbose 129 Whether the loader is verbose (prints its progress in a low output level) or not. 130 @return 131 Returns true if successful. 132 */ 133 bool Loader::reload(const ClassTreeMask& mask, bool bVerbose) 134 { 135 Loader::unload(mask); 136 return Loader::load(mask, bVerbose); 137 } 50 Loader* Loader::singletonPtr_s = 0; 138 51 139 52 /** … … 156 69 return false; 157 70 158 Loader::currentMask_s= file->getMask() * mask;71 this->currentMask_ = file->getMask() * mask; 159 72 160 73 std::string xmlInput; … … 189 102 // start of the program. 190 103 // Assumption: the LevelInfo tag does not use Lua scripting 191 xmlInput = removeLuaTags(xmlInput);104 xmlInput = Loader::removeLuaTags(xmlInput); 192 105 } 193 106 } … … 198 111 { 199 112 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl; 200 orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s<< endl;113 orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl; 201 114 } 202 115 else 203 116 { 204 117 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl; 205 orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s<< endl;118 orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl; 206 119 } 207 120 … … 220 133 rootNamespace->setLoaderIndentation(" "); 221 134 rootNamespace->setFile(file); 222 rootNamespace->setNamespace(rootNamespace);223 135 rootNamespace->setRoot(true); 224 136 rootNamespace->XMLPort(rootElement, XMLPort::LoadObject); … … 303 215 ++it; 304 216 } 305 }306 307 /**308 @brief309 Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.310 @param file311 The file to be reloaded.312 @param mask313 A ClassTreeMask, which defines which types of classes are reloaded and which aren't.314 @param bVerbose315 Whether the loader is verbose (prints its progress in a low output level) or not.316 @return317 Returns true if successful.318 */319 bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)320 {321 Loader::unload(file, mask);322 return Loader::load(file, mask, bVerbose);323 217 } 324 218
Note: See TracChangeset
for help on using the changeset viewer.