Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 9, 2008, 7:32:06 PM (16 years ago)
Author:
landauf
Message:

upload of the work i did before the exams (not yet finished nor working)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/orxonox/core/ConfigValueContainer.h

    r790 r792  
    4949
    5050#include "util/Math.h"
     51#include "util/MultiTypeMath.h"
    5152#include "Language.h"
    5253
     
    7273    {
    7374        public:
    74             enum VariableType
    75             {
    76                 VT_Int,
    77                 VT_uInt,
    78                 VT_Char,
    79                 VT_uChar,
    80                 VT_Float,
    81                 VT_Double,
    82                 VT_LongDouble,
    83                 VT_Bool,
    84                 VT_ConstChar,
    85                 VT_String,
    86                 VT_Vector2,
    87                 VT_Vector3,
    88                 VT_ColourValue
    89             };
    90 
    91             ConfigValueContainer(const std::string& classname, const std::string& varname, int defvalue);
    92             ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned int defvalue);
    93             ConfigValueContainer(const std::string& classname, const std::string& varname, char defvalue);
    94             ConfigValueContainer(const std::string& classname, const std::string& varname, unsigned char defvalue);
    95             ConfigValueContainer(const std::string& classname, const std::string& varname, float defvalue);
    96             ConfigValueContainer(const std::string& classname, const std::string& varname, double defvalue);
    97             ConfigValueContainer(const std::string& classname, const std::string& varname, long double defvalue);
    98             ConfigValueContainer(const std::string& classname, const std::string& varname, bool defvalue);
    99             ConfigValueContainer(const std::string& classname, const std::string& varname, const std::string& defvalue);
    100             ConfigValueContainer(const std::string& classname, const std::string& varname, const char* defvalue);
    101             ConfigValueContainer(const std::string& classname, const std::string& varname, Vector2 defvalue);
    102             ConfigValueContainer(const std::string& classname, const std::string& varname, Vector3 defvalue);
    103             ConfigValueContainer(const std::string& classname, const std::string& varname, ColourValue defvalue);
     75            ConfigValueContainer(const std::string& classname, const std::string& varname, MultiTypeMath defvalue);
    10476
    10577            /** @returns the value. @param value This is only needed to determine the right type. */
    106             inline ConfigValueContainer& getValue(int& value)                           { value = this->value_.value_int_; return *this; }
    107             /** @returns the value. @param value This is only needed to determine the right type. */
    108             inline ConfigValueContainer& getValue(unsigned int& value)                  { value = this->value_.value_uint_; return *this; }
    109             /** @returns the value. @param value This is only needed to determine the right type. */
    110             inline ConfigValueContainer& getValue(char& value)                          { value = this->value_.value_char_; return *this; }
    111             /** @returns the value. @param value This is only needed to determine the right type. */
    112             inline ConfigValueContainer& getValue(unsigned char& value)                 { value = this->value_.value_uchar_; return *this; }
    113             /** @returns the value. @param value This is only needed to determine the right type. */
    114             inline ConfigValueContainer& getValue(float& value)                         { value = this->value_.value_float_; return *this; }
    115             /** @returns the value. @param value This is only needed to determine the right type. */
    116             inline ConfigValueContainer& getValue(double& value)                        { value = this->value_.value_double_; return *this; }
    117             /** @returns the value. @param value This is only needed to determine the right type. */
    118             inline ConfigValueContainer& getValue(long double& value)                   { value = this->value_.value_long_double_; return *this; }
    119             /** @returns the value. @param value This is only needed to determine the right type. */
    120             inline ConfigValueContainer& getValue(bool& value)                          { value = this->value_.value_bool_; return *this; }
    121             /** @returns the value. @param value This is only needed to determine the right type. */
    122             inline ConfigValueContainer& getValue(std::string& value)                   { value = this->value_string_; return *this; }
    123             /** @returns the value. @param value This is only needed to determine the right type. */
    124             inline ConfigValueContainer& getValue(const char* value)                    { value = this->value_string_.c_str(); return *this; }
    125             /** @returns the value. @param value This is only needed to determine the right type. */
    126             inline ConfigValueContainer& getValue(Vector2& value)                       { value = this->value_vector2_; return *this; }
    127             /** @returns the value. @param value This is only needed to determine the right type. */
    128             inline ConfigValueContainer& getValue(Vector3& value)                       { value = this->value_vector3_; return *this; }
    129             /** @returns the value. @param value This is only needed to determine the right type. */
    130             inline ConfigValueContainer& getValue(ColourValue& value)                   { value = this->value_colourvalue_; return *this; }
     78/*            template <typename T>
     79            inline ConfigValueContainer& getValue(T& value)                           { this->value_.getValue(value); return *this; }
     80*/
     81            inline ConfigValueContainer& getValue(int* value)            { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     82            inline ConfigValueContainer& getValue(unsigned int* value)   { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     83            inline ConfigValueContainer& getValue(char* value)           { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     84            inline ConfigValueContainer& getValue(unsigned char* value)  { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     85            inline ConfigValueContainer& getValue(short* value)          { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     86            inline ConfigValueContainer& getValue(unsigned short* value) { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     87            inline ConfigValueContainer& getValue(long* value)           { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     88            inline ConfigValueContainer& getValue(unsigned long* value)  { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     89            inline ConfigValueContainer& getValue(float* value)          { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     90            inline ConfigValueContainer& getValue(double* value)         { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     91            inline ConfigValueContainer& getValue(long double* value)    { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     92            inline ConfigValueContainer& getValue(bool* value)           { ((MultiTypePrimitive)this->value_).getValue(value); return *this; }
     93            inline ConfigValueContainer& getValue(std::string* value)    { ((MultiTypeString)this->value_).getValue(value); return *this; }
     94            inline ConfigValueContainer& getValue(Vector2* value)        { this->value_.getValue(value); return *this; }
     95            inline ConfigValueContainer& getValue(Vector3* value)        { this->value_.getValue(value); return *this; }
     96            inline ConfigValueContainer& getValue(ColourValue* value)    { this->value_.getValue(value); return *this; }
     97            inline ConfigValueContainer& getValue(Quaternion* value)     { this->value_.getValue(value); return *this; }
     98            inline ConfigValueContainer& getValue(Radian* value)         { this->value_.getValue(value); return *this; }
     99            inline ConfigValueContainer& getValue(Degree* value)         { this->value_.getValue(value); return *this; }
    131100
    132101            void description(const std::string& description);
    133102
    134             bool parseSting(const std::string& input);
     103            bool parseString(const std::string& input, MultiTypeMath& defvalue = MT_null);
     104            bool valueToString(std::string* output, MultiTypeMath& input);
    135105            void resetConfigFileEntry();
    136106            void resetConfigValue();
     
    141111
    142112        private:
    143             bool parseSting(const std::string& input, int defvalue);
    144             bool parseSting(const std::string& input, unsigned int defvalue);
    145             bool parseSting(const std::string& input, char defvalue);
    146             bool parseSting(const std::string& input, unsigned char defvalue);
    147             bool parseSting(const std::string& input, float defvalue);
    148             bool parseSting(const std::string& input, double defvalue);
    149             bool parseSting(const std::string& input, long double defvalue);
    150             bool parseSting(const std::string& input, bool defvalue);
    151             bool parseSting(const std::string& input, const std::string& defvalue);
    152             bool parseSting(const std::string& input, const char* defvalue);
    153             bool parseSting(const std::string& input, const Vector2& defvalue);
    154             bool parseSting(const std::string& input, const Vector3& defvalue);
    155             bool parseSting(const std::string& input, const ColourValue& defvalue);
     113            bool parseString(const std::string& input, int defvalue);
     114            bool parseString(const std::string& input, unsigned int defvalue);
     115            bool parseString(const std::string& input, char defvalue);
     116            bool parseString(const std::string& input, unsigned char defvalue);
     117            bool parseString(const std::string& input, short defvalue);
     118            bool parseString(const std::string& input, unsigned short defvalue);
     119            bool parseString(const std::string& input, long defvalue);
     120            bool parseString(const std::string& input, unsigned long defvalue);
     121            bool parseString(const std::string& input, float defvalue);
     122            bool parseString(const std::string& input, double defvalue);
     123            bool parseString(const std::string& input, long double defvalue);
     124            bool parseString(const std::string& input, bool defvalue);
     125            bool parseString(const std::string& input, const std::string& defvalue);
     126            bool parseString(const std::string& input, const char* defvalue);
     127            bool parseString(const std::string& input, const Vector2& defvalue);
     128            bool parseString(const std::string& input, const Vector3& defvalue);
     129            bool parseString(const std::string& input, const ColourValue& defvalue);
     130            bool parseString(const std::string& input, const Quaternion& defvalue);
     131            bool parseString(const std::string& input, const Radian& defvalue);
     132            bool parseString(const std::string& input, const Degree& defvalue);
    156133
    157134            static std::list<std::string>& getConfigFileLines();
     
    167144            std::string         defvalueString_;                //!< The string of the default-variable
    168145
    169             union MultiType
    170             {
    171                 int                 value_int_;                 //!< The value, if the variable is of the type int
    172                 unsigned int        value_uint_;                //!< The value, if the variable is of the type unsigned int
    173                 char                value_char_;                //!< The value, if the variable is of the type char
    174                 unsigned char       value_uchar_;               //!< The value, if the variable is of the type unsigned char
    175                 float               value_float_;               //!< The value, if the variable is of the type float
    176                 double              value_double_;              //!< The value, if the variable is of the type double
    177                 long double         value_long_double_;         //!< The value, if the variable is of the type long double
    178                 bool                value_bool_;                //!< The value, if the variable is of the type bool
    179             } value_;                                           //!< The value of the variable
    180 
    181             std::string         value_string_;                  //!< The value, if the variable is of the type string
    182             Vector2             value_vector2_;                 //!< The value, if the variable is of the type Vector2
    183             Vector3             value_vector3_;                 //!< The value, if the variable is of the type Vector3
    184             ColourValue         value_colourvalue_;             //!< The value, if the variable is of the type ColourValue
     146            MultiTypeMath       value_;                         //!< The value
    185147
    186148            std::list<std::string>::iterator configFileLine_;   //!< An iterator, pointing to the entry of the variable in the config-file
    187149
    188             VariableType type_;                                 //!< The type of the variable
    189150            bool bAddedDescription_;                            //!< True if a description was added
    190151            LanguageEntryName description_;                     //!< The description
Note: See TracChangeset for help on using the changeset viewer.