Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 947


Ignore:
Timestamp:
Mar 28, 2008, 10:13:58 PM (16 years ago)
Author:
landauf
Message:
  • added CommandExecutor
  • added ConsoleCommand macros
  • added getTypename to all MultiTypes
  • added 2 static maps to Identifier that contain all existing Identifiers with their names and lowercase names respectively.
  • added 2 maps to each Identifier that contain all console commands of the Identifier with their names and lowercase names respectively
  • using tolower(.) and toupper(.) instead of selfmade hacks in String.h
  • added AccessLevel enum
  • added some test-console-commands to OutputHandler, Ambient and SpaceShip
Location:
code/branches/core2/src
Files:
3 added
24 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/CMakeLists.txt

    r895 r947  
    1919  Namespace.cc
    2020  NamespaceNode.cc
     21  CommandExecutor.cc
    2122)
    2223
  • code/branches/core2/src/orxonox/core/ConfigValueContainer.cc

    r871 r947  
    181181        @return True if the string was successfully parsed
    182182    */
    183     bool ConfigValueContainer::parseString(const std::string& input, MultiTypeMath& defvalue)
     183    bool ConfigValueContainer::parseString(const std::string& input, const MultiTypeMath& defvalue)
    184184    {
    185185        if (defvalue.getType() == MT_int)
  • code/branches/core2/src/orxonox/core/ConfigValueContainer.h

    r871 r947  
    102102            const std::string& getDescription() const;
    103103
    104             bool parseString(const std::string& input, MultiTypeMath& defvalue);
     104            bool parseString(const std::string& input, const MultiTypeMath& defvalue = MT_null);
    105105            bool valueToString(std::string* output, MultiTypeMath& input);
    106106            void resetConfigFileEntry();
     
    110110            static bool isEmpty(const std::string& line);
    111111            static bool isComment(const std::string& line);
     112
     113            inline std::string getTypename() const
     114                { return this->value_.getTypename(); }
    112115
    113116        private:
  • code/branches/core2/src/orxonox/core/CorePrereqs.h

    r902 r947  
    9191  class ClassTreeMaskIterator;
    9292  class ClassTreeMaskNode;
     93  class CommandExecutor;
    9394  class ConfigValueContainer;
    9495  class DebugLevel;
    9596  class Error;
    9697  class Executor;
     98  template <class T>
     99  class ExecutorMember;
     100  class ExecutorStatic;
    97101  class Factory;
     102  class Functor;
     103  template <class T>
     104  class FunctorMember;
     105  class FunctorStatic;
    98106  class Identifier;
    99107  class IdentifierDistributor;
  • code/branches/core2/src/orxonox/core/DebugLevel.cc

    r871 r947  
    9595
    9696        // Return a constant value while we're creating the object
    97         return 4;
     97        return 5;
    9898    }
    9999}
  • code/branches/core2/src/orxonox/core/Executor.cc

    r939 r947  
    3232namespace orxonox
    3333{
    34     Executor::Executor(Functor* functor, const std::string& name)
     34    Executor::Executor(Functor* functor, const std::string& name, AccessLevel::Level level)
    3535    {
    3636        this->functor_ = functor;
    3737        this->name_ = name;
     38        this->accessLevel_ = level;
     39
    3840        this->bAddedDescription_ = false;
    3941        this->bAddedDescriptionReturnvalue_ = false;
     
    6062    {
    6163        EXECUTOR_PARSE(normal);
    62     }
    63 
    64     void Executor::setName(const std::string name)
    65     {
    66         this->name_ = name;
    67     }
    68 
    69     const std::string& Executor::getName() const
    70     {
    71         return this->name_;
    7264    }
    7365
  • code/branches/core2/src/orxonox/core/Executor.h

    r939 r947  
    129129    return true
    130130
     131namespace AccessLevel
     132{
     133    enum Level
     134    {
     135        None,
     136        User,
     137        Admin,
     138        Offline,
     139        Debug,
     140        Disabled
     141    };
     142}
    131143
    132144namespace orxonox
     
    135147    {
    136148        public:
    137             Executor(Functor* functor, const std::string& name = "");
     149            Executor(Functor* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None);
    138150            virtual ~Executor();
    139151
     
    153165            bool parse(const std::string& params, const std::string& delimiter = " ") const;
    154166
    155             void setName(const std::string name);
    156             const std::string& getName() const;
    157 
    158167            void setDescription(const std::string& description);
    159168            const std::string& getDescription() const;
     
    165174            const std::string& getDescriptionReturnvalue(int param) const;
    166175
    167             inline int getParamCount() const
     176            inline unsigned int getParamCount() const
    168177                { return this->functor_->getParamCount(); }
    169178            inline bool hasReturnvalue() const
     
    173182            inline MultiTypeMath getReturnvalue() const
    174183                { return this->functor_->getReturnvalue(); }
    175             inline std::string getTypenameParam(int param) const
     184            inline std::string getTypenameParam(unsigned int param) const
    176185                { return this->functor_->getTypenameParam(param); }
    177186            inline std::string getTypenameReturnvalue() const
    178187                { return this->functor_->getTypenameReturnvalue(); }
     188
     189            inline void setName(const std::string name)
     190                { this->name_ = name; }
     191            inline const std::string& getName() const
     192                { return this->name_; }
     193
     194            inline void setAccessLevel(AccessLevel::Level level)
     195                { this->accessLevel_ = level; }
     196            inline AccessLevel::Level getAccessLevel() const
     197                { return this->accessLevel_; }
    179198
    180199            void setDefaultValues(const MultiTypeMath& param1);
     
    186205
    187206            bool allDefaultValuesSet() const;
     207            inline bool defaultValueSet(unsigned int index) const
     208            {
     209                if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
     210                    return this->bAddedDefaultValue_[index];
     211
     212                return false;
     213            }
    188214
    189215        protected:
     
    201227            bool bAddedDescriptionReturnvalue_;
    202228            bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS];
     229
     230            AccessLevel::Level accessLevel_;
    203231    };
    204232
     
    206234    {
    207235        public:
    208             ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
     236            ExecutorStatic(FunctorStatic* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {}
    209237            virtual ~ExecutorStatic() {}
    210238    };
     
    214242    {
    215243        public:
    216             ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
     244            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {}
    217245            virtual ~ExecutorMember() {}
    218246
     
    260288    };
    261289
    262     inline Executor* createExecutor(Functor* functor, const std::string& name = "")
    263     {
    264         return new Executor(functor, name);
     290    inline Executor* createExecutor(Functor* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None)
     291    {
     292        return new Executor(functor, name, level);
    265293    }
    266294
    267295    template <class T>
    268     inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "")
    269     {
    270         return new ExecutorMember<T>(functor, name);
     296    inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None)
     297    {
     298        return new ExecutorMember<T>(functor, name, level);
    271299    }
    272300
    273     inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "")
    274     {
    275         return new ExecutorStatic(functor, name);
     301    inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None)
     302    {
     303        return new ExecutorStatic(functor, name, level);
    276304    }
    277305}
  • code/branches/core2/src/orxonox/core/Functor.h

    r931 r947  
    3737#define MAX_FUNCTOR_ARGUMENTS 5
    3838
    39 enum FunctionType
     39namespace orxonox
    4040{
    41     FT_MEMBER,
    42     FT_CONSTMEMBER,
    43     FT_STATIC
    44 };
    45 
    46 
    47 template <class T>
    48 inline std::string typeToString();
     41    enum FunctionType
     42    {
     43        FT_MEMBER,
     44        FT_CONSTMEMBER,
     45        FT_STATIC
     46    };
     47
     48
     49    template <class T>
     50    inline std::string typeToString() { return "unknown"; }
    4951
    5052#define CreateTypeToStringTemplate(type) \
     
    5254    inline std::string typeToString<type>() { return #type; }
    5355
    54 CreateTypeToStringTemplate(int);
    55 CreateTypeToStringTemplate(unsigned int);
    56 CreateTypeToStringTemplate(char);
    57 CreateTypeToStringTemplate(unsigned char);
    58 CreateTypeToStringTemplate(short);
    59 CreateTypeToStringTemplate(unsigned short);
    60 CreateTypeToStringTemplate(long);
    61 CreateTypeToStringTemplate(unsigned long);
    62 CreateTypeToStringTemplate(float);
    63 CreateTypeToStringTemplate(double);
    64 CreateTypeToStringTemplate(long double);
    65 CreateTypeToStringTemplate(bool);
    66 CreateTypeToStringTemplate(std::string);
    67 CreateTypeToStringTemplate(orxonox::Vector2);
    68 CreateTypeToStringTemplate(orxonox::Vector3);
    69 CreateTypeToStringTemplate(orxonox::Quaternion);
    70 CreateTypeToStringTemplate(orxonox::ColourValue);
    71 CreateTypeToStringTemplate(orxonox::Radian);
    72 CreateTypeToStringTemplate(orxonox::Degree);
    73 
    74 
    75 class _CoreExport Functor
    76 {
    77     public:
    78         Functor() {}
    79         virtual ~Functor() {}
    80 
    81         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;
    82 
    83         inline unsigned int getParamCount() const { return this->numParams_; }
    84         inline bool hasReturnvalue() const { return this->hasReturnValue_; }
    85         inline FunctionType getType() const { return this->type_; }
    86         inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; }
    87 
    88         std::string getTypenameParam(int param) const { return (param > 0 && param <= 5) ? this->typeParam_[param-1] : ""; }
    89         std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; }
    90 
    91     protected:
    92         unsigned int numParams_;
    93         bool hasReturnValue_;
    94         FunctionType type_;
    95         MultiTypeMath returnedValue_;
    96 
    97         std::string typeReturnvalue_;
    98         std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
    99 };
    100 
    101 class _CoreExport FunctorStatic : public Functor
    102 {
    103     public:
    104         virtual ~FunctorStatic() {}
    105         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;
    106 };
    107 
    108 template <class T>
    109 class FunctorMember : public Functor
    110 {
    111     public:
    112         FunctorMember()
    113         {
    114             constObject_ = 0;
    115             object_ = 0;
    116             bConstObject_ = false;
    117         }
    118         virtual ~FunctorMember() {}
    119 
    120         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;
    121         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;
    122 
    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)
    124         {
    125             if (this->bConstObject_)
     56    CreateTypeToStringTemplate(int);
     57    CreateTypeToStringTemplate(unsigned int);
     58    CreateTypeToStringTemplate(char);
     59    CreateTypeToStringTemplate(unsigned char);
     60    CreateTypeToStringTemplate(short);
     61    CreateTypeToStringTemplate(unsigned short);
     62    CreateTypeToStringTemplate(long);
     63    CreateTypeToStringTemplate(unsigned long);
     64    CreateTypeToStringTemplate(float);
     65    CreateTypeToStringTemplate(double);
     66    CreateTypeToStringTemplate(long double);
     67    CreateTypeToStringTemplate(bool);
     68    CreateTypeToStringTemplate(std::string);
     69    CreateTypeToStringTemplate(orxonox::Vector2);
     70    CreateTypeToStringTemplate(orxonox::Vector3);
     71    CreateTypeToStringTemplate(orxonox::Quaternion);
     72    CreateTypeToStringTemplate(orxonox::ColourValue);
     73    CreateTypeToStringTemplate(orxonox::Radian);
     74    CreateTypeToStringTemplate(orxonox::Degree);
     75
     76
     77    class _CoreExport Functor
     78    {
     79        public:
     80            Functor() {}
     81            virtual ~Functor() {}
     82
     83            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;
     84
     85            inline unsigned int getParamCount() const { return this->numParams_; }
     86            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
     87            inline FunctionType getType() const { return this->type_; }
     88            inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; }
     89
     90            std::string getTypenameParam(unsigned int param) const { return (param > 0 && param <= 5) ? this->typeParam_[param-1] : ""; }
     91            std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; }
     92
     93        protected:
     94            unsigned int numParams_;
     95            bool hasReturnValue_;
     96            FunctionType type_;
     97            MultiTypeMath returnedValue_;
     98
     99            std::string typeReturnvalue_;
     100            std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
     101    };
     102
     103    class _CoreExport FunctorStatic : public Functor
     104    {
     105        public:
     106            virtual ~FunctorStatic() {}
     107            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;
     108    };
     109
     110    template <class T>
     111    class FunctorMember : public Functor
     112    {
     113        public:
     114            FunctorMember()
    126115            {
    127                 if (this->constObject_)
    128                     (*this)(this->constObject_, param1, param2, param3, param4, param5);
     116                constObject_ = 0;
     117                object_ = 0;
     118                bConstObject_ = false;
     119            }
     120            virtual ~FunctorMember() {}
     121
     122            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;
     123            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;
     124
     125            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)
     126            {
     127                if (this->bConstObject_)
     128                {
     129                    if (this->constObject_)
     130                        (*this)(this->constObject_, param1, param2, param3, param4, param5);
     131                    else
     132                    {
     133                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
     134                        COUT(1) << "Error: No const object set." << std::endl;
     135                    }
     136                }
    129137                else
    130138                {
    131                     COUT(1) << "An error occurred in Functor.h:" << std::endl;
    132                     COUT(1) << "Error: No const object set." << std::endl;
     139                    if (this->object_)
     140                        (*this)(this->object_, param1, param2, param3, param4, param5);
     141                    else
     142                    {
     143                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
     144                        COUT(1) << "Error: No object set." << std::endl;
     145                    }
    133146                }
    134147            }
    135             else
     148
     149            void setObject(T* object)
    136150            {
    137                 if (this->object_)
    138                     (*this)(this->object_, param1, param2, param3, param4, param5);
    139                 else
    140                 {
    141                     COUT(1) << "An error occurred in Functor.h:" << std::endl;
    142                     COUT(1) << "Error: No object set." << std::endl;
    143                 }
     151                this->bConstObject_ = false;
     152                this->object_ = object;
    144153            }
    145         }
    146 
    147         void setObject(T* object)
    148         {
    149             this->bConstObject_ = false;
    150             this->object_ = object;
    151         }
    152 
    153         void setObject(const T* object)
    154         {
    155             this->bConstObject_ = true;
    156             this->constObject_ = object;
    157         }
    158 
    159     private:
    160         const T* constObject_;
    161         T* object_;
    162         bool bConstObject_;
    163 };
     154
     155            void setObject(const T* object)
     156            {
     157                this->bConstObject_ = true;
     158                this->constObject_ = object;
     159            }
     160
     161        private:
     162            const T* constObject_;
     163            T* object_;
     164            bool bConstObject_;
     165    };
    164166
    165167
     
    403405
    404406
    405 CREATE_ALL_STATIC_FUNCTORS();
    406 CREATE_ALL_MEMBER_FUNCTORS();
     407    CREATE_ALL_STATIC_FUNCTORS();
     408    CREATE_ALL_MEMBER_FUNCTORS();
     409}
    407410
    408411#endif /* _Functor_H__ */
  • code/branches/core2/src/orxonox/core/Identifier.cc

    r876 r947  
    3535#include "Identifier.h"
    3636#include "Factory.h"
     37#include "Executor.h"
     38#include "CommandExecutor.h"
    3739
    3840namespace orxonox
     
    5052        this->bCreatedOneObject_ = false;
    5153        this->factory_ = 0;
     54
     55        this->bHasConfigValues_ = false;
     56        this->bHasConsoleCommands_ = false;
    5257
    5358        this->children_ = new std::set<const Identifier*>();
     
    198203
    199204    /**
     205        @brief Returns the map that stores all Identifiers.
     206        @return The map
     207    */
     208    std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
     209    {
     210        static std::map<std::string, Identifier*> identifierMap;
     211        return identifierMap;
     212    }
     213
     214    /**
     215        @brief Returns the map that stores all Identifiers.
     216        @return The map
     217    */
     218    std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
     219    {
     220        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
     221        return lowercaseIdentifierMap;
     222    }
     223
     224    /**
     225        @brief Adds the ConfigValueContainer of a variable, given by the string of its name.
     226        @param varname The name of the variablee
     227        @param container The container
     228    */
     229    void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
     230    {
     231        this->bHasConfigValues_ = true;
     232        this->configValues_[varname] = container;
     233        this->configValues_LC_[getLowercase(varname)] = container;
     234    }
     235
     236    /**
    200237        @brief Returns the ConfigValueContainer of a variable, given by the string of its name.
    201238        @param varname The name of the variable
     
    212249
    213250    /**
    214         @brief Adds the ConfigValueContainer of a variable, given by the string of its name.
    215         @param varname The name of the variablee
    216         @param container The container
    217     */
    218     void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
    219     {
    220         this->configValues_[varname] = container;
    221     }
    222 
     251        @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase.
     252        @param varname The name of the variable in lowercase
     253        @return The ConfigValueContainer
     254    */
     255    ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname)
     256    {
     257        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
     258        if (it != configValues_LC_.end())
     259            return ((*it).second);
     260        else
     261            return 0;
     262    }
     263
     264    /**
     265        @brief Adds a new console command of this class.
     266        @param executor The executor of the command
     267        @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
     268        @return The executor of the command
     269    */
     270    ExecutorStatic& Identifier::addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut)
     271    {
     272        this->bHasConsoleCommands_ = true;
     273        this->consoleCommands_[executor->getName()] = executor;
     274        this->consoleCommands_LC_[getLowercase(executor->getName())] = executor;
     275
     276        if (bCreateShortcut)
     277            CommandExecutor::addConsoleCommandShortcut(executor);
     278
     279        return (*executor);
     280    }
     281
     282    /**
     283        @brief Returns the executor of a console command with given name.
     284        @brief name The name of the requested console command
     285        @return The executor of the requested console command
     286    */
     287    ExecutorStatic* Identifier::getConsoleCommand(const std::string& name) const
     288    {
     289        std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_.find(name);
     290        if (it != this->consoleCommands_.end())
     291            return (*it).second;
     292        else
     293            return 0;
     294    }
     295
     296    /**
     297        @brief Returns the executor of a console command with given name in lowercase.
     298        @brief name The name of the requested console command in lowercae
     299        @return The executor of the requested console command
     300    */
     301    ExecutorStatic* Identifier::getLowercaseConsoleCommand(const std::string& name) const
     302    {
     303        std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_LC_.find(name);
     304        if (it != this->consoleCommands_LC_.end())
     305            return (*it).second;
     306        else
     307            return 0;
     308    }
     309
     310    /**
     311        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
     312        @param out The outstream
     313        @param list The list (or set) of Identifiers
     314        @return The outstream
     315    */
    223316    std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list)
    224317    {
  • code/branches/core2/src/orxonox/core/Identifier.h

    r941 r947  
    6262#include "Debug.h"
    6363#include "Iterator.h"
     64#include "util/String.h"
    6465
    6566namespace orxonox
     
    114115            inline const std::string& getName() const { return this->name_; }
    115116
     117
    116118            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
    117119            inline const std::set<const Identifier*>& getParents() const { return this->parents_; }
     
    142144            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
    143145
     146
     147            /** @brief Returns the map that stores all Identifiers. @return The map */
     148            static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); }
     149            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */
     150            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); }
     151            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */
     152            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); }
     153
     154            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
     155            static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }
     156            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
     157            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }
     158            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
     159            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); }
     160
     161
     162            /** @brief Returns the map that stores all config values. @return The const_iterator */
     163            inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; }
     164            /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */
     165            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); }
     166            /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */
     167            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); }
     168
     169            /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */
     170            inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; }
     171            /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */
     172            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); }
     173            /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */
     174            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
     175
     176
     177            /** @brief Returns the map that stores all console commands. @return The const_iterator */
     178            inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandMap() const { return this->consoleCommands_; }
     179            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
     180            inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }
     181            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
     182            inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }
     183
     184            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
     185            inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }
     186            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
     187            inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }
     188            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
     189            inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
     190
     191
     192            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
     193            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
     194            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
     195            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
     196
    144197            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
    145198            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
     
    151204            void setNetworkID(unsigned int id);
    152205
     206            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    153207            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
    154             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    155 
     208            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
     209
     210            virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
    156211            virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0;
    157             virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;
    158 
     212
     213            virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;
    159214            virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0;
    160             virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;
     215
     216            ExecutorStatic& addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut);
     217            ExecutorStatic* getConsoleCommand(const std::string& name) const;
     218            ExecutorStatic* getLowercaseConsoleCommand(const std::string& name) const;
     219
     220        protected:
     221            /** @brief Returns the map that stores all Identifiers. @return The map */
     222            static std::map<std::string, Identifier*>& getIdentifierMapIntern();
     223            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
     224            static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
    161225
    162226        private:
     
    189253            }
    190254
    191             std::set<const Identifier*> parents_;                      //!< The parents of the class the Identifier belongs to
    192             std::set<const Identifier*>* children_;                    //!< The children of the class the Identifier belongs to
    193 
    194             std::set<const Identifier*> directParents_;                //!< The direct parents of the class the Identifier belongs to
    195             std::set<const Identifier*>* directChildren_;              //!< The direct children of the class the Identifier belongs to
    196 
    197             std::string name_;                                          //!< The name of the class the Identifier belongs to
    198 
    199             BaseFactory* factory_;                                      //!< The Factory, able to create new objects of the given class (if available)
    200             bool bCreatedOneObject_;                                    //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
    201             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)
    202             unsigned int classID_;                                      //!< The network ID to identify a class through the network
    203             std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer
     255            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
     256            std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
     257
     258            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
     259            std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
     260
     261            std::string name_;                                             //!< The name of the class the Identifier belongs to
     262
     263            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
     264            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     265            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)
     266            unsigned int classID_;                                         //!< The network ID to identify a class through the network
     267
     268            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
     269            std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
     270            std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer
     271
     272            bool bHasConsoleCommands_;                                     //!< True if this class has at least one assigned console command
     273            std::map<std::string, ExecutorStatic*> consoleCommands_;       //!< All console commands of this class
     274            std::map<std::string, ExecutorStatic*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
    204275    };
    205276
     
    246317            ~ClassIdentifier() {}                                       // don't delete
    247318
    248             ObjectList<T>* objects_;    //!< The ObjectList, containing all objects of type T
    249             bool bSetName_;             //!< True if the name is set
    250             std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;
    251             std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;
     319            ObjectList<T>* objects_;                                                                    //!< The ObjectList, containing all objects of type T
     320            bool bSetName_;                                                                             //!< True if the name is set
     321            std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;              //!< All loadable parameters
     322            std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;   //!< All attachable objects
    252323    };
    253324
     
    300371            this->name_ = name;
    301372            this->bSetName_ = true;
     373            Identifier::getIdentifierMapIntern()[name] = this;
     374            Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
    302375        }
    303376    }
     
    324397    }
    325398
     399    /**
     400        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
     401        @param paramname The name of the parameter
     402        @return The container
     403    */
    326404    template <class T>
    327405    XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname)
     
    334412    }
    335413
     414    /**
     415        @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
     416        @param paramname The name of the parameter
     417        @param container The container
     418    */
    336419    template <class T>
    337420    void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
     
    340423    }
    341424
     425    /**
     426        @brief Returns a XMLPortObjectContainer that attaches an object to this class.
     427        @param sectionname The name of the section that contains the attachable objects
     428        @return The container
     429    */
    342430    template <class T>
    343431    XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname)
     
    350438    }
    351439
     440    /**
     441        @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
     442        @param sectionname The name of the section that contains the attachable objects
     443        @param container The container
     444    */
    352445    template <class T>
    353446    void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
  • code/branches/core2/src/orxonox/core/OutputHandler.cc

    r871 r947  
    3333#include "DebugLevel.h"
    3434#include "OutputHandler.h"
     35#include "ConsoleCommand.h"
    3536
    3637namespace orxonox
    3738{
     39    ConsoleCommandShortcutGeneric(log, createExecutor(createFunctor(&OutputHandler::log), "log", AccessLevel::None));
     40
    3841    /**
    3942        @brief Constructor: Opens the logfile and writes the first line.
  • code/branches/core2/src/orxonox/core/OutputHandler.h

    r871 r947  
    5858
    5959            static OutputHandler& getOutStream();
     60
     61            /** @brief Puts some text on the outstream. @param text The text */
     62            static inline void log(const std::string& text)
     63                { OutputHandler::getOutStream().output(text); }
    6064
    6165            /** @brief Returns a reference to the logfile. @return The logfile */
  • code/branches/core2/src/orxonox/core/XMLPort.h

    r933 r947  
    4242
    4343#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
    44     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #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)
    4545#define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode) \
    46     XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #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)
    4747
    4848#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
    49     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
     49    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
    5050#define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \
    51     XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
     51    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode)
    5252
    5353#define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
     
    6262
    6363#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    64     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #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)
    6565#define XMLPortObject_Template(classname, objectclass, sectionname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
    66     XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #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)
    6767
    6868#define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
     
    143143                this->loadexecutor_ = loadexecutor;
    144144                this->saveexecutor_ = saveexecutor;
    145 
    146                 this->setDefaultValue_[0] = false;
    147                 this->setDefaultValue_[1] = false;
    148                 this->setDefaultValue_[2] = false;
    149                 this->setDefaultValue_[3] = false;
    150                 this->setDefaultValue_[4] = false;
    151145            }
    152146
     
    209203            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param)
    210204            {
    211                 if (!this->setDefaultValue_[index])
    212                 {
    213                     this->setDefaultValue_[index] = true;
     205                if (!this->loadexecutor_->defaultValueSet(index))
    214206                    this->loadexecutor_->setDefaultValue(index, param);
    215                 }
    216207                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    217208            }
    218209            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1)
    219210            {
    220                 if (!this->setDefaultValue_[0])
    221                 {
    222                     this->setDefaultValue_[0] = true;
     211                if (!this->loadexecutor_->defaultValueSet(0))
    223212                    this->loadexecutor_->setDefaultValues(param1);
    224                 }
    225213                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    226214            }
    227215            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
    228216            {
    229                 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]))
    230                 {
    231                     this->setDefaultValue_[0] = true;
    232                     this->setDefaultValue_[1] = true;
     217                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)))
    233218                    this->loadexecutor_->setDefaultValues(param1, param2);
    234                 }
    235219                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    236220            }
    237221            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
    238222            {
    239                 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]))
    240                 {
    241                     this->setDefaultValue_[0] = true;
    242                     this->setDefaultValue_[1] = true;
    243                     this->setDefaultValue_[3] = true;
     223                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)))
    244224                    this->loadexecutor_->setDefaultValues(param1, param2, param3);
    245                 }
    246225                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    247226            }
    248227            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
    249228            {
    250                 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3]))
    251                 {
    252                     this->setDefaultValue_[0] = true;
    253                     this->setDefaultValue_[1] = true;
    254                     this->setDefaultValue_[3] = true;
    255                     this->setDefaultValue_[4] = true;
     229                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)))
    256230                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4);
    257                 }
    258231                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    259232            }
    260233            virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
    261234            {
    262                 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3]) || (!this->setDefaultValue_[4]))
    263                 {
    264                     this->setDefaultValue_[0] = true;
    265                     this->setDefaultValue_[1] = true;
    266                     this->setDefaultValue_[3] = true;
    267                     this->setDefaultValue_[4] = true;
    268                     this->setDefaultValue_[5] = true;
     235                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4)))
    269236                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4, param5);
    270                 }
    271237                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
    272238            }
     
    276242            ExecutorMember<T>* saveexecutor_;
    277243            ParseParams parseParams_;
    278             bool setDefaultValue_[5];
    279244    };
    280245
  • code/branches/core2/src/orxonox/objects/Ambient.cc

    r902 r947  
    4141#include "../Orxonox.h"
    4242#include "core/XMLPort.h"
     43#include "core/ConsoleCommand.h"
    4344
    4445#include "Ambient.h"
     
    4647namespace orxonox
    4748{
     49    ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false);
     50
    4851    CreateFactory(Ambient);
     52
     53    Ambient* Ambient::instance_s;
    4954
    5055    Ambient::Ambient()
    5156    {
    5257        RegisterObject(Ambient);
     58        Ambient::instance_s = this;
    5359    }
    5460
  • code/branches/core2/src/orxonox/objects/Ambient.h

    r902 r947  
    1818            void setAmbientLight(const ColourValue& colour);
    1919
     20            static void setAmbientLightTest(const ColourValue& colour)
     21                { Ambient::instance_s->setAmbientLight(colour); }
     22
    2023        private:
    21 
     24            static Ambient* instance_s;
    2225
    2326    };
  • code/branches/core2/src/orxonox/objects/SpaceShip.cc

    r902 r947  
    4545#include "Projectile.h"
    4646#include "core/XMLPort.h"
     47#include "core/ConsoleCommand.h"
    4748
    4849#include "SpaceShip.h"
     
    5051namespace orxonox
    5152{
     53    ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false);
     54
    5255    CreateFactory(SpaceShip);
    5356
     57    SpaceShip* SpaceShip::instance_s;
     58
    5459    SpaceShip::SpaceShip()
    5560    {
    5661        RegisterObject(SpaceShip);
     62
     63        SpaceShip::instance_s = this;
    5764
    5865        this->setConfigValues();
  • code/branches/core2/src/orxonox/objects/SpaceShip.h

    r902 r947  
    3636            void setRotDamp(float value);
    3737
     38            static void setMaxSpeedTest(float value)
     39                { SpaceShip::instance_s->setMaxSpeed(value); }
     40
    3841            bool mouseMoved(const OIS::MouseEvent &e);
    3942            bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
     
    4245
    4346        private:
     47            static SpaceShip* instance_s;
     48
    4449            Vector3 testvector_;
    4550            bool bInvertYAxis_;
  • code/branches/core2/src/util/MultiTypeMath.cc

    r933 r947  
    144144}
    145145
     146std::string MultiTypeMath::getTypename() const
     147{
     148    if (this->type_ == MT_vector2)
     149        return "Vector2";
     150    else if (this->type_ == MT_vector3)
     151        return "Vector3";
     152    else if (this->type_ == MT_colourvalue)
     153        return "ColourValue";
     154    else if (this->type_ == MT_quaternion)
     155        return "Quaternion";
     156    else if (this->type_ == MT_radian)
     157        return "Radian";
     158    else if (this->type_ == MT_degree)
     159        return "Degree";
     160    else
     161        return MultiTypeString::getTypename();
     162}
     163
    146164std::string MultiTypeMath::toString() const
    147165{
  • code/branches/core2/src/util/MultiTypeMath.h

    r933 r947  
    145145        inline void getValue(orxonox::Degree*      variable) const { (*variable) = orxonox::Degree      (this->degree_);      }
    146146
     147        virtual std::string getTypename() const;
     148
    147149        virtual std::string toString() const;
    148150        virtual bool fromString(const std::string value);
  • code/branches/core2/src/util/MultiTypePrimitive.cc

    r933 r947  
    167167}
    168168
     169std::string MultiTypePrimitive::getTypename() const
     170{
     171    if (this->type_ == MT_void)
     172        return "pointer";
     173    else if (this->type_ == MT_int)
     174        return "int";
     175    else if (this->type_ == MT_uint)
     176        return "unsigned int";
     177    else if (this->type_ == MT_char)
     178        return "char";
     179    else if (this->type_ == MT_uchar)
     180        return "unsigned char";
     181    else if (this->type_ == MT_short)
     182        return "short";
     183    else if (this->type_ == MT_ushort)
     184        return "unsigned short";
     185    else if (this->type_ == MT_long)
     186        return "long";
     187    else if (this->type_ == MT_ulong)
     188        return "unsigned long";
     189    else if (this->type_ == MT_float)
     190        return "float";
     191    else if (this->type_ == MT_double)
     192        return "double";
     193    else if (this->type_ == MT_longdouble)
     194        return "long double";
     195    else if (this->type_ == MT_bool)
     196        return "bool";
     197    else
     198        return "unknown";
     199}
     200
    169201std::string MultiTypePrimitive::toString() const
    170202{
  • code/branches/core2/src/util/MultiTypePrimitive.h

    r933 r947  
    181181        inline bool      isA(MultiType type) const { return (this->type_ == type); }
    182182
     183        virtual std::string getTypename() const;
     184
    183185        virtual std::string toString() const;
    184186        virtual bool fromString(const std::string value);
  • code/branches/core2/src/util/MultiTypeString.cc

    r933 r947  
    104104}
    105105
     106std::string MultiTypeString::getTypename() const
     107{
     108    if (this->type_ == MT_constchar)
     109        return "string";
     110    else if (this->type_ == MT_string)
     111        return "string";
     112    else if (this->type_ == MT_xmlelement)
     113        return "XML-element";
     114    else
     115        return MultiTypePrimitive::getTypename();
     116}
     117
    106118std::string MultiTypeString::toString() const
    107119{
  • code/branches/core2/src/util/MultiTypeString.h

    r933 r947  
    115115        inline void getValue(orxonox::Element* variable) const { (*variable) = this->xmlelement_;     }
    116116
     117        virtual std::string getTypename() const;
     118
    117119        virtual std::string toString() const;
    118120        virtual bool fromString(const std::string value);
  • code/branches/core2/src/util/String.cc

    r931 r947  
    2525 *
    2626 */
     27
     28#include <cctype>
    2729
    2830#include "String.h"
     
    116118void lowercase(std::string* str)
    117119{
    118     static unsigned const char difference_between_A_and_a = 'A' - 'a';
    119 
    120     for (std::string::iterator it = (*str).begin(); it != (*str).end(); ++it)
    121         if ((*it) >= 'A' && (*it) <= 'Z')
    122             (*it) -= difference_between_A_and_a;
     120    for (unsigned int i = 0; i < str->size(); ++i)
     121    {
     122        (*str)[i] = tolower((*str)[i]);
     123    }
    123124}
    124125
     
    141142void uppercase(std::string* str)
    142143{
    143     static unsigned const char difference_between_A_and_a = 'A' - 'a';
    144 
    145     for (std::string::iterator it = (*str).begin(); it != (*str).end(); ++it)
    146         if ((*it) >= 'a' && (*it) <= 'z')
    147             (*it) += difference_between_A_and_a;
     144    for (unsigned int i = 0; i < str->size(); ++i)
     145    {
     146        (*str)[i] = toupper((*str)[i]);
     147    }
    148148}
    149149
Note: See TracChangeset for help on using the changeset viewer.