Changeset 871 for code/trunk/src/orxonox/core/ConfigValueContainer.h
- Timestamp:
- Mar 9, 2008, 4:44:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/core/ConfigValueContainer.h
r790 r871 26 26 */ 27 27 28 /* !28 /** 29 29 @file ConfigValueContainer.h 30 30 @brief Definition of the ConfigValueContainer class. … … 49 49 50 50 #include "util/Math.h" 51 #include " Language.h"51 #include "util/MultiTypeMath.h" 52 52 53 53 namespace orxonox … … 72 72 { 73 73 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 }; 74 ConfigValueContainer(const std::string& classname, const std::string& varname, MultiTypeMath defvalue); 90 75 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); 104 105 /** @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; } 76 /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */ 77 /* template <typename T> 78 inline ConfigValueContainer& getValue(T& value) { this->value_.getValue(value); return *this; } 79 */ 80 inline ConfigValueContainer& getValue(int* value) { this->value_.getValue(value); return *this; } 81 inline ConfigValueContainer& getValue(unsigned int* value) { this->value_.getValue(value); return *this; } 82 inline ConfigValueContainer& getValue(char* value) { this->value_.getValue(value); return *this; } 83 inline ConfigValueContainer& getValue(unsigned char* value) { this->value_.getValue(value); return *this; } 84 inline ConfigValueContainer& getValue(short* value) { this->value_.getValue(value); return *this; } 85 inline ConfigValueContainer& getValue(unsigned short* value) { this->value_.getValue(value); return *this; } 86 inline ConfigValueContainer& getValue(long* value) { this->value_.getValue(value); return *this; } 87 inline ConfigValueContainer& getValue(unsigned long* value) { this->value_.getValue(value); return *this; } 88 inline ConfigValueContainer& getValue(float* value) { this->value_.getValue(value); return *this; } 89 inline ConfigValueContainer& getValue(double* value) { this->value_.getValue(value); return *this; } 90 inline ConfigValueContainer& getValue(long double* value) { this->value_.getValue(value); return *this; } 91 inline ConfigValueContainer& getValue(bool* value) { this->value_.getValue(value); return *this; } 92 inline ConfigValueContainer& getValue(std::string* value) { this->value_.getValue(value); return *this; } 93 inline ConfigValueContainer& getValue(const char** value) { 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; } 131 100 132 101 void description(const std::string& description); 102 const std::string& getDescription() const; 133 103 134 bool parseSting(const std::string& input); 104 bool parseString(const std::string& input, MultiTypeMath& defvalue); 105 bool valueToString(std::string* output, MultiTypeMath& input); 135 106 void resetConfigFileEntry(); 136 107 void resetConfigValue(); … … 141 112 142 113 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); 114 bool parseString(const std::string& input, int defvalue); 115 bool parseString(const std::string& input, unsigned int defvalue); 116 bool parseString(const std::string& input, char defvalue); 117 bool parseString(const std::string& input, unsigned char defvalue); 118 bool parseString(const std::string& input, short defvalue); 119 bool parseString(const std::string& input, unsigned short defvalue); 120 bool parseString(const std::string& input, long defvalue); 121 bool parseString(const std::string& input, unsigned long defvalue); 122 bool parseString(const std::string& input, float defvalue); 123 bool parseString(const std::string& input, double defvalue); 124 bool parseString(const std::string& input, long double defvalue); 125 bool parseString(const std::string& input, bool defvalue); 126 bool parseString(const std::string& input, const std::string& defvalue); 127 bool parseString(const std::string& input, const char* defvalue); 128 bool parseString(const std::string& input, const Vector2& defvalue); 129 bool parseString(const std::string& input, const Vector3& defvalue); 130 bool parseString(const std::string& input, const ColourValue& defvalue); 131 bool parseString(const std::string& input, const Quaternion& defvalue); 132 bool parseString(const std::string& input, const Radian& defvalue); 133 bool parseString(const std::string& input, const Degree& defvalue); 156 134 157 135 static std::list<std::string>& getConfigFileLines(); … … 167 145 std::string defvalueString_; //!< The string of the default-variable 168 146 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 147 MultiTypeMath value_; //!< The value 185 148 186 149 std::list<std::string>::iterator configFileLine_; //!< An iterator, pointing to the entry of the variable in the config-file 187 150 188 VariableType type_; //!< The type of the variable189 151 bool bAddedDescription_; //!< True if a description was added 190 LanguageEntry Name description_;//!< The description152 LanguageEntryLabel description_; //!< The description 191 153 }; 192 154 }
Note: See TracChangeset
for help on using the changeset viewer.