Changeset 1036 for code/branches/core2
- Timestamp:
- Apr 13, 2008, 1:36:45 AM (17 years ago)
- Location:
- code/branches/core2/src/orxonox
- Files:
-
- 2 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/Orxonox.cc
r1030 r1036 79 79 #include "core/ClassTreeMask.h" 80 80 #include "objects/WorldEntity.h" 81 #include "core/DebugLevel.h"82 81 #include "core/BaseObject.h" 82 #include "core/CoreSettings.h" 83 83 #include "objects/Test.h" 84 84 #include "objects/test1.h" … … 1125 1125 1126 1126 ClassTreeMask test13_20; 1127 test13_20.exclude(Class( DebugLevel));1128 std::cout << std::endl; 1129 std::cout << "Mask with excluded DebugLevel:\n";1127 test13_20.exclude(Class(CoreSettings)); 1128 std::cout << std::endl; 1129 std::cout << "Mask with excluded CoreSettings:\n"; 1130 1130 TestClassTreeMask(test13_20); 1131 1131 -
code/branches/core2/src/orxonox/core/CMakeLists.txt
r1006 r1036 11 11 SignalHandler.cc 12 12 ArgReader.cc 13 DebugLevel.cc13 CoreSettings.cc 14 14 OutputHandler.cc 15 15 Language.cc -
code/branches/core2/src/orxonox/core/ConfigValueContainer.cc
r1031 r1036 35 35 #include "ConfigValueContainer.h" 36 36 #include "Language.h" 37 #include "Identifier.h" 37 38 #include "util/SubString.h" 38 39 #include "util/Convert.h" -
code/branches/core2/src/orxonox/core/CorePrereqs.h
r993 r1036 100 100 class ConfigFileSection; 101 101 class ConfigValueContainer; 102 class DebugLevel;102 class CoreSettings; 103 103 class Error; 104 104 class Executor; -
code/branches/core2/src/orxonox/core/Identifier.h
r957 r1036 113 113 virtual void updateConfigValues() const = 0; 114 114 115 /** @brief Removes all objects of the corresponding class. */116 virtual void removeObjects() const = 0;117 118 115 /** @brief Returns the name of the class the Identifier belongs to. @return The name */ 119 116 inline const std::string& getName() const { return this->name_; } … … 306 303 ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass); 307 304 void addObject(T* object); 308 void removeObjects() const;309 305 void setName(const std::string& name); 310 306 /** @brief Returns the list of all existing objects of this class. @return The list */ … … 394 390 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 395 391 object->getMetaList().add(this->objects_, this->objects_->add(object)); 396 }397 398 /**399 @brief Removes all objects of the corresponding class.400 */401 template <class T>402 void ClassIdentifier<T>::removeObjects() const403 {404 for (Iterator<T> it = this->objects_->start(); it;)405 delete *(it++);406 392 } 407 393 -
code/branches/core2/src/orxonox/core/Language.cc
r1031 r1036 28 28 /** 29 29 @file Language.cc 30 @brief Implementation of the Language and the LanguageEntry class .30 @brief Implementation of the Language and the LanguageEntry classes. 31 31 */ 32 32 33 33 #include <fstream> 34 34 35 #include "CoreIncludes.h"36 35 #include "Language.h" 37 #include "Co nfigValueIncludes.h"36 #include "CoreSettings.h" 38 37 39 38 namespace orxonox … … 48 47 LanguageEntry::LanguageEntry(const std::string& fallbackEntry) 49 48 { 50 RegisterRootObject(LanguageEntry);51 52 49 this->fallbackEntry_ = fallbackEntry; 53 50 this->localisedEntry_ = fallbackEntry; // Set the localisation to the fallback entry, for the case that no translation gets assigned … … 92 89 Language::Language() 93 90 { 94 RegisterRootObject(Language);95 96 91 this->defaultLanguage_ = "default"; 97 92 this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!"; … … 102 97 103 98 /** 104 @brief Function to collect the SetConfigValue-macro calls.105 */106 void Language::setConfigValues()107 {108 SetConfigValue(language_, this->defaultLanguage_).description("The language of the ingame text");109 110 // Read the translation file after the language was configured111 this->readTranslatedLanguageFile();112 }113 114 /**115 99 @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function. 116 100 @return The reference to the only existing instance … … 118 102 Language& Language::getLanguage() 119 103 { 120 // Use static variables to avoid conflicts while executing this code before main() 121 static Language theOnlyLanguageObject = Language(); 122 static bool bCreatingTheOnlyLanguageObject = true; 123 124 // This workaround is used to set a description of the own config value without creating an infinite recursion 125 if (bCreatingTheOnlyLanguageObject) 126 { 127 bCreatingTheOnlyLanguageObject = false; 128 theOnlyLanguageObject.setConfigValues(); 129 } 130 131 return theOnlyLanguageObject; 104 static Language instance = Language(); 105 return instance; 132 106 } 133 107 … … 267 241 void Language::readTranslatedLanguageFile() 268 242 { 269 COUT(4) << "Read translated language file (" << this->language_<< ")." << std::endl;243 COUT(4) << "Read translated language file (" << CoreSettings::getLanguage() << ")." << std::endl; 270 244 271 245 // Open the file 272 246 std::ifstream file; 273 file.open(getFileName( this->language_).c_str(), std::fstream::in);247 file.open(getFileName(CoreSettings::getLanguage()).c_str(), std::fstream::in); 274 248 275 249 if (!file.is_open()) 276 250 { 277 251 COUT(1) << "An error occurred in Language.cc:" << std::endl; 278 COUT(1) << "Error: Couldn't open file " << getFileName( this->language_) << " to read the translated language entries!" << std::endl;279 ResetConfigValue(language_);252 COUT(1) << "Error: Couldn't open file " << getFileName(CoreSettings::getLanguage()) << " to read the translated language entries!" << std::endl; 253 CoreSettings::resetLanguage(); 280 254 COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl; 281 255 return; … … 308 282 else 309 283 { 310 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName( this->language_) << std::endl;284 COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(CoreSettings::getLanguage()) << std::endl; 311 285 } 312 286 } … … 335 309 336 310 // Iterate through the list an write the lines into the file 337 for ( Iterator<LanguageEntry> it = ObjectList<LanguageEntry>::start(); it; ++it)338 { 339 file << it->getLabel() << "=" << it->getDefault() << std::endl;311 for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it) 312 { 313 file << (*it).second->getLabel() << "=" << (*it).second->getDefault() << std::endl; 340 314 } 341 315 -
code/branches/core2/src/orxonox/core/Language.h
r871 r1036 49 49 50 50 #include "CorePrereqs.h" 51 #include "OrxonoxClass.h"52 51 53 52 … … 65 64 // ############################### 66 65 //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 67 class _CoreExport LanguageEntry : public OrxonoxClass66 class _CoreExport LanguageEntry 68 67 { 69 68 public: … … 112 111 // ############################### 113 112 //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 114 class _CoreExport Language : public OrxonoxClass113 class _CoreExport Language 115 114 { 116 template <class T> 117 friend class ClassIdentifier; // forward declaration because of the private destructor 115 friend class CoreSettings; 118 116 119 117 public: 120 118 static Language& getLanguage(); 121 void setConfigValues();122 119 void addEntry(const LanguageEntryLabel& label, const std::string& entry); 123 120 const std::string& getLocalisation(const LanguageEntryLabel& label) const; … … 134 131 LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry); 135 132 136 std::string language_; //!< The configured language137 133 std::string defaultLanguage_; //!< The default language 138 134 std::string defaultLocalisation_; //!< The returned string, if an entry unavailable entry is requested -
code/branches/core2/src/orxonox/core/OutputHandler.cc
r1030 r1036 31 31 */ 32 32 33 #include " DebugLevel.h"33 #include "CoreSettings.h" 34 34 #include "OutputHandler.h" 35 35 #include "ConsoleCommand.h" … … 77 77 int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device) 78 78 { 79 return DebugLevel::getSoftDebugLevel(device);79 return CoreSettings::getSoftDebugLevel(device); 80 80 } 81 81
Note: See TracChangeset
for help on using the changeset viewer.