Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1747 for code/trunk/src/core


Ignore:
Timestamp:
Sep 9, 2008, 4:25:52 AM (16 years ago)
Author:
landauf
Message:

merged core3 back to trunk

Location:
code/trunk
Files:
9 deleted
47 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/BaseObject.h

    r1625 r1747  
    3939#include "CorePrereqs.h"
    4040
     41#include "Super.h"
     42#include "OrxonoxClass.h"
    4143#include "util/XMLIncludes.h"
    42 #include "OrxonoxClass.h"
    4344
    4445namespace orxonox
     
    101102            Namespace* namespace_;
    102103    };
     104
     105    SUPER_FUNCTION(0, BaseObject, XMLPort, false);
     106    SUPER_FUNCTION(2, BaseObject, changedActivity, false);
     107    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
    103108}
    104109
  • code/trunk/src/core/CMakeLists.txt

    r1612 r1747  
    33  ConfigValueContainer.cc
    44  Core.cc
    5   Error.cc
    65  Language.cc
     6  ObjectListBase.cc
    77  OrxonoxClass.cc
    8   OutputBuffer.cc
    9   OutputHandler.cc
    108  Script.cc
    11   SignalHandler.cc
    129
    1310  # command
  • code/trunk/src/core/ClassFactory.h

    r1543 r1747  
    4343#include "Factory.h"
    4444#include "Identifier.h"
    45 #include "Debug.h"
     45#include "util/Debug.h"
    4646
    4747namespace orxonox
     
    7474    {
    7575        COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
    76         ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);
     76        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
    7777        Factory::add(name, ClassIdentifier<T>::getIdentifier());
    7878
  • code/trunk/src/core/ClassTreeMask.h

    r1505 r1747  
    7878namespace orxonox
    7979{
    80     // ###############################
    81     // ###    ClassTreeMaskNode    ###
    82     // ###############################
     80    // ###################################
     81    // ###      ClassTreeMaskNode      ###
     82    // ###################################
    8383    //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
    8484    /**
     
    116116
    117117
    118     // ###############################
    119     // ###  ClassTreeMaskIterator  ###
    120     // ###############################
     118    // ###################################
     119    // ###    ClassTreeMaskIterator    ###
     120    // ###################################
    121121    //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.
    122122    /**
     
    146146
    147147
    148     // ###############################
    149     // ###      ClassTreeMask      ###
    150     // ###############################
     148    // ###################################
     149    // ###        ClassTreeMask        ###
     150    // ###################################
    151151    //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
    152152    /**
     
    214214            ClassTreeMaskNode* root_;   //!< The root-node of the internal rule-tree, usually BaseObject
    215215    };
     216
     217
     218    // ###################################
     219    // ### ClassTreeMaskObjectIterator ###
     220    // ###################################
     221    //! ...
     222    /**
     223        ...
     224    */
     225    class _CoreExport ClassTreeMaskObjectIterator
     226    {
     227    };
    216228}
    217229
  • code/trunk/src/core/CommandEvaluation.cc

    r1563 r1747  
    3030#include "ConsoleCommand.h"
    3131#include "Identifier.h"
    32 #include "Debug.h"
     32#include "util/Debug.h"
    3333#include "util/String.h"
    3434
     
    218218    }
    219219
    220     void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiTypeMath param)
     220    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
    221221    {
    222222        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    224224    }
    225225
    226     MultiTypeMath CommandEvaluation::getEvaluatedParameter(unsigned int index) const
     226    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
    227227    {
    228228        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    240240    }
    241241
    242     MultiTypeMath CommandEvaluation::getReturnvalue() const
     242    MultiType CommandEvaluation::getReturnvalue() const
    243243    {
    244244        if (this->function_)
    245245            return this->function_->getReturnvalue();
    246246
    247         return MultiTypeMath();
     247        return MultiType();
    248248    }
    249249
     
    304304
    305305            if (command->defaultValueSet(i))
    306                 output += "=" + command->getDefaultValue(i).toString() + "]";
     306                output += "=" + command->getDefaultValue(i).getString() + "]";
    307307            else
    308308                output += "}";
  • code/trunk/src/core/CommandEvaluation.h

    r1505 r1747  
    3737#include "ArgumentCompletionListElement.h"
    3838#include "util/SubString.h"
    39 #include "util/MultiTypeMath.h"
     39#include "util/MultiType.h"
    4040
    4141namespace orxonox
     
    8181                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
    8282
    83             void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
    84             MultiTypeMath getEvaluatedParameter(unsigned int index) const;
     83            void setEvaluatedParameter(unsigned int index, MultiType param);
     84            MultiType getEvaluatedParameter(unsigned int index) const;
    8585
    8686            bool hasReturnvalue() const;
    87             MultiTypeMath getReturnvalue() const;
     87            MultiType getReturnvalue() const;
    8888
    8989        private:
     
    115115
    116116            bool bEvaluatedParams_;
    117             MultiTypeMath param_[5];
     117            MultiType param_[5];
    118118    };
    119119}
  • code/trunk/src/core/CommandExecutor.cc

    r1505 r1747  
    3131#include "util/String.h"
    3232#include "util/Convert.h"
     33#include "util/Debug.h"
    3334#include "Identifier.h"
    3435#include "Language.h"
    35 #include "Debug.h"
    3636#include "TclBind.h"
    3737
  • code/trunk/src/core/ConfigFileManager.cc

    r1543 r1747  
    3838namespace orxonox
    3939{
    40     SetConsoleCommandShortcutExtern(config).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
    41     SetConsoleCommandShortcutExtern(tconfig).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
     40    SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
     41    SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
    4242    SetConsoleCommandShortcutExtern(reloadConfig);
    4343    SetConsoleCommandShortcutExtern(cleanConfig);
    44     SetConsoleCommandShortcutExtern(loadSettings).setArgumentCompleter(0, autocompletion::files());
    45     SetConsoleCommandShortcutExtern(loadKeybindings).setArgumentCompleter(0, autocompletion::files());
     44    SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
     45    SetConsoleCommandShortcutExtern(loadKeybindings).argumentCompleter(0, autocompletion::files());
    4646
    4747    bool config(const std::string& classname, const std::string& varname, const std::string& value)
     
    7171    void reloadConfig()
    7272    {
    73         ConfigFileManager::getSingleton()->load();
     73        ConfigFileManager::getInstance()->load();
    7474    }
    7575
    7676    void cleanConfig()
    7777    {
    78         ConfigFileManager::getSingleton()->clean(false);
     78        ConfigFileManager::getInstance()->clean(false);
    7979    }
    8080
    8181    void loadSettings(const std::string& filename)
    8282    {
    83         ConfigFileManager::getSingleton()->setFile(CFT_Settings, filename, false);
     83        ConfigFileManager::getInstance()->setFile(CFT_Settings, filename, false);
    8484    }
    8585
    8686    void loadKeybindings(const std::string& filename)
    8787    {
    88         ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, filename);
     88        ConfigFileManager::getInstance()->setFile(CFT_Keybindings, filename);
    8989    }
    9090
     
    327327        file.close();
    328328
    329         COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
     329        COUT(0) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
    330330
    331331        // Save the file in case something changed (like stripped whitespaces)
     
    459459    }
    460460
    461     ConfigFileManager* ConfigFileManager::getSingleton()
     461    ConfigFileManager* ConfigFileManager::getInstance()
    462462    {
    463463        static ConfigFileManager instance;
  • code/trunk/src/core/ConfigFileManager.h

    r1505 r1747  
    258258    {
    259259        public:
    260             static ConfigFileManager* getSingleton();
     260            static ConfigFileManager* getInstance();
    261261
    262262            void setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting = true);
  • code/trunk/src/core/ConfigValueContainer.cc

    r1505 r1747  
    4747{
    4848    /**
    49         @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
    50         @param type The type of the corresponding config-file
    51         @param identifier The identifier of the class the variable belongs to
    52         @param varname The name of the variable
    53         @param defvalue The default-value
    54     */
    55     ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue)
     49        @brief Initializes the ConfigValueContainer with defaultvalues.
     50    */
     51    void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& varname)
    5652    {
    5753        this->type_ = type;
     
    5955        this->sectionname_ = identifier->getName();
    6056        this->varname_ = varname;
    61 
     57        this->callback_ = 0;
     58        this->bContainerIsNew_ = true;
     59        this->bDoInitialCallback_ = false;
     60        this->bAddedDescription_ = false;
     61    }
     62
     63    /**
     64        @brief Does some special initialization for single config-values.
     65    */
     66    void ConfigValueContainer::initValue(const MultiType& defvalue)
     67    {
    6268        this->value_ = defvalue;
    63         this->bAddedDescription_ = false;
    6469        this->bIsVector_ = false;
    6570
    66         this->defvalueString_ = defvalue.toString();
     71        this->defvalueString_ = this->value_.getString();
    6772        this->update();
    6873    }
    6974
    7075    /**
    71         @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
    72         @param type The type of the corresponding config-file
    73         @param identifier The identifier of the class the variable belongs to
    74         @param varname The name of the variable
    75         @param defvalue The default-value
    76     */
    77     ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue)
    78     {
    79         this->type_ = type;
    80         this->identifier_ = identifier;
    81         this->sectionname_ = identifier->getName();
    82         this->varname_ = varname;
    83 
    84         this->valueVector_ = defvalue;
    85         this->bAddedDescription_ = false;
     76        @brief Does some special initialization for vector config-values.
     77    */
     78    void ConfigValueContainer::initVector()
     79    {
    8680        this->bIsVector_ = true;
    8781
    88         if (defvalue.size() > 0)
    89         {
    90                 this->value_ = defvalue[0];
    91 
    92             for (unsigned int i = 0; i < defvalue.size(); i++)
    93             {
    94                 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string));
    95                 this->defvalueStringVector_.push_back(defvalue[i].toString());
    96             }
    97 
    98             this->update();
    99         }
     82        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
     83        {
     84            ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
     85            this->defvalueStringVector_.push_back(this->valueVector_[i]);
     86        }
     87
     88        this->update();
     89    }
     90
     91    /**
     92        @brief Destructor: Deletes the callback object if necessary.
     93    */
     94    ConfigValueContainer::~ConfigValueContainer()
     95    {
     96        if (this->callback_)
     97            delete this->callback_;
    10098    }
    10199
     
    105103        @return True if the new value was successfully assigned
    106104    */
    107     bool ConfigValueContainer::set(const MultiTypeMath& input)
    108     {
    109         if (this->bIsVector_)
    110         {
    111             return this->callFunctionWithIndex(&ConfigValueContainer::set, input.toString());
     105    bool ConfigValueContainer::set(const MultiType& input)
     106    {
     107        if (this->bIsVector_)
     108        {
     109            return this->callFunctionWithIndex(&ConfigValueContainer::set, input);
    112110        }
    113111        else
     
    115113            if (this->tset(input))
    116114            {
    117                 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, input.toString(), this->value_.isA(MT_string));
     115                ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
    118116                return true;
    119117            }
     
    128126        @return True if the new value was successfully assigned
    129127    */
    130     bool ConfigValueContainer::set(unsigned int index, const MultiTypeMath& input)
     128    bool ConfigValueContainer::set(unsigned int index, const MultiType& input)
    131129    {
    132130        if (this->bIsVector_)
     
    134132            if (this->tset(index, input))
    135133            {
    136                 ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, index, input.toString(), this->value_.isA(MT_string));
     134                ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
    137135                return true;
    138136            }
     
    150148        @return True if the new value was successfully assigned
    151149    */
    152     bool ConfigValueContainer::tset(const MultiTypeMath& input)
    153     {
    154         if (this->bIsVector_)
    155         {
    156             return this->callFunctionWithIndex(&ConfigValueContainer::tset, input.toString());
    157         }
    158         else
    159         {
    160             MultiTypeMath temp = this->value_;
    161             if (temp.assimilate(input))
    162             {
    163                 this->value_ = temp;
    164                 if (this->identifier_)
    165                     this->identifier_->updateConfigValues();
    166 
    167                 return true;
    168             }
    169         }
    170         return false;
     150    bool ConfigValueContainer::tset(const MultiType& input)
     151    {
     152        if (this->bIsVector_)
     153        {
     154            return this->callFunctionWithIndex(&ConfigValueContainer::tset, input);
     155            return false;
     156        }
     157        else
     158        {
     159            this->value_ = input;
     160
     161            if (this->identifier_)
     162                this->identifier_->updateConfigValues();
     163
     164            return true;
     165        }
    171166    }
    172167
     
    177172        @return True if the new value was successfully assigned
    178173    */
    179     bool ConfigValueContainer::tset(unsigned int index, const MultiTypeMath& input)
     174    bool ConfigValueContainer::tset(unsigned int index, const MultiType& input)
    180175    {
    181176        if (this->bIsVector_)
     
    191186                for (unsigned int i = this->valueVector_.size(); i <= index; i++)
    192187                {
    193                     this->valueVector_.push_back(MultiTypeMath());
     188                    this->valueVector_.push_back(MultiType());
    194189                }
    195190            }
    196191
    197             MultiTypeMath temp = this->value_;
    198             if (temp.assimilate(input))
    199             {
    200                 this->valueVector_[index] = temp;
    201 
    202                 if (this->identifier_)
    203                     this->identifier_->updateConfigValues();
    204 
    205                 return true;
    206             }
     192            this->valueVector_[index] = input;
     193
     194            if (this->identifier_)
     195                this->identifier_->updateConfigValues();
     196
     197            return true;
    207198        }
    208199        else
    209200        {
    210201            COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
    211         }
    212         return false;
     202            return false;
     203        }
    213204    }
    214205
     
    218209        @return True if the new entry was successfully added
    219210    */
    220     bool ConfigValueContainer::add(const MultiTypeMath& input)
     211    bool ConfigValueContainer::add(const MultiType& input)
    221212    {
    222213        if (this->bIsVector_)
     
    241232                this->valueVector_.erase(this->valueVector_.begin() + index);
    242233                for (unsigned int i = index; i < this->valueVector_.size(); i++)
    243                     ConfigFileManager::getSingleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string));
    244                 ConfigFileManager::getSingleton()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
     234                    ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
     235                ConfigFileManager::getInstance()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
    245236
    246237                return true;
     
    266257                if (!this->set(i, this->defvalueStringVector_[i]))
    267258                    success = false;
    268             ConfigFileManager::getSingleton()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
     259            ConfigFileManager::getInstance()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
    269260            return success;
    270261        }
     
    277268    {
    278269        if (!this->bIsVector_)
    279             this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isA(MT_string)));
     270            this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
    280271        else
    281272        {
    282273            this->valueVector_.clear();
    283             for (unsigned int i = 0; i < ConfigFileManager::getSingleton()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
     274            for (unsigned int i = 0; i < ConfigFileManager::getInstance()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
    284275            {
    285276                if (i < this->defvalueStringVector_.size())
    286277                {
    287                     this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isA(MT_string)));
     278                    this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
    288279                }
    289280                else
    290281                {
    291                     this->value_.fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiTypeMath(), this->value_.isA(MT_string)));
     282                    this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
    292283                }
    293284
     
    303294        @return The returnvalue of the functioncall
    304295    */
    305     bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input)
     296    bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
    306297    {
    307298        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
     
    335326        @param description The description
    336327    */
    337     void ConfigValueContainer::description(const std::string& description)
     328    ConfigValueContainer& ConfigValueContainer::description(const std::string& description)
    338329    {
    339330        if (!this->bAddedDescription_)
     
    343334            this->bAddedDescription_ = true;
    344335        }
     336        return (*this);
    345337    }
    346338
  • code/trunk/src/core/ConfigValueContainer.h

    r1505 r1747  
    5050
    5151#include "util/Math.h"
    52 #include "util/MultiTypeMath.h"
     52#include "util/MultiType.h"
    5353#include "ConfigFileManager.h"
    5454
    5555namespace orxonox
    5656{
     57    class ConfigValueCallbackBase
     58    {
     59        public:
     60            virtual void call(void* object) = 0;
     61            inline virtual ~ConfigValueCallbackBase() {}
     62    };
     63
     64    template <class T>
     65    class ConfigValueCallback: public ConfigValueCallbackBase
     66    {
     67        public:
     68            inline ConfigValueCallback(void (T::*function) (void)) : function_(function) {}
     69            inline virtual ~ConfigValueCallback() {}
     70            inline virtual void call(void* object)
     71                { (((T*)object)->*this->function_)(); }
     72
     73        private:
     74            void (T::*function_) (void);
     75    };
     76
     77
    5778    //! The ConfigValuecontainer contains all needed informations about a configurable variable.
    5879    /**
     
    7495    {
    7596        public:
    76             ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue);
    77             ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue);
    78 
    79             /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */
    80             template <typename T>
    81             inline ConfigValueContainer& getValue(T* value)
    82                 { this->value_.getValue(value); return *this; }
    83             template <typename T>
    84             inline ConfigValueContainer& getValue(std::vector<T>* value)
    85             {
    86                 value->clear();
    87                 for (unsigned int i = 0; i < this->valueVector_.size(); i++)
    88                     value->push_back(this->valueVector_[i]);
     97            /**
     98                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
     99                @param type The type of the corresponding config-file
     100                @param identifier The identifier of the class the variable belongs to
     101                @param varname The name of the variable
     102                @param defvalue The default-value
     103                @param value Only needed do determine the right type.
     104            */
     105            template <class D, class V>
     106            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const D& defvalue, const V& value)
     107            {
     108                this->init(type, identifier, varname);
     109                this->initValue((V)defvalue);
     110            }
     111
     112            /**
     113                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
     114                @param type The type of the corresponding config-file
     115                @param identifier The identifier of the class the variable belongs to
     116                @param varname The name of the variable
     117                @param defvalue The default-value
     118            */
     119            template <class V>
     120            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<V>& defvalue)
     121            {
     122                this->init(type, identifier, varname);
     123
     124                this->value_ = V();
     125                for (unsigned int i = 0; i < defvalue.size(); i++)
     126                    this->valueVector_.push_back(MultiType(defvalue[i]));
     127
     128                this->initVector();
     129            }
     130
     131            ~ConfigValueContainer();
     132
     133            /**
     134                @brief Returns the configured value.
     135                @param value A pointer to the variable to store the value.
     136                @param object The object calling this function
     137                @return The ConfigValueContainer
     138            */
     139            template <typename T, class C>
     140            ConfigValueContainer& getValue(T* value, C* object)
     141            {
     142                if ((this->callback_ && object) || this->bContainerIsNew_)
     143                {
     144                    if (this->bContainerIsNew_)
     145                        this->bContainerIsNew_ = false;
     146
     147                    T temp = *value;
     148                    this->value_.getValue(value);
     149                    if ((*value) != temp)
     150                    {
     151                        if (this->callback_ && object)
     152                            this->callback_->call(object);
     153                        else
     154                            this->bDoInitialCallback_ = true;
     155                    }
     156                }
     157                else
     158                {
     159                    this->value_.getValue(value);
     160                }
    89161                return *this;
    90162            }
    91163
    92             template <typename T>
    93             inline void setVectorType(const std::vector<T>& value)
    94             {
    95                 this->value_ = T();
    96                 this->update();
    97             }
    98 
     164            /**
     165                @brief Returns the configured vector.
     166                @param value A pointer to the vector to store the values.
     167                @param object The object calling this function
     168                @return The ConfigValueContainer
     169            */
     170            template <typename T, class C>
     171            ConfigValueContainer& getValue(std::vector<T>* value, C* object)
     172            {
     173                if ((this->callback_ && object) || this->bContainerIsNew_)
     174                {
     175                    if (this->bContainerIsNew_)
     176                        this->bContainerIsNew_ = false;
     177
     178                    std::vector<T> temp = *value;
     179                    value->clear();
     180                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
     181                        value->push_back(this->valueVector_[i]);
     182
     183                    if (value->size() != temp.size())
     184                    {
     185                        if (this->callback_ && object)
     186                            this->callback_->call(object);
     187                        else
     188                            this->bDoInitialCallback_ = true;
     189                    }
     190                    else
     191                    {
     192                        for (unsigned int i = 0; i < value->size(); ++i)
     193                        {
     194                            if ((*value)[i] != temp[i])
     195                            {
     196                                if (this->callback_ && object)
     197                                    this->callback_->call(object);
     198                                else
     199                                    this->bDoInitialCallback_ = true;
     200                                break;
     201                            }
     202                        }
     203                    }
     204                }
     205                else
     206                {
     207                    value->clear();
     208                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
     209                        value->push_back(this->valueVector_[i]);
     210                }
     211                return *this;
     212            }
     213
     214            /** @brief Returns the name of this container. */
    99215            inline const std::string& getName() const
    100216                { return this->varname_; }
     217            /** @brief Returns true if this config-value is a vector */
    101218            inline bool isVector() const
    102219                { return this->bIsVector_; }
     220            /** @brief Returns the vectors size (or zero if it's not a vector). */
    103221            inline unsigned int getVectorSize() const
    104222                { return this->valueVector_.size(); }
    105223
    106             void description(const std::string& description);
     224            ConfigValueContainer& description(const std::string& description);
    107225            const std::string& getDescription() const;
    108226
    109             bool set(const MultiTypeMath& input);
    110             bool tset(const MultiTypeMath& input);
    111 
    112             bool set(unsigned int index, const MultiTypeMath& input);
    113             bool tset(unsigned int index, const MultiTypeMath& input);
    114             bool add(const MultiTypeMath& input);
     227            /**
     228                @brief Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable.
     229                @param object The object to call the function
     230                @param function The callback function
     231            */
     232            template <class T>
     233            inline ConfigValueContainer& callback(T* object, void (T::*function) (void))
     234            {
     235                if (!this->callback_)
     236                {
     237                    this->callback_ = new ConfigValueCallback<T>(function);
     238
     239                    if (this->bDoInitialCallback_)
     240                    {
     241                        this->bDoInitialCallback_ = false;
     242                        this->callback_->call(object);
     243                    }
     244                }
     245
     246                return (*this);
     247            }
     248
     249            bool set(const MultiType& input);
     250            bool tset(const MultiType& input);
     251
     252            bool set(unsigned int index, const MultiType& input);
     253            bool tset(unsigned int index, const MultiType& input);
     254            bool add(const MultiType& input);
    115255            bool remove(unsigned int index);
    116256
     
    120260            /** @brief Converts the config-value to a string. @return The string */
    121261            inline std::string toString() const
    122                 { return this->value_.toString(); }
     262                { return this->value_; }
    123263            /** @brief Returns the typename of the assigned config-value. @return The typename */
    124264            inline std::string getTypename() const
     
    126266
    127267        private:
    128             bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input);
     268            void init(ConfigFileType type, Identifier* identifier, const std::string& varname);
     269            void initValue(const MultiType& defvalue);
     270            void initVector();
     271            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input);
    129272
    130273            bool                       bIsVector_;                  //!< True if the container contains a std::vector
     
    137280            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
    138281
    139             MultiTypeMath              value_;                      //!< The value
    140             std::vector<MultiTypeMath> valueVector_;                //!< A vector, containg the values in case we're storing a vector
     282            MultiType                  value_;                      //!< The value
     283            std::vector<MultiType>    valueVector_;                //!< A vector, containg the values in case we're storing a vector
    141284
    142285            bool                       bAddedDescription_;          //!< True if a description was added
    143286            LanguageEntryLabel         description_;                //!< The description
     287            ConfigValueCallbackBase*   callback_;                   //!< A callback function to call after getValue if the value changed
     288
     289            bool                       bContainerIsNew_;            //!< True if it's the first time getValue() gets called
     290            bool                       bDoInitialCallback_;         //!< True if the callback should be called as soon as it gets created
    144291    };
    145292}
  • code/trunk/src/core/ConfigValueIncludes.h

    r1543 r1747  
    4747    @param defvalue The default-value of the variable
    4848*/
    49 #define SetConfigValue(varname, defvalue) \
    50     orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
     49#define SetConfigValueGeneric(type, varname, defvalue) \
     50    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
     51    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
    5152    if (!container##varname) \
    5253    { \
    53         container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, varname = defvalue); \
    54         this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \
     54        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue, varname); \
     55        identifier##varname->addConfigValueContainer(#varname, container##varname); \
    5556    } \
    56     container##varname->getValue(&varname)
     57    container##varname->getValue(&varname, this)
    5758
    58 /**
    59     @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
    60     @param classname name in which the config value should be stored
    61     @param varname The name of the variable
    62     @param defvalue The default-value of the variable
    63 */
    64 #define SetConfigValueGeneric(classname, varname, defvalue) \
    65     orxonox::ConfigValueContainer* container##varname = ClassIdentifier<classname>::getIdentifier()->getConfigValueContainer(#varname); \
    66     if (!container##varname) \
    67     { \
    68         container##varname = new orxonox::ConfigValueContainer(CFT_Settings, ClassIdentifier<classname>::getIdentifier(), #varname, varname = defvalue); \
    69         ClassIdentifier<classname>::getIdentifier()->addConfigValueContainer(#varname, container##varname); \
    70     } \
    71     container##varname->getValue(&varname)
     59#define SetConfigValue(varname, defvalue) SetConfigValueGeneric(CFT_Settings, varname, defvalue)
     60#define SetKeybindingValue(varname, defvalue) SetConfigValueGeneric(CFT_Keybindings, varname, defvalue)
     61
    7262
    7363/**
     
    7666    @param defvalue The default-value
    7767*/
    78 #define SetConfigValueVector(varname, defvalue) \
    79     orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \
     68#define SetConfigValueVectorGeneric(type, varname, defvalue) \
     69    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
     70    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
    8071    if (!container##varname) \
    8172    { \
    82         std::vector<MultiTypeMath> temp; \
    83         for (unsigned int i = 0; i < defvalue.size(); i++) \
    84             temp.push_back(MultiTypeMath(defvalue[i])); \
    85         container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, temp); \
    86         container##varname->setVectorType(varname); \
    87         this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \
     73        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue); \
     74        identifier##varname->addConfigValueContainer(#varname, container##varname); \
    8875    } \
    89     container##varname->getValue(&varname)
     76    container##varname->getValue(&varname, this)
     77
     78#define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Settings, varname, defvalue)
     79#define SetKeybindingValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Keybindings, varname, defvalue)
     80
    9081
    9182/**
     
    9889    { \
    9990        container##varname##reset->reset(); \
    100         container##varname##reset->getValue(&varname); \
     91        container##varname##reset->getValue(&varname, this); \
    10192    } \
    10293    else \
     
    10495        COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
    10596    }
     97
    10698
    10799/**
     
    115107    { \
    116108        container##varname##modify##modifier->modifier(__VA_ARGS__); \
    117         container##varname##modify##modifier->getValue(&varname); \
     109        container##varname##modify##modifier->getValue(&varname, this); \
    118110    } \
    119111    else \
  • code/trunk/src/core/ConsoleCommand.cc

    r1505 r1747  
    4545    }
    4646
    47     ConsoleCommand& ConsoleCommand::setArgumentCompleter(unsigned int param, ArgumentCompleter* completer)
     47    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
    4848    {
    4949        if (param < 5)
  • code/trunk/src/core/ConsoleCommand.h

    r1549 r1747  
    3838
    3939
    40 #define SetConsoleCommand(classname, function,  bCreateShortcut) \
    41     SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut)
     40#define SetConsoleCommand(classname, function, bCreateShortcut) \
     41    SetConsoleCommandAliasMulti(classname, function, #function, 0, bCreateShortcut)
     42#define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \
     43    SetConsoleCommandAliasMulti(classname, function, name, 0, bCreateShortcut)
     44#define SetConsoleCommandAliasMulti(classname, function, name, number, bCreateShortcut) \
     45    SetConsoleCommandGeneric(classname##function##consolecommand__##number, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut)
    4246
    4347#define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \
    44     orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier()->addConsoleCommand(command, bCreateShortcut)
     48    orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier(#classname)->addConsoleCommand(command, bCreateShortcut)
    4549
    4650
    4751#define SetConsoleCommandShortcut(classname, function) \
    48     SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function))
     52    SetConsoleCommandShortcutAliasMulti(classname, function, #function, 0)
     53#define SetConsoleCommandShortcutAlias(classname, function, name) \
     54    SetConsoleCommandShortcutAliasMulti(classname, function, name, 0)
     55#define SetConsoleCommandShortcutAliasMulti(classname, function, name, number) \
     56    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name))
    4957
    5058#define SetConsoleCommandShortcutExtern(function) \
    51     SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function))
     59    SetConsoleCommandShortcutExternAliasMulti(function, #function, 0)
     60#define SetConsoleCommandShortcutExternAlias(function, name) \
     61    SetConsoleCommandShortcutExternAliasMulti(function, name, 0)
     62#define SetConsoleCommandShortcutExternAliasMulti(function, name, number) \
     63    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&function), name))
    5264
    5365#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
     
    7587            ConsoleCommand(FunctorStatic* functor, const std::string& name = "");
    7688
    77             inline ConsoleCommand& setDescription(const std::string& description)
     89            inline ConsoleCommand& description(const std::string& description)
    7890                { this->ExecutorStatic::setDescription(description); return (*this); }
    79             inline ConsoleCommand& setDescriptionParam(int param, const std::string& description)
     91            inline ConsoleCommand& descriptionParam(int param, const std::string& description)
    8092                { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); }
    81             inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description)
     93            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
    8294                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
    83             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1)
     95            inline ConsoleCommand& defaultValues(const MultiType& param1)
    8496                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
    85             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     97            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
    8698                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
    87             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     99            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    88100                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
    89             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     101            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    90102                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
    91             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     103            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    92104                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
    93             inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param)
     105            inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
    94106                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
    95107
    96             inline ConsoleCommand& setAccessLevel(AccessLevel::Level level)
     108            inline ConsoleCommand& accessLevel(AccessLevel::Level level)
    97109                { this->accessLevel_ = level; return (*this); }
    98110            inline AccessLevel::Level getAccessLevel() const
    99111                { return this->accessLevel_; }
    100112
    101             ConsoleCommand& setArgumentCompleter(unsigned int param, ArgumentCompleter* completer);
     113            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
    102114            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
    103115
     
    110122                { return this->argumentList_.end(); }
    111123
    112             inline ConsoleCommand& setKeybindMode(KeybindMode::Enum mode)
     124            inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
    113125                { this->keybindMode_ = mode; return *this; }
    114126            inline KeybindMode::Enum getKeybindMode() const
    115127                { return this->keybindMode_; }
    116128
    117             inline ConsoleCommand& setAxisParamIndex(int index)
     129            inline ConsoleCommand& axisParamIndex(int index)
    118130                { this->axisParamIndex_ = index; return *this; }
    119131            inline int getAxisParamIndex() const
    120132                { return this->axisParamIndex_; }
    121133
    122             inline ConsoleCommand& setIsAxisRelative(bool val)
     134            inline ConsoleCommand& isAxisRelative(bool val)
    123135                { this->bAxisRelative_ = val; return *this; }
    124136            inline int getIsAxisRelative() const
  • code/trunk/src/core/ConsoleCommandCompilation.cc

    r1505 r1747  
    2929#include "ConsoleCommandCompilation.h"
    3030#include "ConsoleCommand.h"
    31 #include "Debug.h"
     31#include "util/Debug.h"
    3232#include "util/ExprParser.h"
    3333
    3434namespace orxonox
    3535{
    36     SetConsoleCommandShortcutExtern(source).setArgumentCompleter(0, autocompletion::files());
     36    SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
    3737    SetConsoleCommandShortcutExtern(echo);
    3838    SetConsoleCommandShortcutExtern(puts);
    3939
    40     SetConsoleCommandShortcutExtern(read).setArgumentCompleter(0, autocompletion::files());
    41     SetConsoleCommandShortcutExtern(append).setArgumentCompleter(0, autocompletion::files());
    42     SetConsoleCommandShortcutExtern(write).setArgumentCompleter(0, autocompletion::files());
     40    SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
     41    SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
     42    SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
    4343
    4444    SetConsoleCommandShortcutExtern(calculate);
  • code/trunk/src/core/Core.cc

    r1535 r1747  
    9696    void Core::setConfigValues()
    9797    {
    98         SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console");
    99         SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile");
    100         SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell");
    101 
     98        SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
     99        SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
     100        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
     101        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
     102    }
     103
     104    /**
     105        @brief Callback function if the debug level has changed.
     106    */
     107    void Core::debugLevelChanged()
     108    {
    102109        // softDebugLevel_ is the maximum of the 3 variables
    103110        this->softDebugLevel_ = this->softDebugLevelConsole_;
     
    107114            this->softDebugLevel_ = this->softDebugLevelShell_;
    108115
    109 
    110         std::string temp = this->language_;
    111         SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text");
    112 
    113         if (this->language_ != temp)
    114         {
    115             // Read the translation file after the language was configured
    116             Language::getLanguage().readTranslatedLanguageFile();
    117         }
     116        OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
     117        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
     118        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
     119        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
     120    }
     121
     122    /**
     123        @brief Callback function if the language has changed.
     124    */
     125    void Core::languageChanged()
     126    {
     127        // Read the translation file after the language was configured
     128        Language::getLanguage().readTranslatedLanguageFile();
    118129    }
    119130
     
    158169            else if (device == OutputHandler::LD_Shell)
    159170                Core::getInstance().softDebugLevelShell_ = level;
     171
     172            OutputHandler::setSoftDebugLevel(device, level);
    160173        }
    161174     }
     
    199212    }
    200213}
    201 
    202 /**
    203     @brief Returns the soft debug level, stored in the only existing instance of the DebugLevel class, configured in the config-file.
    204     @return The soft debug level
    205 */
    206 int getSoftDebugLevel()
    207 {
    208     return orxonox::Core::getSoftDebugLevel();
    209 }
  • code/trunk/src/core/Core.h

    r1535 r1747  
    4141
    4242#include "OrxonoxClass.h"
    43 #include "OutputHandler.h"
     43#include "util/OutputHandler.h"
    4444
    4545namespace orxonox
     
    5252            static bool& isCreatingCoreSettings();
    5353            void setConfigValues();
     54            void debugLevelChanged();
     55            void languageChanged();
    5456
    5557            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
  • code/trunk/src/core/CoreIncludes.h

    r1543 r1747  
    4646#include "Factory.h"
    4747#include "ClassFactory.h"
    48 #include "Debug.h"
     48#include "util/Debug.h"
    4949
    5050
     
    5555*/
    5656#define InternRegisterObject(ClassName, bRootClass) \
    57     this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier()->registerClass(this->getParents(), #ClassName, bRootClass)); \
    58     if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \
    59         this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
    60     orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this); \
     57    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
    6158    if (orxonox::Identifier::isCreatingHierarchy()) \
    62       return
     59    { \
     60        if (this->getParents()) \
     61        { \
     62            orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
     63            this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
     64        } \
     65        this->setConfigValues(); \
     66        return; \
     67    } \
     68    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
    6369
    6470/**
  • code/trunk/src/core/CorePrereqs.h

    r1543 r1747  
    6262// Forward declarations
    6363//-----------------------------------------------------------------------
    64 class SignalHandler;
    65 
    6664namespace orxonox
    6765{
     
    111109  class ConsoleCommand;
    112110  class Core;
    113   class Error;
    114111  class Executor;
    115112  template <class T>
     
    125122  template <class T>
    126123  class Iterator;
     124  class IteratorBase;
    127125  class Language;
    128126  class LanguageEntry;
     
    130128  class Loader;
    131129  class MetaObjectList;
    132   template <class T>
    133130  class MetaObjectListElement;
    134131  class Namespace;
     
    136133  template <class T>
    137134  class ObjectList;
     135  class ObjectListBase;
     136  class ObjectListBaseElement;
    138137  template <class T>
    139138  class ObjectListElement;
     139  template <class T>
     140  class ObjectListIterator;
    140141  class OrxonoxClass;
    141   class OutputBuffer;
    142   class OutputBufferListener;
    143   class OutputHandler;
    144142  class Shell;
    145143  class ShellListener;
  • code/trunk/src/core/Executor.cc

    r1625 r1747  
    6666    }
    6767
    68     bool Executor::evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter) const
     68    bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const
    6969    {
    7070        unsigned int paramCount = this->functor_->getParamCount();
     
    172172    }
    173173
    174     Executor& Executor::setDefaultValues(const MultiTypeMath& param1)
    175     {
    176         this->defaultValue_[0] = param1;
    177         this->bAddedDefaultValue_[0] = true;
    178 
    179         return (*this);
    180     }
    181 
    182     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
    183     {
    184         this->defaultValue_[0] = param1;
    185         this->bAddedDefaultValue_[0] = true;
    186         this->defaultValue_[1] = param2;
    187         this->bAddedDefaultValue_[1] = true;
    188 
    189         return (*this);
    190     }
    191 
    192     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     174    Executor& Executor::setDefaultValues(const MultiType& param1)
     175    {
     176        this->defaultValue_[0] = param1;
     177        this->bAddedDefaultValue_[0] = true;
     178
     179        return (*this);
     180    }
     181
     182    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
     183    {
     184        this->defaultValue_[0] = param1;
     185        this->bAddedDefaultValue_[0] = true;
     186        this->defaultValue_[1] = param2;
     187        this->bAddedDefaultValue_[1] = true;
     188
     189        return (*this);
     190    }
     191
     192    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    193193    {
    194194        this->defaultValue_[0] = param1;
     
    202202    }
    203203
    204     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     204    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    205205    {
    206206        this->defaultValue_[0] = param1;
     
    216216    }
    217217
    218     Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     218    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    219219    {
    220220        this->defaultValue_[0] = param1;
     
    232232    }
    233233
    234     Executor& Executor::setDefaultValue(unsigned int index, const MultiTypeMath& param)
     234    Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
    235235    {
    236236        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
  • code/trunk/src/core/Executor.h

    r1505 r1747  
    3737#include "util/Math.h"
    3838#include "Functor.h"
    39 #include "Debug.h"
     39#include "util/Debug.h"
    4040
    4141
     
    6464        { \
    6565            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
    66             EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiTypeMath(params)); \
     66            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
    6767        } \
    6868        else if (this->bAddedDefaultValue_[0]) \
     
    9090        } \
    9191        \
    92         MultiTypeMath param[MAX_FUNCTOR_ARGUMENTS]; \
     92        MultiType param[MAX_FUNCTOR_ARGUMENTS]; \
    9393        COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \
    9494        for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \
     
    145145            inline void operator()() const
    146146                { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    147             inline void operator()(const MultiTypeMath& param1) const
     147            inline void operator()(const MultiType& param1) const
    148148                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    149             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2) const
     149            inline void operator()(const MultiType& param1, const MultiType& param2) const
    150150                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    151             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     151            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    152152                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    153             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     153            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    154154                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
    155             inline void operator()(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     155            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    156156                { (*this->functor_)(param1, param2, param3, param4, param5); }
    157157
    158158            bool parse(const std::string& params, const std::string& delimiter = " ") const;
    159159
    160             bool evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter = " ") const;
     160            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
    161161
    162162            Executor& setDescription(const std::string& description);
     
    177177            inline FunctionType getType() const
    178178                { return this->functor_->getType(); }
    179             inline MultiTypeMath getReturnvalue() const
     179            inline MultiType getReturnvalue() const
    180180                { return this->functor_->getReturnvalue(); }
    181181            inline std::string getTypenameParam(unsigned int param) const
     
    189189                { return this->name_; }
    190190
    191             Executor& setDefaultValues(const MultiTypeMath& param1);
    192             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2);
    193             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3);
    194             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4);
    195             Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5);
    196             Executor& setDefaultValue(unsigned int index, const MultiTypeMath& param);
    197 
    198             inline MultiTypeMath getDefaultValue(unsigned int index) const
     191            Executor& setDefaultValues(const MultiType& param1);
     192            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
     193            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
     194            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
     195            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
     196            Executor& setDefaultValue(unsigned int index, const MultiType& param);
     197
     198            inline MultiType getDefaultValue(unsigned int index) const
    199199            {
    200200                if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     
    216216            Functor* functor_;
    217217            std::string name_;
    218             MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS];
     218            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
    219219            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
    220220
     
    245245            inline void operator()(T* object) const
    246246                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    247             inline void operator()(T* object, const MultiTypeMath& param1) const
     247            inline void operator()(T* object, const MultiType& param1) const
    248248                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    249             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2) const
     249            inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
    250250                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    251             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     251            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    252252                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    253             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     253            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    254254                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    255             inline void operator()(T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     255            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    256256                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    257257
     
    259259            inline void operator()(const T* object) const
    260260                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    261             inline void operator()(const T* object, const MultiTypeMath& param1) const
     261            inline void operator()(const T* object, const MultiType& param1) const
    262262                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    263             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2) const
     263            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
    264264                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    265             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const
     265            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    266266                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    267             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const
     267            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    268268                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    269             inline void operator()(const T* object, const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const
     269            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    270270                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    271271
  • code/trunk/src/core/Factory.cc

    r1505 r1747  
    3434#include "Factory.h"
    3535#include "Identifier.h"
    36 #include "Debug.h"
    3736#include "BaseObject.h"
     37#include "util/Debug.h"
    3838
    3939namespace orxonox
  • code/trunk/src/core/Functor.h

    r1505 r1747  
    3333#include "CorePrereqs.h"
    3434
    35 #include "util/MultiTypeMath.h"
    36 #include "Debug.h"
     35#include "util/MultiType.h"
     36#include "util/Debug.h"
    3737
    3838#define MAX_FUNCTOR_ARGUMENTS 5
     
    6969    CreateTypeToStringTemplate(long);
    7070    CreateTypeToStringTemplate(unsigned long);
     71    CreateTypeToStringTemplate(long long);
     72    CreateTypeToStringTemplate(unsigned long long);
    7173    CreateTypeToStringTemplate(float);
    7274    CreateTypeToStringTemplate(double);
     
    8082    CreateTypeToStringTemplate(Degree);
    8183
    82     template <> \
    83     inline std::string typeToString<std::string>() { return "string"; } \
    84     template <> \
    85     inline std::string typeToString<std::string&>() { return "string"; } \
    86     template <> \
    87     inline std::string typeToString<const std::string>() { return "string"; } \
    88     template <> \
     84    template <>
     85    inline std::string typeToString<std::string>() { return "string"; }
     86    template <>
     87    inline std::string typeToString<std::string&>() { return "string"; }
     88    template <>
     89    inline std::string typeToString<const std::string>() { return "string"; }
     90    template <>
    8991    inline std::string typeToString<const std::string&>() { return "string"; }
    9092
     
    9597            virtual ~Functor() {}
    9698
    97             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
     99            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
    98100
    99101            inline unsigned int getParamCount() const { return this->numParams_; }
    100102            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
    101103            inline FunctionType getType() const { return this->type_; }
    102             inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; }
     104            inline MultiType getReturnvalue() const { return this->returnedValue_; }
    103105
    104106            std::string getTypenameParam(unsigned int param) const { return (param >= 0 && param < 5) ? this->typeParam_[param] : ""; }
    105107            std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; }
    106108
    107             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const = 0;
     109            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
    108110
    109111        protected:
     
    111113            bool hasReturnValue_;
    112114            FunctionType type_;
    113             MultiTypeMath returnedValue_;
     115            MultiType returnedValue_;
    114116
    115117            std::string typeReturnvalue_;
     
    121123        public:
    122124            virtual ~FunctorStatic() {}
    123             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
     125            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
    124126    };
    125127
     
    136138            virtual ~FunctorMember() {}
    137139
    138             virtual void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
    139             virtual void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;
    140 
    141             virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)
     140            virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
     141            virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
     142
     143            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null)
    142144            {
    143145                if (this->bConstObject_)
     
    284286#define FUNCTOR_EVALUATE_PARAM0
    285287#define FUNCTOR_EVALUATE_PARAM1 \
    286     if (index == 0) { P1 temp = param; param = temp; }
     288    if (index == 0) { param.convert<P1>(); }
    287289#define FUNCTOR_EVALUATE_PARAM2 \
    288     if (index == 0) { P1 temp = param; param = temp; } \
    289     else if (index == 1) { P2 temp = param; param = temp; }
     290    if (index == 0) { param.convert<P1>(); } \
     291    else if (index == 1) { param.convert<P2>(); }
    290292#define FUNCTOR_EVALUATE_PARAM3 \
    291     if (index == 0) { P1 temp = param; param = temp; } \
    292     else if (index == 1) { P2 temp = param; param = temp; } \
    293     else if (index == 2) { P3 temp = param; param = temp; }
     293    if (index == 0) { param.convert<P1>(); } \
     294    else if (index == 1) { param.convert<P2>(); } \
     295    else if (index == 2) { param.convert<P3>(); }
    294296#define FUNCTOR_EVALUATE_PARAM4 \
    295     if (index == 0) { P1 temp = param; param = temp; } \
    296     else if (index == 1) { P2 temp = param; param = temp; } \
    297     else if (index == 2) { P3 temp = param; param = temp; } \
    298     else if (index == 3) { P4 temp = param; param = temp; }
     297    if (index == 0) { param.convert<P1>(); } \
     298    else if (index == 1) { param.convert<P2>(); } \
     299    else if (index == 2) { param.convert<P3>(); } \
     300    else if (index == 3) { param.convert<P4>(); }
    299301#define FUNCTOR_EVALUATE_PARAM5 \
    300     if (index == 0) { P1 temp = param; param = temp; } \
    301     else if (index == 1) { P2 temp = param; param = temp; } \
    302     else if (index == 2) { P3 temp = param; param = temp; } \
    303     else if (index == 3) { P4 temp = param; param = temp; } \
    304     else if (index == 4) { P5 temp = param; param = temp; }
     302    if (index == 0) { param.convert<P1>(); } \
     303    else if (index == 1) { param.convert<P2>(); } \
     304    else if (index == 2) { param.convert<P3>(); } \
     305    else if (index == 3) { param.convert<P4>(); } \
     306    else if (index == 4) { param.convert<P5>(); }
    305307
    306308
     
    324326            } \
    325327    \
    326             void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     328            void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    327329            { \
    328330                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    329331            } \
    330332    \
    331             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     333            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    332334            { \
    333335                FUNCTOR_EVALUATE_PARAM(numparams); \
     
    362364            } \
    363365    \
    364             void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     366            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    365367            { \
    366368                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    367369            } \
    368370    \
    369             void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     371            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    370372            { \
    371373                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
     
    373375            } \
    374376    \
    375             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     377            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    376378            { \
    377379                FUNCTOR_EVALUATE_PARAM(numparams); \
     
    395397            } \
    396398    \
    397             void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     399            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    398400            { \
    399401                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    400402            } \
    401403    \
    402             void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \
     404            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
    403405            { \
    404406                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    405407            } \
    406408    \
    407             virtual void evaluateParam(unsigned int index, MultiTypeMath& param) const \
     409            virtual void evaluateParam(unsigned int index, MultiType& param) const \
    408410            { \
    409411                FUNCTOR_EVALUATE_PARAM(numparams); \
  • code/trunk/src/core/IRC.cc

    r1505 r1747  
    3939namespace orxonox
    4040{
    41     SetConsoleCommand(IRC, say,  true).setAccessLevel(AccessLevel::User);
    42     SetConsoleCommand(IRC, msg,  false).setAccessLevel(AccessLevel::User);
    43     SetConsoleCommand(IRC, nick, false).setAccessLevel(AccessLevel::User);
    44 
    45     IRC* instance_irc = &IRC::getInstance();
     41    SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
     42    SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
     43    SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
    4644
    4745    IRC::IRC()
  • code/trunk/src/core/Identifier.cc

    r1543 r1747  
    3737
    3838#include "Factory.h"
     39#include "ConfigValueContainer.h"
    3940#include "ConsoleCommand.h"
    4041#include "CommandExecutor.h"
     42#include "XMLPort.h"
    4143
    4244namespace orxonox
     
    5254    Identifier::Identifier()
    5355    {
     56        this->objects_ = new ObjectListBase(this);
     57
    5458        this->bCreatedOneObject_ = false;
     59        this->bSetName_ = false;
    5560        this->factory_ = 0;
    5661
     
    7378        delete this->children_;
    7479        delete this->directChildren_;
     80        delete this->objects_;
     81
     82        if (this->factory_)
     83            delete this->factory_;
     84
     85        for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
     86            delete (it->second);
     87        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
     88            delete (it->second);
     89        for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
     90            delete (it->second);
     91        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
     92            delete (it->second);
    7593    }
    7694
     
    8199        @return The identifier (unique instance)
    82100    */
    83     Identifier *Identifier::getIdentifier(std::string &name, Identifier *proposal)
     101    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
    84102    {
    85103        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
    86104        std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name);
    87         if (it == identifiers.end())
    88         {
    89             // there isn't an entry yet, put the proposal in it
     105
     106        if (it != identifiers.end())
     107        {
     108            // There is already an entry: return it and delete the proposal
     109            delete proposal;
     110            return (*it).second;
     111        }
     112        else
     113        {
     114            // There is no entry: put the proposal into the map and return it
    90115            identifiers[name] = proposal;
    91         }
    92         else
    93         {
    94             // this happens when a template exists twice --> delete the proposal
    95             delete proposal;
    96         }
    97         return identifiers[name];
     116            return proposal;
     117        }
    98118    }
    99119
     
    139159                // Tell the parent we're one of it's direct children
    140160                (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
     161
     162                // Create the super-function dependencies
     163                (*it)->createSuperFunctionCaller();
    141164            }
     165        }
     166    }
     167
     168    /**
     169        @brief Destroys all Identifiers. Called when exiting the program.
     170    */
     171    void Identifier::destroyAllIdentifiers()
     172    {
     173        for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
     174            delete (it->second);
     175    }
     176
     177    /**
     178        @brief Sets the name of the class.
     179        @param name The name
     180    */
     181    void Identifier::setName(const std::string& name)
     182    {
     183        if (!this->bSetName_)
     184        {
     185            this->name_ = name;
     186            this->bSetName_ = true;
     187            Identifier::getIdentifierMapIntern()[name] = this;
     188            Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
    142189        }
    143190    }
     
    258305        {
    259306            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
     307            delete (it->second);
    260308        }
    261309
     
    305353        {
    306354            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
     355            delete (it->second);
    307356        }
    308357
     
    343392        else
    344393            return 0;
     394    }
     395
     396    /**
     397        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
     398        @param paramname The name of the parameter
     399        @return The container
     400    */
     401    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
     402    {
     403        std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);
     404        if (it != xmlportParamContainers_.end())
     405            return ((*it).second);
     406        else
     407            return 0;
     408    }
     409
     410    /**
     411        @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
     412        @param paramname The name of the parameter
     413        @param container The container
     414    */
     415    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
     416    {
     417        this->xmlportParamContainers_[paramname] = container;
     418    }
     419
     420    /**
     421        @brief Returns a XMLPortObjectContainer that attaches an object to this class.
     422        @param sectionname The name of the section that contains the attachable objects
     423        @return The container
     424    */
     425    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
     426    {
     427        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
     428        if (it != xmlportObjectContainers_.end())
     429            return ((*it).second);
     430        else
     431            return 0;
     432    }
     433
     434    /**
     435        @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
     436        @param sectionname The name of the section that contains the attachable objects
     437        @param container The container
     438    */
     439    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
     440    {
     441        this->xmlportObjectContainers_[sectionname] = container;
    345442    }
    346443
  • code/trunk/src/core/Identifier.h

    r1639 r1747  
    6262#include <stdlib.h>
    6363
    64 #include "ObjectList.h"
    65 #include "Debug.h"
     64#include "MetaObjectList.h"
    6665#include "Iterator.h"
    67 #include "MetaObjectList.h"
     66#include "Super.h"
     67#include "util/Debug.h"
    6868#include "util/String.h"
    6969
     
    9191    {
    9292        template <class T>
    93         friend class ClassIdentifier;
    94 
    95         template <class T>
    9693        friend class SubclassIdentifier;
    9794
     
    110107            bool isDirectParentOf(const Identifier* identifier) const;
    111108
    112             virtual const ObjectList<BaseObject>* getObjectList() const = 0;
    113 
    114             virtual void updateConfigValues() const = 0;
     109            /** @brief Returns the list of all existing objects of this class. @return The list */
     110            inline ObjectListBase* getObjects() const
     111                { return this->objects_; }
    115112
    116113            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
    117114            inline const std::string& getName() const { return this->name_; }
    118 
     115            void setName(const std::string& name);
     116
     117            virtual void updateConfigValues(bool updateChildren = true) const = 0;
    119118
    120119            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    210209            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
    211210
    212             virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
    213             virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0;
    214 
    215             virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;
    216             virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0;
     211            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
     212            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     213
     214            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
     215            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
    217216
    218217            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
     
    221220
    222221        protected:
     222            Identifier();
     223            Identifier(const Identifier& identifier); // don't copy
     224            virtual ~Identifier();
     225
     226            void initialize(std::set<const Identifier*>* parents);
     227            static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
     228
     229            virtual void createSuperFunctionCaller() const = 0;
     230
    223231            /** @brief Returns the map that stores all Identifiers. @return The map */
    224232            static std::map<std::string, Identifier*>& getIdentifierMapIntern();
     
    226234            static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
    227235
    228         private:
    229             Identifier();
    230             Identifier(const Identifier& identifier); // don't copy
    231             virtual ~Identifier();
    232             void initialize(std::set<const Identifier*>* parents);
    233 
    234236            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    235237            inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
     
    237239            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
    238240
     241            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     242            ObjectListBase* objects_;                                      //!< The list of all objects of this class
     243
     244        private:
    239245            /**
    240246                @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
     
    255261            }
    256262
    257             static Identifier* getIdentifier(std::string &name, Identifier *proposal);
     263            static void destroyAllIdentifiers();
    258264
    259265            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
     
    263269            std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
    264270
     271            bool bSetName_;                                                //!< True if the name is set
    265272            std::string name_;                                             //!< The name of the class the Identifier belongs to
    266 
    267273            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    268             bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
    269274            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
    270275            unsigned int classID_;                                         //!< The network ID to identify a class through the network
     
    277282            std::map<std::string, ConsoleCommand*> consoleCommands_;       //!< All console commands of this class
    278283            std::map<std::string, ConsoleCommand*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
     284
     285            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
     286            std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_;   //!< All attachable objects
    279287    };
    280288
     
    297305    class ClassIdentifier : public Identifier
    298306    {
     307        #define SUPER_INTRUSIVE_DECLARATION_INCLUDE
     308        #include "Super.h"
     309
    299310        public:
    300             ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass);
     311            static ClassIdentifier<T> *getIdentifier();
     312            static ClassIdentifier<T> *getIdentifier(const std::string& name);
     313            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     314            static bool isFirstCall();
    301315            void addObject(T* object);
    302             void setName(const std::string& name);
    303             /** @brief Returns the list of all existing objects of this class. @return The list */
    304             inline ObjectList<T>* getObjects() const { return this->objects_; }
    305             /** @brief Returns a list of all existing objects of this class. @return The list */
    306             inline ObjectList<BaseObject>* getObjectList() const { return (ObjectList<BaseObject>*)this->objects_; }
    307 
    308             void updateConfigValues() const;
    309 
    310             XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
    311             void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
    312 
    313             XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
    314             void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
    315 
    316             static ClassIdentifier<T> *getIdentifier();
     316
     317            void updateConfigValues(bool updateChildren = true) const;
    317318
    318319        private:
    319             ClassIdentifier();
    320320            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
    321             ~ClassIdentifier() {}                                       // don't delete
    322 
    323             ObjectList<T>* objects_;                                                                    //!< The ObjectList, containing all objects of type T
    324             bool bSetName_;                                                                             //!< True if the name is set
    325             std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;              //!< All loadable parameters
    326             std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;   //!< All attachable objects
     321            ClassIdentifier()
     322            {
     323                SuperFunctionInitialization<0, T>::initialize(this);
     324            }
     325            ~ClassIdentifier()
     326            {
     327                SuperFunctionDestruction<0, T>::destroy(this);
     328            }
    327329
    328330            static ClassIdentifier<T> *classIdentifier_s;
     
    333335
    334336    /**
    335         @brief Constructor: Creates the ObjectList.
    336     */
    337     template <class T>
    338     ClassIdentifier<T>::ClassIdentifier()
    339     {
    340 //        this->objects_ = ObjectList<T>::getList();
    341         this->objects_ = new ObjectList<T>();
    342         this->bSetName_ = false;
    343     }
    344 
    345     /**
    346337        @brief Registers a class, which means that the name and the parents get stored.
    347338        @param parents A list, containing the Identifiers of all parents of the class
    348         @param name A string, containing exactly the name of the class
    349339        @param bRootClass True if the class is either an Interface or the BaseObject itself
    350         @return The ClassIdentifier itself
    351     */
    352     template <class T>
    353     ClassIdentifier<T>* ClassIdentifier<T>::registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass)
    354     {
    355         this->setName(name);
    356 
     340    */
     341    template <class T>
     342    void ClassIdentifier<T>::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass)
     343    {
    357344        // Check if at least one object of the given type was created
    358345        if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
    359346        {
    360347            // If no: We have to store the informations and initialize the Identifier
    361             COUT(4) << "*** ClassIdentifier: Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl;
     348            COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;
    362349            if (bRootClass)
    363                 this->initialize(NULL); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
     350                this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
    364351            else
    365352                this->initialize(parents);
    366353        }
    367 
    368         return this;
    369354    }
    370355
    371356    /**
    372         @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name.
     357        @brief Returns true if the function gets called the first time, false otherwise.
     358        @return True if this function got called the first time.
     359    */
     360    template <class T>
     361    bool ClassIdentifier<T>::isFirstCall()
     362    {
     363        static bool bFirstCall = true;
     364
     365        if (bFirstCall)
     366        {
     367            bFirstCall = false;
     368            return true;
     369        }
     370        else
     371        {
     372            return false;
     373        }
     374    }
     375
     376    /**
     377        @brief Returns the only instance of this class.
    373378        @return The unique Identifier
    374379    */
     
    377382    {
    378383        // check if the static field has already been filled
    379         if (ClassIdentifier<T>::classIdentifier_s == 0)
     384        if (ClassIdentifier<T>::isFirstCall())
    380385        {
    381386            // Get the name of the class
     
    383388
    384389            // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
    385             ClassIdentifier<T> *proposal = new ClassIdentifier<T>();
     390            ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
    386391
    387392            // Get the entry from the map
    388             ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifier(name, proposal);
     393            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal);
     394
     395            if (ClassIdentifier<T>::classIdentifier_s == proposal)
     396            {
     397                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;
     398            }
     399            else
     400            {
     401                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;
     402            }
    389403        }
    390404
     
    394408
    395409    /**
    396         @brief Sets the name of the class.
    397         @param name The name
    398     */
    399     template <class T>
    400     void ClassIdentifier<T>::setName(const std::string& name)
    401     {
    402         if (!this->bSetName_)
    403         {
    404             this->name_ = name;
    405             this->bSetName_ = true;
    406             Identifier::getIdentifierMapIntern()[name] = this;
    407             Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
    408         }
     410        @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.
     411        @param name The name of this Identifier
     412        @return The Identifier
     413    */
     414    template <class T>
     415    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
     416    {
     417        ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
     418        identifier->setName(name);
     419        return identifier;
    409420    }
    410421
     
    417428    {
    418429        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    419         object->getMetaList().add(this->objects_, this->objects_->add(object));
     430        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
    420431    }
    421432
     
    424435    */
    425436    template <class T>
    426     void ClassIdentifier<T>::updateConfigValues() const
    427     {
    428         for (Iterator<T> it = this->objects_->start(); it; ++it)
    429             ((T*)*it)->setConfigValues();
    430     }
    431 
    432     /**
    433         @brief Returns a XMLPortParamContainer that loads a parameter of this class.
    434         @param paramname The name of the parameter
    435         @return The container
    436     */
    437     template <class T>
    438     XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname)
    439     {
    440         typename std::map<std::string, XMLPortClassParamContainer<T>*>::const_iterator it = xmlportParamContainers_.find(paramname);
    441         if (it != xmlportParamContainers_.end())
    442             return (XMLPortParamContainer*)((*it).second);
    443         else
    444             return 0;
    445     }
    446 
    447     /**
    448         @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
    449         @param paramname The name of the parameter
    450         @param container The container
    451     */
    452     template <class T>
    453     void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
    454     {
    455         this->xmlportParamContainers_[paramname] = (XMLPortClassParamContainer<T>*)container;
    456     }
    457 
    458     /**
    459         @brief Returns a XMLPortObjectContainer that attaches an object to this class.
    460         @param sectionname The name of the section that contains the attachable objects
    461         @return The container
    462     */
    463     template <class T>
    464     XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname)
    465     {
    466         typename std::map<std::string, XMLPortClassObjectContainer<T, class O>*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
    467         if (it != xmlportObjectContainers_.end())
    468             return (XMLPortObjectContainer*)((*it).second);
    469         else
    470             return 0;
    471     }
    472 
    473     /**
    474         @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
    475         @param sectionname The name of the section that contains the attachable objects
    476         @param container The container
    477     */
    478     template <class T>
    479     void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
    480     {
    481         this->xmlportObjectContainers_[sectionname] = (XMLPortClassObjectContainer<T, class O>*)container;
     437    void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const
     438    {
     439        if (!this->hasConfigValues())
     440            return;
     441
     442        for (ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)
     443            it->setConfigValues();
     444
     445        if (updateChildren)
     446            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
     447                (*it)->updateConfigValues(false);
    482448    }
    483449
  • code/trunk/src/core/Iterator.h

    r1625 r1747  
    3131    @brief Definition and implementation of the Iterator class.
    3232
    33     The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
    34     This is the only way to access the objects stored in an ObjectList.
     33    The Iterator of a given class allows to iterate through an ObjectList. Objects in
     34    this list are casted to the template argument of the Iterator.
    3535
    3636    Usage:
    37     for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
     37    for (Iterator<myClass> it = anyidentifier->getObjects().begin(); it != anyidentifier->getObjects().end(); ++it)
    3838    {
    3939        it->someFunction(...);
    40         class* myObject = *it;
     40        myClass* myObject = *it;
    4141    }
    42 
    43     Warning: Don't delete objects directly through the iterator.
    4442*/
    4543
     
    4947#include "CorePrereqs.h"
    5048
    51 #include "ObjectList.h"
     49#include "ObjectListBase.h"
     50#include "ObjectListIterator.h"
     51#include "OrxonoxClass.h"
    5252
    5353namespace orxonox
    5454{
    55     //! The iterator allows to iterate through an ObjectList of a given class.
    56     template <class T>
     55    //! The Iterator allows to iterate through a given ObjectList
     56    template <class T = OrxonoxClass>
    5757    class Iterator
    5858    {
     
    6161                @brief Constructor: Sets the element, whereon the iterator points, to zero.
    6262            */
    63             Iterator()
     63            inline Iterator()
    6464            {
    6565                this->element_ = 0;
    66                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
    67             }
    68 
    69             /**
    70                 @brief Constructor: Sets the element, whereon the iterator points, to a given element.
    71                 @param element The element to start with
    72             */
    73             Iterator(ObjectListElement<T>* element)
    74             {
    75                 this->element_ = element;
    76                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
     66                this->list_ = 0;
     67            }
     68
     69            /**
     70                @brief Constructor: Sets this element to the exported element.
     71                @param exp The exported element
     72            */
     73            inline Iterator(const ObjectListBase::Export& exp)
     74            {
     75                this->element_ = exp.element_;
     76                this->list_ = exp.list_;
     77                this->iterator_ = this->list_->registerIterator(this);
     78            }
     79
     80            /**
     81                @brief Constructor: Sets this element to the element of another Iterator.
     82                @param other The other Iterator
     83            */
     84            inline Iterator(const Iterator<T>& other)
     85            {
     86                this->element_ = other.element_;
     87                this->list_ = other.list_;
     88                this->iterator_ = this->list_->registerIterator(this);
     89            }
     90
     91            /**
     92                @brief Constructor: Sets this element to a given element
     93                @param element The element
     94            */
     95            template <class O>
     96            inline Iterator(ObjectListElement<O>* element)
     97            {
     98                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     99                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     100                this->iterator_ = this->list_->registerIterator(this);
     101            }
     102
     103            /**
     104                @brief Constructor: Sets this element to the element an ObjectListIterator.
     105                @param other The ObjectListIterator
     106            */
     107            template <class O>
     108            inline Iterator(const ObjectListIterator<O>& other)
     109            {
     110                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     111                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     112                this->iterator_ = this->list_->registerIterator(this);
    77113            }
    78114
     
    80116                @brief Unregisters the Iterator from the ObjectList.
    81117            */
    82             ~Iterator()
    83             {
    84                 ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this);
    85             }
    86 
    87             /**
    88                 @brief Assigns an element to the iterator.
     118            inline ~Iterator()
     119            {
     120                this->list_->unregisterIterator(this->iterator_);
     121            }
     122
     123            /**
     124                @brief Assigns an exported element.
     125                @param exp The exported element
     126            */
     127            inline const Iterator<T>& operator=(const ObjectListBase::Export& exp)
     128            {
     129                if (this->list_)
     130                    this->list_->unregisterIterator(this->iterator_);
     131
     132                this->element_ = exp.element_;
     133                this->list_ = exp.list_;
     134                this->iterator_ = this->list_->registerIterator(this);
     135
     136                return (*this);
     137            }
     138
     139            /**
     140                @brief Assigns the element of another Iterator.
     141                @param other The other Iterator
     142            */
     143            inline const Iterator<T>& operator=(const Iterator<T>& other)
     144            {
     145                if (this->list_)
     146                    this->list_->unregisterIterator(this->iterator_);
     147
     148                this->element_ = other.element_;
     149                this->list_ = other.list_;
     150                this->iterator_ = this->list_->registerIterator(this);
     151
     152                return (*this);
     153            }
     154
     155            /**
     156                @brief Assigns a given element.
    89157                @param element The element
    90158            */
    91             Iterator<T> operator=(ObjectListElement<T>* element)
    92             {
    93                 this->element_ = element;
     159            template <class O>
     160            inline const Iterator<T>& operator=(ObjectListElement<O>* element)
     161            {
     162                if (this->list_)
     163                    this->list_->unregisterIterator(this->iterator_);
     164
     165                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     166                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     167                this->iterator_ = this->list_->registerIterator(this);
     168
     169                return (*this);
    94170                return *this;
     171            }
     172
     173            /**
     174                @brief Assigns the element of an ObjectListIterator.
     175                @param other The ObjectListIterator
     176            */
     177            template <class O>
     178            inline const Iterator<T>& operator=(const ObjectListIterator<O>& other)
     179            {
     180                if (this->list_)
     181                    this->list_->unregisterIterator(this->iterator_);
     182
     183                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     184                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
     185                this->iterator_ = this->list_->registerIterator(this);
     186
     187                return (*this);
    95188            }
    96189
     
    99192                @return The Iterator itself
    100193            */
    101             Iterator<T> operator++()
     194            inline const Iterator<T>& operator++()
    102195            {
    103196                if (this->element_)
     
    110203                @return The Iterator itself
    111204            */
    112             Iterator<T> operator++(int i)
     205            inline Iterator<T> operator++(int i)
    113206            {
    114207                Iterator<T> copy = *this;
     
    122215                @return The Iterator itself
    123216            */
    124             Iterator<T> operator--()
     217            inline const Iterator<T>& operator--()
    125218            {
    126219                if (this->element_)
     
    133226                @return The Iterator itself
    134227            */
    135             Iterator<T> operator--(int i)
     228            inline Iterator<T> operator--(int i)
    136229            {
    137230                Iterator<T> copy = *this;
     
    145238                @return The object the Iterator points at
    146239            */
    147             T* operator*()
    148             {
    149                 if (this->element_)
    150                     return this->element_->object_;
     240            inline T* operator*() const
     241            {
     242                if (this->element_)
     243                    return dynamic_cast<T*>(this->element_->objectBase_);
    151244                else
    152245                    return 0;
     
    157250                @return The object the Iterator points at
    158251            */
    159             T* operator->() const
    160             {
    161                 if (this->element_)
    162                     return this->element_->object_;
     252            inline T* operator->() const
     253            {
     254                if (this->element_)
     255                    return dynamic_cast<T*>(this->element_->objectBase_);
    163256                else
    164257                    return 0;
    165 
    166258            }
    167259
    168260            /**
    169261                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
    170                 @return True if the iterator points to an existing object.
    171             */
    172             operator bool()
     262                @return True if the Iterator points to an existing object.
     263            */
     264            inline operator bool() const
    173265            {
    174266                return (this->element_ != 0);
     
    176268
    177269            /**
    178                 @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
    179                 @param compare The integer (must be zero, everything else makes no sense).
    180                 @return True if the iterator points to an existing object.
    181             */
    182             bool operator!=(ObjectListElement<T>* compare)
    183             {
    184                 return (this->element_ != compare);
    185             }
    186 
    187         private:
    188             ObjectListElement<T>* element_;     //!< The element the Iterator points at
     270                @brief Overloading of the == operator to compare with another Iterator.
     271                @param compare The other Iterator
     272                @return True if the iterators point to the same element
     273            */
     274            inline bool operator==(const Iterator<T>& compare) const
     275            {
     276                return (this->element_ == compare.element_);
     277            }
     278
     279            /**
     280                @brief Overloading of the != operator to compare with another Iterator.
     281                @param compare The other Iterator
     282                @return True if the iterators point to different elements
     283            */
     284            inline bool operator!=(const Iterator<T>& compare) const
     285            {
     286                return (this->element_ != compare.element_);
     287            }
     288
     289            /**
     290                @brief Increments the Iterator if it points at the given object.
     291                @param object The object to compare with
     292            */
     293            inline void incrementIfEqual(OrxonoxClass* object)
     294            {
     295                if (this->element_ && this->element_->objectBase_ == object)
     296                    this->operator++();
     297            }
     298
     299        protected:
     300            ObjectListBaseElement* element_;       //!< The element the Iterator points at
     301            ObjectListBase* list_;                 //!< The list wherein the element is
     302            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
    189303    };
     304
     305    typedef Iterator<OrxonoxClass> BaseIterator;
    190306}
    191307
     308// Include ObjectList.h so the user only has to include one file: Iterator.h
     309#include "ObjectList.h"
     310
    192311#endif /* _Iterator_H__ */
  • code/trunk/src/core/Language.cc

    r1535 r1747  
    3737
    3838#include "Core.h"
    39 
    40 #include "Debug.h"
     39#include "util/Debug.h"
    4140
    4241namespace orxonox
     
    9897        // Read the default language file to create all known LanguageEntry objects
    9998        this->readDefaultLanguageFile();
     99    }
     100
     101    /**
     102        @brief Destructor: Deletes all language entries.
     103    */
     104    Language::~Language()
     105    {
     106        for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
     107            delete (it->second);
    100108    }
    101109
  • code/trunk/src/core/Language.h

    r1535 r1747  
    123123            Language();
    124124            Language(const Language& language);     // don't copy
    125             virtual ~Language() {};                 // don't delete
     125            virtual ~Language();
    126126
    127127            void readDefaultLanguageFile();
  • code/trunk/src/core/Loader.cc

    r1625 r1747  
    3232#include "Identifier.h"
    3333#include "Iterator.h"
    34 #include "Debug.h"
     34#include "ObjectList.h"
    3535#include "CoreIncludes.h"
    3636#include "Script.h"
    3737#include "Namespace.h"
     38#include "util/Debug.h"
    3839
    3940#include "tinyxml/ticpp.h"
     
    9192    void Loader::unload(const ClassTreeMask& mask)
    9293    {
    93         for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )
     94        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
    9495        {
    9596            if (mask.isIncluded(it->getIdentifier()))
     
    165166    void Loader::unload(const Level* level, const ClassTreeMask& mask)
    166167    {
    167         for (Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )
     168        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
    168169        {
    169170            if ((it->getLevel() == level) && mask.isIncluded(it->getIdentifier()))
  • code/trunk/src/core/MetaObjectList.cc

    r1505 r1747  
    3333
    3434#include "MetaObjectList.h"
     35#include "ObjectListBase.h"
     36#include "Identifier.h"
     37#include "util/Debug.h"
    3538
    3639namespace orxonox
    3740{
     41    // ###############################
     42    // ###  MetaObjectListElement  ###
     43    // ###############################
     44    /**
     45        @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement.
     46    */
     47    MetaObjectListElement::~MetaObjectListElement()
     48    {
     49        COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
     50        this->list_->notifyIterators(this->element_->objectBase_);
     51
     52        if (this->element_->next_)
     53            this->element_->next_->prev_ = this->element_->prev_;
     54        else
     55            this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
     56
     57        if (this->element_->prev_)
     58            this->element_->prev_->next_ = this->element_->next_;
     59        else
     60            this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
     61
     62        delete this->element_;
     63    }
     64
     65
     66    // ###############################
     67    // ###     MetaObjectList      ###
     68    // ###############################
    3869    /**
    3970        @brief Constructor: Sets first_ to zero.
     
    4980    MetaObjectList::~MetaObjectList()
    5081    {
    51         BaseMetaObjectListElement* temp;
     82        MetaObjectListElement* temp;
    5283        while (this->first_)
    5384        {
     
    5788        }
    5889    }
     90
     91    /**
     92        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
     93        @param list The ObjectList wherein the element is
     94        @param element The element wherein the object is
     95    */
     96    void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element)
     97    {
     98        MetaObjectListElement* temp = this->first_;
     99        this->first_ = new MetaObjectListElement(list, element);
     100        this->first_->next_ = temp;
     101    }
    59102}
  • code/trunk/src/core/MetaObjectList.h

    r1543 r1747  
    4141#include "CorePrereqs.h"
    4242
    43 #include "ObjectList.h"
    44 #include "Identifier.h"
    45 #include "Debug.h"
    46 
    4743namespace orxonox
    4844{
    49     //! Base-class of MetaObjectListElement, because those is a template
    50     class BaseMetaObjectListElement
    51     {
    52         public:
    53             /** @brief Default destructor */
    54             virtual ~BaseMetaObjectListElement() {};
    55 
    56             BaseMetaObjectListElement* next_;       //!< The next Element in the list
    57     };
    58 
    5945    // ###############################
    6046    // ###  MetaObjectListElement  ###
    6147    // ###############################
    6248    //! The list-element of the MetaObjectList
    63     template <class T>
    64     class MetaObjectListElement : public BaseMetaObjectListElement
     49    class _CoreExport MetaObjectListElement
    6550    {
    6651        public:
    67             MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element);
    68             virtual ~MetaObjectListElement();
     52            /**
     53                @brief Constructor: Creates the list-element with given list and element.
     54            */
     55            MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
     56            ~MetaObjectListElement();
    6957
    70             ObjectListElement<T>* element_;         //!< The list element, containing the object
    71             ObjectList<T>* list_;                   //!< The list, containing the element
     58            MetaObjectListElement* next_;       //!< The next Element in the list
     59            ObjectListBaseElement* element_;    //!< The list element, containing the object
     60            ObjectListBase* list_;              //!< The list, containing the element
    7261    };
    73 
    74     /**
    75         @brief Constructor: Creates the list-element with given list and element.
    76     */
    77     template <class T>
    78     MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)
    79     {
    80         this->element_ = element;
    81         this->list_ = list;
    82         this->next_ = 0;
    83     }
    84 
    85     /**
    86         @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.
    87     */
    88     template <class T>
    89     MetaObjectListElement<T>::~MetaObjectListElement()
    90     {
    91         COUT(5) << "*** MetaObjectList: Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;
    92         this->list_->notifyIterators(this->element_);
    93 
    94         if (this->element_->next_)
    95             this->element_->next_->prev_ = this->element_->prev_;
    96         else
    97             this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
    98 
    99         if (this->element_->prev_)
    100             this->element_->prev_->next_ = this->element_->next_;
    101         else
    102             this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
    103 
    104         delete this->element_;
    105     }
    10662
    10763
     
    10965    // ###     MetaObjectList      ###
    11066    // ###############################
    111     //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
     67    //!  The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
    11268    /**
    11369        The MetaObjectList is a single-linked list, containing all list-elements and their
     
    12076            MetaObjectList();
    12177            ~MetaObjectList();
    122             template <class T>
    123             void add(ObjectList<T>* list, ObjectListElement<T>* element);
     78            void add(ObjectListBase* list, ObjectListBaseElement* element);
    12479
    125             BaseMetaObjectListElement* first_;      //!< The first element in the list
     80            MetaObjectListElement* first_;      //!< The first element in the list
    12681    };
    127 
    128     /**
    129         @brief Adds an ObjectList and an element of that list to the MetaObjectList.
    130         @param list The ObjectList wherein the element is
    131         @param element The element wherein the object is
    132     */
    133     template <class T>
    134     void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)
    135     {
    136         BaseMetaObjectListElement* temp = this->first_;
    137         this->first_ = new MetaObjectListElement<T>(list, element);
    138         this->first_->next_ = temp;
    139     }
    14082}
    14183
  • code/trunk/src/core/Namespace.cc

    r1505 r1747  
    6060    void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6161    {
    62         BaseObject::XMLPort(xmlelement, mode);
     62        SUPER(Namespace, XMLPort, xmlelement, mode);
    6363
    6464        std::string name = this->getName();
  • code/trunk/src/core/NamespaceNode.cc

    r1505 r1747  
    2828
    2929#include "NamespaceNode.h"
    30 #include "Debug.h"
     30#include "util/Debug.h"
    3131
    3232namespace orxonox
  • code/trunk/src/core/ObjectList.h

    r1543 r1747  
    3131    @brief Definition and implementation of the ObjectList class.
    3232
    33     The ObjectList is a double-linked list, used by Identifiers to store all objects of a given class.
    34     Newly created objects are added through the RegisterObject-macro in its constructor.
     33    The ObjectList is a wrapper of an ObjectListBase of a given class.
    3534    Use Iterator<class> to iterate through all objects of the class.
    3635*/
     
    3938#define _ObjectList_H__
    4039
    41 #include <set>
    42 
    4340#include "CorePrereqs.h"
    4441
    45 #include "Iterator.h"
    4642#include "Identifier.h"
     43#include "ObjectListIterator.h"
    4744
    4845namespace orxonox
    4946{
    5047    // ###############################
    51     // ###    ObjectListElement    ###
    52     // ###############################
    53     //! The list-element of the ObjectList
    54     template <class T>
    55     class ObjectListElement
    56     {
    57         public:
    58             ObjectListElement(T* object);
    59 
    60             T* object_;                     //!< The object
    61             ObjectListElement* next_;       //!< The next element in the list
    62             ObjectListElement* prev_;       //!< The previous element in the list
    63     };
    64 
    65     /**
    66         @brief Constructor: Creates the list-element with an object.
    67         @param object The object to store
    68     */
    69     template <class T>
    70     ObjectListElement<T>::ObjectListElement(T* object)
    71     {
    72         this->object_ = object;
    73         this->next_ = 0;
    74         this->prev_ = 0;
    75     }
    76 
    77 
    78     // ###############################
    7948    // ###       ObjectList        ###
    8049    // ###############################
    81     //! The ObjectList contains all objects of a given class.
     50    //! The ObjectList contains all objects of the given class.
    8251    /**
    83         The ObjectList is used by Identifiers to store all objects of a given class.
    84         Use Iterator<class> to iterate through all objects in the list.
     52        Wraps the ObjectListBase of the corresponding Identifier.
     53        Use ObjectListIterator<class> to iterate through all objects in the list.
    8554    */
    8655    template <class T>
     
    8857    {
    8958        public:
    90             ObjectList();
    91             ~ObjectList();
     59            typedef ObjectListIterator<T> iterator;
    9260
    93             ObjectListElement<T>* add(T* object);
     61            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
     62            inline static ObjectListElement<T>* begin()
     63                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
    9464
    95             /** @brief Returns the first element in the list. @return The first element */
    96             inline static Iterator<T> start()
    97                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
     65            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
     66            inline static ObjectListElement<T>* end()
     67                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
    9868
    99             /** @brief Returns the first element in the list. @return The first element */
    100             inline static Iterator<T> begin()
    101                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }
     69            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
     70            inline static ObjectListElement<T>* rbegin()
     71                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
    10272
    103             /** @brief Returns the last element in the list. @return The last element */
    104             inline static Iterator<T> end()
    105                 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->last_); }
    106 
    107             inline void registerIterator(Iterator<T>* iterator)
    108                 { this->iterators_.insert(this->iterators_.end(), (void*)iterator); }
    109             inline void unregisterIterator(Iterator<T>* iterator)
    110                 { this->iterators_.erase((void*)iterator); }
    111             void notifyIterators(ObjectListElement<T>* element);
    112 
    113             ObjectListElement<T>* first_;       //!< The first element in the list
    114             ObjectListElement<T>* last_;        //!< The last element in the list
    115 
    116         private:
    117             std::set<void*> iterators_;  //!< A list of iterators pointing on an element in this list
     73            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
     74            inline static ObjectListElement<T>* rend()
     75                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
    11876    };
    119 
    120     /**
    121         @brief Constructor: Sets default values.
    122     */
    123     template <class T>
    124     ObjectList<T>::ObjectList()
    125     {
    126         this->first_ = 0;
    127         this->last_ = 0;
    128     }
    129 
    130     /**
    131         @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
    132     */
    133     template <class T>
    134     ObjectList<T>::~ObjectList()
    135     {
    136         ObjectListElement<T>* temp;
    137         while (this->first_)
    138         {
    139             temp = this->first_->next_;
    140             delete this->first_;
    141             this->first_ = temp;
    142         }
    143     }
    144 
    145     /**
    146         @brief Increases all Iterators that currently point on the given element (because it gets removed).
    147         @param element The element that gets removed
    148     */
    149     template <class T>
    150     void ObjectList<T>::notifyIterators(ObjectListElement<T>* element)
    151     {
    152         for (std::set<void*>::iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
    153             if ((*(*((Iterator<T>*)(*it)))) == element->object_)
    154                 ++(*((Iterator<T>*)(*it)));
    155     }
    156 
    157     /**
    158         @brief Adds a new object to the end of the list.
    159         @param object The object to add
    160         @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object
    161     */
    162     template <class T>
    163     ObjectListElement<T>* ObjectList<T>::add(T* object)
    164     {
    165         if (!this->last_)
    166         {
    167             // If the list is empty
    168             this->last_ = new ObjectListElement<T>(object);
    169             this->first_ = this->last_; // There's only one object in the list now
    170         }
    171         else
    172         {
    173             // If the list isn't empty
    174             ObjectListElement<T>* temp = this->last_;
    175             this->last_ = new ObjectListElement<T>(object);
    176             this->last_->prev_ = temp;
    177             temp->next_ = this->last_;
    178         }
    179 
    180         return this->last_;
    181     }
    18277}
    18378
  • code/trunk/src/core/OrxonoxClass.cc

    r1505 r1747  
    3939{
    4040    /** @brief Constructor: Sets the default values. */
    41     OrxonoxClass::OrxonoxClass() :
    42       identifier_(0),
    43       parents_(0)
     41    OrxonoxClass::OrxonoxClass()
    4442    {
     43        this->identifier_ = 0;
     44        this->parents_ = 0;
    4545        this->metaList_ = new MetaObjectList();
    46 
    47         this->setConfigValues();
    4846    }
    4947
  • code/trunk/src/core/Shell.cc

    r1540 r1747  
    3434#include "ConsoleCommand.h"
    3535#include "input/InputInterfaces.h"
     36#include "util/OutputHandler.h"
    3637
    3738#define SHELL_UPDATE_LISTENERS(function) \
     
    4344    SetConsoleCommand(Shell, clearShell, true);
    4445    SetConsoleCommand(Shell, history, true);
     46
     47    SetConsoleCommandShortcut(OutputHandler, log);
     48    SetConsoleCommandShortcut(OutputHandler, error);
     49    SetConsoleCommandShortcut(OutputHandler, warning);
     50    SetConsoleCommandShortcut(OutputHandler, info);
     51    SetConsoleCommandShortcut(OutputHandler, debug);
    4552
    4653    Shell::Shell()
     
    6168
    6269        this->outputBuffer_.registerListener(this);
     70        OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_);
    6371
    6472        this->setConfigValues();
     
    8290    void Shell::setConfigValues()
    8391    {
    84         SetConfigValue(maxHistoryLength_, 100);
    85         SetConfigValue(historyOffset_, 0);
     92        SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged);
     93        SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged);
    8694        SetConfigValueVector(commandHistory_, std::vector<std::string>());
    87 
     95    }
     96
     97    void Shell::commandHistoryOffsetChanged()
     98    {
    8899        if (this->historyOffset_ >= this->maxHistoryLength_)
    89100            this->historyOffset_ = 0;
     101    }
     102
     103    void Shell::commandHistoryLengthChanged()
     104    {
     105        this->commandHistoryOffsetChanged();
    90106
    91107        while (this->commandHistory_.size() > this->maxHistoryLength_)
  • code/trunk/src/core/Shell.h

    r1535 r1747  
    3737#include "OrxonoxClass.h"
    3838#include "input/InputBuffer.h"
    39 #include "OutputBuffer.h"
     39#include "util/OutputBuffer.h"
    4040
    4141namespace orxonox
     
    6767
    6868            virtual void setConfigValues();
     69            void commandHistoryOffsetChanged();
     70            void commandHistoryLengthChanged();
    6971
    7072            void registerListener(ShellListener* listener);
  • code/trunk/src/core/TclBind.cc

    r1505 r1747  
    3232#include "ConsoleCommand.h"
    3333#include "CommandExecutor.h"
    34 #include "Debug.h"
    3534#include "TclThreadManager.h"
    3635#include "TclBind.h"
     36#include "util/Debug.h"
    3737#include "util/String.h"
    3838
    3939namespace orxonox
    4040{
    41     SetConsoleCommandShortcutGeneric(tcl, createConsoleCommand(createFunctor(&TclBind::tcl), "tcl"));
    42     SetConsoleCommandShortcutGeneric(bgerror, createConsoleCommand(createFunctor(&TclBind::bgerror), "bgerror"));
     41    SetConsoleCommandShortcut(TclBind, tcl);
     42    SetConsoleCommandShortcut(TclBind, bgerror);
    4343
    4444    TclBind::TclBind()
     
    115115
    116116        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    117             return CommandExecutor::getLastEvaluation().getReturnvalue().toString();
     117            return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    118118
    119119        return "";
  • code/trunk/src/core/TclThreadManager.cc

    r1505 r1747  
    3838#include "ConsoleCommand.h"
    3939#include "CommandExecutor.h"
    40 #include "Debug.h"
    4140#include "TclBind.h"
    4241#include "TclThreadManager.h"
     42#include "util/Debug.h"
    4343#include "util/Convert.h"
    4444
     
    4848namespace orxonox
    4949{
    50     SetConsoleCommandShortcutGeneric(tclexecute, createConsoleCommand(createFunctor(&TclThreadManager::execute), "tclexecute")).setArgumentCompleter(0, autocompletion::tclthreads());
    51     SetConsoleCommandShortcutGeneric(tclquery,   createConsoleCommand(createFunctor(&TclThreadManager::query),   "tclquery"  )).setArgumentCompleter(0, autocompletion::tclthreads());
     50    SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
     51    SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
    5252    SetConsoleCommand(TclThreadManager, create,  false);
    53     SetConsoleCommand(TclThreadManager, destroy, false).setArgumentCompleter(0, autocompletion::tclthreads());
    54     SetConsoleCommand(TclThreadManager, execute, false).setArgumentCompleter(0, autocompletion::tclthreads());
    55     SetConsoleCommand(TclThreadManager, query,   false).setArgumentCompleter(0, autocompletion::tclthreads());
     53    SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
     54    SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
     55    SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
    5656    SetConsoleCommand(TclThreadManager, status,  false);
    57     SetConsoleCommand(TclThreadManager, dump,    false).setArgumentCompleter(0, autocompletion::tclthreads());
    58     SetConsoleCommand(TclThreadManager, flush,   false).setArgumentCompleter(0, autocompletion::tclthreads());
    59 
    60     TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance();
     57    SetConsoleCommand(TclThreadManager, dump,    false).argumentCompleter(0, autocompletion::tclthreads());
     58    SetConsoleCommand(TclThreadManager, flush,   false).argumentCompleter(0, autocompletion::tclthreads());
    6159
    6260    TclThreadManager::TclThreadManager()
     
    7270        //
    7371#endif
     72    }
     73
     74    TclThreadManager::~TclThreadManager()
     75    {
     76        unsigned int threadID;
     77        {
     78            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
     79            if (this->interpreterBundles_.begin() == this->interpreterBundles_.end())
     80                return;
     81            else
     82                threadID = this->interpreterBundles_.begin()->first;
     83        }
     84        this->destroy(threadID);
    7485    }
    7586
     
    508519
    509520                if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    510                     output = CommandExecutor::getLastEvaluation().getReturnvalue().toString();
     521                    output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    511522            }
    512523
  • code/trunk/src/core/TclThreadManager.h

    r1625 r1747  
    6969    class _CoreExport TclThreadManager : public OrxonoxClass
    7070    {
     71        friend class IRC;
     72        friend class TclBind;
     73
    7174        public:
    7275            static TclThreadManager& getInstance();
     
    8184            static void flush(unsigned int threadID);
    8285
     86            void error(const std::string& error);
     87            void debug(const std::string& error);
     88
     89            virtual void tick(float dt);
     90
     91            std::list<unsigned int> getThreadList() const;
     92
     93        private:
     94            TclThreadManager();
     95            TclThreadManager(const TclThreadManager& other);
     96            ~TclThreadManager();
     97
    8398            static void tcl_execute(Tcl::object const &args);
    8499            static std::string tcl_query(int querierID, Tcl::object const &args);
     
    89104            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
    90105            std::string dumpList(const std::list<unsigned int>& list);
    91             void error(const std::string& error);
    92             void debug(const std::string& error);
    93106
    94107            void pushCommandToQueue(const std::string& command);
     
    105118            std::string evalQuery(unsigned int querierID, const std::string& command);
    106119            std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command);
    107 
    108             virtual void tick(float dt);
    109 
    110             std::list<unsigned int> getThreadList() const;
    111 
    112         private:
    113             TclThreadManager();
    114             TclThreadManager(const TclThreadManager& other);
    115             ~TclThreadManager() {}
    116120
    117121            unsigned int threadCounter_;
  • code/trunk/src/core/XMLPort.h

    r1628 r1747  
    3232#include "CorePrereqs.h"
    3333
     34#include "util/Debug.h"
    3435#include "util/XMLIncludes.h"
    35 #include "util/MultiTypeMath.h"
     36#include "util/MultiType.h"
    3637#include "tinyxml/ticpp.h"
    3738#include "Executor.h"
    38 #include "Debug.h"
    3939#include "CoreIncludes.h"
    4040#include "BaseObject.h"
     
    4242
    4343#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
    44     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), #savefunction), xmlelement, mode)
    45 #define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode) \
    46     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode)
     44    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
     45#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
     46    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
    4747
    4848#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
    49     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
    50 #define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \
    51     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
    52 
    53 #define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
    54     orxonox::XMLPortClassParamContainer<classname>* containername = (orxonox::XMLPortClassParamContainer<classname>*)(this->getIdentifier()->getXMLPortParamContainer(paramname)); \
     49    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
     50#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
     51    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
     52
     53#define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
     54    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
     55#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
     56    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
     57
     58#define XMLPortParamGeneric(containername, classname, objectclass, object, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
     59    orxonox::XMLPortClassParamContainer<objectclass>* containername = (orxonox::XMLPortClassParamContainer<objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortParamContainer(paramname)); \
    5560    if (!containername) \
    5661    { \
    57         containername = new orxonox::XMLPortClassParamContainer<classname>(std::string(paramname), loadexecutor, saveexecutor); \
    58         this->getIdentifier()->addXMLPortParamContainer(paramname, containername); \
     62        containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \
     63        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
    5964    } \
    60     containername->port(this, xmlelement, mode)
     65    containername->port((BaseObject*)this, object, xmlelement, mode)
    6166
    6267
    6368#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    64     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    65 #define XMLPortObject_Template(classname, objectclass, sectionname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    66     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
     69    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
     70#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
     71    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    6772
    6873#define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    69     orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \
     74    orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortObjectContainer(sectionname)); \
    7075    if (!containername) \
    7176    { \
    72         containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \
    73         this->getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \
     77        containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \
     78        ClassIdentifier<classname>::getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \
    7479    } \
    7580    containername->port(this, xmlelement, mode)
     
    102107            virtual const std::string& getDescription() = 0;
    103108
    104             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param) = 0;
    105             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) = 0;
    106             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) = 0;
    107             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) = 0;
    108             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) = 0;
    109             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) = 0;
     109            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
     110            virtual XMLPortParamContainer& defaultValues(const MultiType& param1) = 0;
     111            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) = 0;
     112            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) = 0;
     113            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) = 0;
     114            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) = 0;
    110115
    111116        protected:
    112117            std::string paramname_;
    113118            ParseResult parseResult_;
    114 
     119            Identifier* identifier_;
     120            BaseObject* owner_;
    115121    };
    116122
     
    126132
    127133        public:
    128             XMLPortClassParamContainer(const std::string paramname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
     134            XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
    129135            {
    130136                this->paramname_ = paramname;
     137                this->identifier_ = identifier;
    131138                this->loadexecutor_ = loadexecutor;
    132139                this->saveexecutor_ = saveexecutor;
    133140            }
    134141
    135             XMLPortParamContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
    136             {
     142            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
     143            {
     144                this->owner_ = owner;
    137145                this->parseParams_.object = object;
    138146                this->parseParams_.xmlelement = &xmlelement;
     
    146154                        if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet()))
    147155                        {
    148                             COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")." << std::endl << ((BaseObject*)object)->getLoaderIndentation();
     156                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    149157                            if (this->loadexecutor_->parse(object, attribute, ","))
    150158                                this->parseResult_ = PR_finished;
     
    158166                    {
    159167                        COUT(1) << std::endl;
    160                         COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << ((BaseObject*)object)->getLevelfile() << ":" << std::endl;
     168                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getLevelfile() << ":" << std::endl;
    161169                        COUT(1) << ex.what() << std::endl;
    162170                    }
     
    173181            }
    174182
    175             XMLPortParamContainer& port(const ParseParams& parseParams)
    176             {
    177                 return this->port(parseParams.object, *parseParams.xmlelement, parseParams.mode);
     183            XMLPortParamContainer& port(BaseObject* owner, const ParseParams& parseParams)
     184            {
     185                return this->port(owner, parseParams.object, *parseParams.xmlelement, parseParams.mode);
    178186            }
    179187
     
    181189            {
    182190                if (result == PR_waiting_for_default_values)
    183                     return this->port(params);
     191                    return this->port(this->owner_, params);
    184192                else
    185193                    return (*this);
     
    191199                { return this->loadexecutor_->getDescription(); }
    192200
    193             virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param)
     201            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
    194202            {
    195203                if (!this->loadexecutor_->defaultValueSet(index))
     
    197205                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    198206            }
    199             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1)
     207            virtual XMLPortParamContainer& defaultValues(const MultiType& param1)
    200208            {
    201209                if (!this->loadexecutor_->defaultValueSet(0))
     
    203211                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    204212            }
    205             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     213            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2)
    206214            {
    207215                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)))
     
    209217                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    210218            }
    211             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     219            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
    212220            {
    213221                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)))
     
    215223                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    216224            }
    217             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     225            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
    218226            {
    219227                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)))
     
    221229                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    222230            }
    223             virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     231            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    224232            {
    225233                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4)))
     
    257265            bool bApplyLoaderMask_;
    258266            bool bLoadBefore_;
     267            Identifier* identifier_;
    259268    };
    260269
     
    263272    {
    264273        public:
    265             XMLPortClassObjectContainer(const std::string sectionname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
     274            XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
    266275            {
    267276                this->sectionname_ = sectionname;
     277                this->identifier_ = identifier;
    268278                this->loadexecutor_ = loadexecutor;
    269279                this->saveexecutor_ = saveexecutor;
     
    305315                                            {
    306316                                                newObject->XMLPort(*child, XMLPort::LoadObject);
    307                                                 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     317                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
    308318                                            }
    309319                                            else
    310320                                            {
    311                                                 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
     321                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
    312322                                            }
    313323
     
    336346                    {
    337347                        COUT(1) << std::endl;
    338                         COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getLevelfile() << ":" << std::endl;
     348                        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->getLevelfile() << ":" << std::endl;
    339349                        COUT(1) << ex.what() << std::endl;
    340350                    }
  • code/trunk/src/core/input/Button.cc

    r1535 r1747  
    3636#include "util/SubString.h"
    3737#include "util/String.h"
    38 #include "core/Debug.h"
     38#include "util/Debug.h"
    3939#include "core/ConsoleCommand.h"
    4040#include "core/CommandEvaluation.h"
  • code/trunk/src/core/input/InputManager.cc

    r1735 r1747  
    3939#include "core/CoreIncludes.h"
    4040#include "core/ConfigValueIncludes.h"
    41 #include "core/Debug.h"
    4241#include "core/CommandExecutor.h"
    4342#include "core/ConsoleCommand.h"
    4443#include "core/Shell.h"               // hack!
     44#include "util/Debug.h"
    4545
    4646#include "InputBuffer.h"
     
    321321    if (joySticksSize_)
    322322    {
    323       std::vector<MultiTypeMath> coeffPos;
    324       std::vector<MultiTypeMath> coeffNeg;
    325       std::vector<MultiTypeMath> zero;
     323      std::vector<double> coeffPos;
     324      std::vector<double> coeffNeg;
     325      std::vector<int> zero;
    326326      coeffPos.resize(24);
    327327      coeffNeg.resize(24);
     
    340340          getIdentifier()->addConfigValueContainer("CoeffPos", cont);
    341341      }
    342       cont->getValue(&coeffPos);
     342      cont->getValue(&coeffPos, this);
    343343
    344344      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
     
    348348          getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
    349349      }
    350       cont->getValue(&coeffNeg);
     350      cont->getValue(&coeffNeg, this);
    351351
    352352      cont = getIdentifier()->getConfigValueContainer("Zero");
     
    356356          getIdentifier()->addConfigValueContainer("Zero", cont);
    357357      }
    358       cont->getValue(&zero);
     358      cont->getValue(&zero, this);
    359359
    360360      // copy values to our own variables
  • code/trunk/src/core/input/KeyBinder.cc

    r1567 r1747  
    3636#include <string>
    3737#include "util/Convert.h"
    38 #include "core/Debug.h"
     38#include "util/Debug.h"
    3939#include "core/ConfigValueIncludes.h"
    4040#include "core/CoreIncludes.h"
     
    216216    if (!infile)
    217217    {
    218       ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "def_keybindings.ini");
    219       ConfigFileManager::getSingleton()->save(CFT_Keybindings, "keybindings.ini");
     218      ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "def_keybindings.ini");
     219      ConfigFileManager::getInstance()->save(CFT_Keybindings, "keybindings.ini");
    220220    }
    221221    else
    222222      infile.close();
    223     ConfigFileManager::getSingleton()->setFile(CFT_Keybindings, "keybindings.ini");
     223    ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "keybindings.ini");
    224224
    225225    // parse key bindings
     
    234234  void KeyBinder::setConfigValues()
    235235  {
    236     SetConfigValueGeneric(KeyBinder, analogThreshold_, 0.05f)  .description("Threshold for analog axes until which the state is 0.");
    237     SetConfigValueGeneric(KeyBinder, mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
    238     SetConfigValueGeneric(KeyBinder, bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
    239     SetConfigValueGeneric(KeyBinder, derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
    240     SetConfigValueGeneric(KeyBinder, mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
    241     SetConfigValueGeneric(KeyBinder, bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
     236    SetConfigValue(analogThreshold_, 0.05f)  .description("Threshold for analog axes until which the state is 0.");
     237    SetConfigValue(mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
     238    SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
     239    SetConfigValue(derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
     240    SetConfigValue(mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
     241    SetConfigValue(bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
    242242
    243243    float oldThresh = buttonThreshold_;
    244     SetConfigValueGeneric(KeyBinder, buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
     244    SetConfigValue(buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
    245245    if (oldThresh != buttonThreshold_)
    246246      for (unsigned int i = 0; i < nHalfAxes_s; i++)
     
    268268    if (!cont)
    269269    {
    270       cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "");
     270      cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "", button.name_);
    271271      ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
    272272    }
    273273    std::string old = button.bindingString_;
    274     cont->getValue(&button.bindingString_);
     274    cont->getValue(&button.bindingString_, this);
    275275
    276276    // keybinder stuff
  • code/trunk/src/core/input/KeyDetector.cc

    r1535 r1747  
    3333
    3434#include "KeyDetector.h"
    35 #include "core/Debug.h"
     35#include "util/Debug.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/CommandExecutor.h"
Note: See TracChangeset for help on using the changeset viewer.