Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1036 for code/branches/core2


Ignore:
Timestamp:
Apr 13, 2008, 1:36:45 AM (17 years ago)
Author:
landauf
Message:

added CoreSettings, a class containing all settings of core classes (at the moment it's only debuglevel and language)

removed DebugLevel
removed OrxonoxClass inheritance of Language and LanguageEntry

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  
    7979#include "core/ClassTreeMask.h"
    8080#include "objects/WorldEntity.h"
    81 #include "core/DebugLevel.h"
    8281#include "core/BaseObject.h"
     82#include "core/CoreSettings.h"
    8383#include "objects/Test.h"
    8484#include "objects/test1.h"
     
    11251125
    11261126        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";
    11301130        TestClassTreeMask(test13_20);
    11311131
  • code/branches/core2/src/orxonox/core/CMakeLists.txt

    r1006 r1036  
    1111  SignalHandler.cc
    1212  ArgReader.cc
    13   DebugLevel.cc
     13  CoreSettings.cc
    1414  OutputHandler.cc
    1515  Language.cc
  • code/branches/core2/src/orxonox/core/ConfigValueContainer.cc

    r1031 r1036  
    3535#include "ConfigValueContainer.h"
    3636#include "Language.h"
     37#include "Identifier.h"
    3738#include "util/SubString.h"
    3839#include "util/Convert.h"
  • code/branches/core2/src/orxonox/core/CorePrereqs.h

    r993 r1036  
    100100  class ConfigFileSection;
    101101  class ConfigValueContainer;
    102   class DebugLevel;
     102  class CoreSettings;
    103103  class Error;
    104104  class Executor;
  • code/branches/core2/src/orxonox/core/Identifier.h

    r957 r1036  
    113113            virtual void updateConfigValues() const = 0;
    114114
    115             /** @brief Removes all objects of the corresponding class. */
    116             virtual void removeObjects() const = 0;
    117 
    118115            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
    119116            inline const std::string& getName() const { return this->name_; }
     
    306303            ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass);
    307304            void addObject(T* object);
    308             void removeObjects() const;
    309305            void setName(const std::string& name);
    310306            /** @brief Returns the list of all existing objects of this class. @return The list */
     
    394390        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    395391        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() const
    403     {
    404         for (Iterator<T> it = this->objects_->start(); it;)
    405             delete *(it++);
    406392    }
    407393
  • code/branches/core2/src/orxonox/core/Language.cc

    r1031 r1036  
    2828/**
    2929    @file Language.cc
    30     @brief Implementation of the Language and the LanguageEntry class.
     30    @brief Implementation of the Language and the LanguageEntry classes.
    3131*/
    3232
    3333#include <fstream>
    3434
    35 #include "CoreIncludes.h"
    3635#include "Language.h"
    37 #include "ConfigValueIncludes.h"
     36#include "CoreSettings.h"
    3837
    3938namespace orxonox
     
    4847    LanguageEntry::LanguageEntry(const std::string& fallbackEntry)
    4948    {
    50         RegisterRootObject(LanguageEntry);
    51 
    5249        this->fallbackEntry_ = fallbackEntry;
    5350        this->localisedEntry_ = fallbackEntry; // Set the localisation to the fallback entry, for the case that no translation gets assigned
     
    9289    Language::Language()
    9390    {
    94         RegisterRootObject(Language);
    95 
    9691        this->defaultLanguage_ = "default";
    9792        this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
     
    10297
    10398    /**
    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 configured
    111         this->readTranslatedLanguageFile();
    112     }
    113 
    114     /**
    11599        @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function.
    116100        @return The reference to the only existing instance
     
    118102    Language& Language::getLanguage()
    119103    {
    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;
    132106    }
    133107
     
    267241    void Language::readTranslatedLanguageFile()
    268242    {
    269         COUT(4) << "Read translated language file (" << this->language_ << ")." << std::endl;
     243        COUT(4) << "Read translated language file (" << CoreSettings::getLanguage() << ")." << std::endl;
    270244
    271245        // Open the file
    272246        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);
    274248
    275249        if (!file.is_open())
    276250        {
    277251            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();
    280254            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
    281255            return;
     
    308282                else
    309283                {
    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;
    311285                }
    312286            }
     
    335309
    336310        // 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;
    340314        }
    341315
  • code/branches/core2/src/orxonox/core/Language.h

    r871 r1036  
    4949
    5050#include "CorePrereqs.h"
    51 #include "OrxonoxClass.h"
    5251
    5352
     
    6564    // ###############################
    6665    //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file.
    67     class _CoreExport LanguageEntry : public OrxonoxClass
     66    class _CoreExport LanguageEntry
    6867    {
    6968        public:
     
    112111    // ###############################
    113112    //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map.
    114     class _CoreExport Language : public OrxonoxClass
     113    class _CoreExport Language
    115114    {
    116         template <class T>
    117         friend class ClassIdentifier; // forward declaration because of the private destructor
     115        friend class CoreSettings;
    118116
    119117        public:
    120118            static Language& getLanguage();
    121             void setConfigValues();
    122119            void addEntry(const LanguageEntryLabel& label, const std::string& entry);
    123120            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
     
    134131            LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
    135132
    136             std::string language_;                                  //!< The configured language
    137133            std::string defaultLanguage_;                           //!< The default language
    138134            std::string defaultLocalisation_;                       //!< The returned string, if an entry unavailable entry is requested
  • code/branches/core2/src/orxonox/core/OutputHandler.cc

    r1030 r1036  
    3131*/
    3232
    33 #include "DebugLevel.h"
     33#include "CoreSettings.h"
    3434#include "OutputHandler.h"
    3535#include "ConsoleCommand.h"
     
    7777    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
    7878    {
    79         return DebugLevel::getSoftDebugLevel(device);
     79        return CoreSettings::getSoftDebugLevel(device);
    8080    }
    8181
Note: See TracChangeset for help on using the changeset viewer.