Changeset 1791
- Timestamp:
- Sep 16, 2008, 3:46:25 AM (16 years ago)
- Location:
- code/trunk/src
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/ConfigValueContainer.cc
r1784 r1791 45 45 namespace orxonox 46 46 { 47 const int MAX_VECTOR_INDEX = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument47 const unsigned int MAX_VECTOR_INDEX = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument 48 48 49 49 /** … … 304 304 success = ConvertValue(&index, token[0]); 305 305 306 if (!success || index < 0 || index > MAX_VECTOR_INDEX)306 if (!success || index < 0 || index > (signed int)MAX_VECTOR_INDEX) 307 307 { 308 308 if (!success) -
code/trunk/src/util/CRC32.cc
r1763 r1791 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... … … 32 32 void calcCRCBit(uint32_t &crc32, int bit){ 33 33 int hbit; 34 34 35 35 hbit=(crc32 & 0x80000000) ? 1 : 0; 36 36 if (hbit != bit) -
code/trunk/src/util/CRC32.h
r1784 r1791 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ... -
code/trunk/src/util/Clipboard.cc
r1505 r1791 29 29 */ 30 30 31 /** 32 @file Clipboard.cc 33 @brief OS-specific implementations of the clipboard functions. 34 */ 35 31 36 #include "Clipboard.h" 32 37 33 38 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 39 ///////////// 40 // Windows // 41 ///////////// 34 42 #include <windows.h> 43 #include "Debug.h" 35 44 36 bool toClipboard(std::string text) 45 /** 46 @brief Puts text into the windows-clipboard 47 @param text The text 48 @return True if the action was successful 49 */ 50 bool toClipboard(const std::string& text) 37 51 { 38 52 try … … 53 67 catch (...) 54 68 { 69 COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl; 70 COUT(1) << " \"" << text << "\"" << std::endl; 55 71 } 56 72 return false; 57 73 } 58 74 75 /** 76 @brief Gets text from the windows-clipboard if there is any text. 77 @return The retrieved text 78 */ 59 79 std::string fromClipboard() 60 80 { … … 73 93 catch (...) 74 94 { 95 COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl; 75 96 } 76 97 return ""; 77 98 } 78 99 #else 79 std::string clipboard = ""; 100 ///////////// 101 // Default // 102 ///////////// 80 103 81 bool toClipboard(std::string text) 104 std::string clipboard = ""; //!< Keeps the text of our internal clipboard 105 106 /** 107 @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard. 108 @param text The text 109 @return True 110 */ 111 bool toClipboard(const std::string& text) 82 112 { 83 113 clipboard = text; … … 85 115 } 86 116 117 /** 118 @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard. 119 @return The text 120 */ 87 121 std::string fromClipboard() 88 122 { -
code/trunk/src/util/Clipboard.h
r1505 r1791 27 27 */ 28 28 29 /** 30 @file Clipboard.h 31 @brief Some functions to exchange text between the OS clipboard and Orxonox. 32 33 Use fromClipboard() to get text from the clipboard (if there is any text) and 34 toClipboard(text) to put text into the clipboard. 35 36 Those functions can only work properly if there's an OS-specific implementation. 37 If an OS isn't supported, the clipboard only works within Orxonox, but exchange 38 with other programs isn't possible. 39 */ 40 29 41 #ifndef _Clipboard_H__ 30 42 #define _Clipboard_H__ … … 35 47 36 48 37 _UtilExport bool toClipboard( std::stringtext);49 _UtilExport bool toClipboard(const std::string& text); 38 50 _UtilExport std::string fromClipboard(); 39 51 -
code/trunk/src/util/Convert.h
r1755 r1791 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau 23 24 * Benjamin Grauer 24 * Fabian 'x3n' Landau25 25 * Co-authors: 26 26 * ... -
code/trunk/src/util/Debug.h
r1747 r1791 28 28 29 29 /** 30 * @file Debug.h 31 * @brief Handles the output for different verbose-modes. 32 * 33 * There are two modes: HARD and SOFT. HARD is precessed during compiletime, while SOFT is for runtime. 30 @file Debug.h 31 @brief Handles different output-levels of errors, warnings, infos and debug informations. 32 33 The COUT(level) macro acts like std::cout, but the output is only performed if the given 34 level is <= the soft debug level. 35 36 There are two used values in this file: 37 - The hard debug level is used during compiletime. It describes the highest allowed output level. 38 - The soft debug level is used during runtime and is the maximum of the three configurable 39 output-levels for console, logfile and ingame shell. 40 41 The separation between the three devices is done by the OutputHandler. 42 43 Possible levels are: 44 0: Very important output 45 1: Errors 46 2: Warnings 47 3: Informations 48 4: Debug information 49 5: More debug information 50 6: Crazy debug informations 51 52 @example 53 COUT(0) << "Very important output" << std::endl; 54 COUT(1) << "Error: Something went wrong!" << std::endl; 55 COUT(2) << "Warning: There might be a problem." << std::endl; 56 COUT(3) << "Info: It's monday" << std::endl; 57 COUT(4) << "Debug: x is 1.23456" << std::endl; 34 58 */ 35 59 -
code/trunk/src/util/Math.cc
r1625 r1791 27 27 */ 28 28 29 /** 30 @file Math.cc 31 @brief Implementation of several math-functions. 32 */ 33 29 34 #include <OgrePlane.h> 30 35 … … 33 38 34 39 /** 35 @brief Function for writing to a stream.40 @brief Function for writing a Radian to a stream. 36 41 */ 37 42 std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian) … … 42 47 43 48 /** 44 @brief Function for reading from a stream.49 @brief Function for reading a Radian from a stream. 45 50 */ 46 51 std::istream& operator>>(std::istream& in, orxonox::Radian& radian) … … 53 58 54 59 /** 55 @brief Function for writing to a stream.60 @brief Function for writing a Degree to a stream. 56 61 */ 57 62 std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree) … … 62 67 63 68 /** 64 @brief Function for reading from a stream.69 @brief Function for reading a Degree from a stream. 65 70 */ 66 71 std::istream& operator>>(std::istream& in, orxonox::Degree& degree) … … 73 78 74 79 80 /** 81 @brief Gets the angle between my viewing direction and the direction to the position of the other object. 82 @param myposition My position 83 @param mydirection My viewing direction 84 @param otherposition The position of the other object 85 @return The angle 86 87 @example 88 If the other object is exactly in front of me, the function returns 0. 89 If the other object is exactly behind me, the function returns pi. 90 If the other object is exactly right/left to me (or above/below), the function returns pi/2. 91 */ 75 92 float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition) 76 93 { … … 83 100 } 84 101 102 /** 103 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object. 104 @param myposition My position 105 @param mydirection My viewing direction 106 @param myorthonormal My orthonormalvector (pointing upwards through my head) 107 @param otherposition The position of the other object 108 @return The viewing direction 109 110 @example 111 If the other object is exactly in front of me, the function returns Vector2(0, 0). 112 If the other object is exactly at my left, the function returns Vector2(-1, 0). 113 If the other object is exactly at my right, the function returns Vector2(1, 0). 114 If the other object is only a bit at my right, the function still returns Vector2(1, 0). 115 If the other object is exactly above me, the function returns Vector2(0, 1). 116 */ 85 117 orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) 86 118 { … … 100 132 } 101 133 134 /** 135 @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1). 136 @param myposition My position 137 @param mydirection My viewing direction 138 @param myorthonormal My orthonormalvector (pointing upwards through my head) 139 @param otherposition The position of the other object 140 @return The viewing direction 141 142 @example 143 If the other object is exactly in front of me, the function returns Vector2(0, 0). 144 If the other object is exactly at my left, the function returns Vector2(-0.5, 0). 145 If the other object is exactly at my right, the function returns Vector2(0.5, 0). 146 If the other object is only a bit at my right, the function still returns Vector2(0.01, 0). 147 If the other object is exactly above me, the function returns Vector2(0, 0.5). 148 */ 102 149 orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) 103 150 { … … 121 168 } 122 169 170 /** 171 @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile. 172 @param myposition My position 173 @param projectilespeed The speed of my projectile 174 @param targetposition The position of my target 175 @param targetvelocity The velocity of my target 176 @return The predicted position 177 178 The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss. 179 */ 123 180 orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity) 124 181 { -
code/trunk/src/util/Math.h
r1781 r1791 26 26 * 27 27 */ 28 29 /** 30 @file Math.h 31 @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace. 32 */ 28 33 29 34 #ifndef _Util_Math_H__ … … 68 73 69 74 //Get around Windows hackery 70 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 75 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 71 76 # ifdef max 72 77 # undef max … … 77 82 #endif 78 83 84 /** 85 @brief Returns the sign of the given value. 86 @param x The value 87 @return 1 if the value is positive or zero, -1 if the value is negative 88 */ 79 89 template <typename T> 80 90 inline T sgn(T x) … … 83 93 } 84 94 95 /** 96 @brief Returns the smaller of two values. 97 */ 85 98 template <typename T> 86 99 inline T min(T a, T b) … … 89 102 } 90 103 104 /** 105 @brief Returns the greater of two values. 106 */ 91 107 template <typename T> 92 108 inline T max(T a, T b) … … 95 111 } 96 112 113 /** 114 @brief Keeps a value between a lower and an upper limit. 115 @param x The value 116 @param min The lower limit 117 @param max The upper limit 118 */ 97 119 template <typename T> 98 120 inline T clamp(T x, T min, T max) … … 107 129 } 108 130 131 /** 132 @brief Returns the square value (x^2). 133 */ 109 134 template <typename T> 110 135 inline T square(T x) … … 113 138 } 114 139 140 /** 141 @brief Returns the cube value (x^3). 142 */ 115 143 template <typename T> 116 144 inline T cube(T x) … … 119 147 } 120 148 149 /** 150 @brief Rounds the value down. 151 */ 121 152 template <typename T> 122 153 inline int floor(T x) … … 125 156 } 126 157 158 /** 159 @brief Rounds the value up. 160 */ 127 161 template <typename T> 128 162 inline int ceil(T x) … … 132 166 } 133 167 168 /** 169 @brief Rounds the value. 170 */ 134 171 template <typename T> 135 172 inline int round(T x) … … 138 175 } 139 176 177 /** 178 @brief The modulo operation, enhanced to work properly with negative values. 179 @param x The value 180 @param max The operand 181 */ 140 182 template <typename T> 141 183 inline int mod(T x, int max) … … 147 189 } 148 190 191 /** 192 @brief Interpolates between two values for a time between 0 and 1. 193 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1. 194 @param start The value at time = 0 195 @param end The value at time = 1 196 @return The interpolation at a given time 197 */ 149 198 template <typename T> 150 199 T interpolate(float time, const T& start, const T& end) … … 153 202 } 154 203 204 /** 205 @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again. 206 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1. 207 @param start The value at time = 0 208 @param end The value at time = 1 209 @return The smoothed interpolation at a given time 210 */ 155 211 template <typename T> 156 212 T interpolateSmooth(float time, const T& start, const T& end) … … 159 215 } 160 216 217 /** 218 @brief Returns a random number between 0 and 1. 219 */ 161 220 inline _UtilExport float rnd() 162 221 { … … 164 223 } 165 224 225 /** 226 @brief Returns a random number between 0 and max. 227 @param max The maximum 228 */ 166 229 inline _UtilExport float rnd(float max) 167 230 { … … 169 232 } 170 233 234 /** 235 @brief Returns a random number between min and max. 236 @param min The minimum 237 @param max The maximum 238 */ 171 239 inline _UtilExport float rnd(float min, float max) 172 240 { -
code/trunk/src/util/MultiType.cc
r1747 r1791 27 27 */ 28 28 29 /** 30 @file MultiType.cc 31 @brief Implementation of the MultiType. 32 */ 33 29 34 #include "MultiType.h" 30 35 #include "MultiTypeValue.h" 31 36 37 /** 38 @brief Converts the current value of the MultiType to a new type. 39 @param type The type 40 */ 32 41 void MultiType::convert(MT_Type type) 33 42 { … … 85 94 } 86 95 96 /** 97 @brief Returns the name of the current type. 98 @return The name 99 */ 87 100 std::string MultiType::getTypename() const 88 101 { … … 142 155 } 143 156 144 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_char ) ? ((MT_Value<char> *)this->value_)->value_ : (*this->value_)) : 0; } 145 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_uchar ) ? ((MT_Value<unsigned char> *)this->value_)->value_ : (*this->value_)) : 0; } 146 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_short ) ? ((MT_Value<short> *)this->value_)->value_ : (*this->value_)) : 0; } 147 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_ushort ) ? ((MT_Value<unsigned short> *)this->value_)->value_ : (*this->value_)) : 0; } 148 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_int ) ? ((MT_Value<int> *)this->value_)->value_ : (*this->value_)) : 0; } 149 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_uint ) ? ((MT_Value<unsigned int> *)this->value_)->value_ : (*this->value_)) : 0; } 150 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_long ) ? ((MT_Value<long> *)this->value_)->value_ : (*this->value_)) : 0; } 151 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_ulong ) ? ((MT_Value<unsigned long> *)this->value_)->value_ : (*this->value_)) : 0; } 152 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_longlong ) ? ((MT_Value<long long> *)this->value_)->value_ : (*this->value_)) : 0; } 153 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong ) ? ((MT_Value<unsigned long long> *)this->value_)->value_ : (*this->value_)) : 0; } 154 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_float ) ? ((MT_Value<float> *)this->value_)->value_ : (*this->value_)) : 0; } 155 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_double ) ? ((MT_Value<double> *)this->value_)->value_ : (*this->value_)) : 0; } 156 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double> *)this->value_)->value_ : (*this->value_)) : 0; } 157 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (*this->value_)) : false; } 158 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (*this->value_)) : (void*)0; } 159 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (*this->value_)) : std::string(); } 160 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2(); } 161 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3(); } 162 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4(); } 163 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } 164 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion(); } 165 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (*this->value_)) : orxonox::Radian(); } 166 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (*this->value_)) : orxonox::Degree(); } 167 168 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_char ); } 169 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_uchar ); } 170 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_short ); } 171 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_ushort ); } 172 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_int ); } 173 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_uint ); } 174 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_long ); } 175 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_ulong ); } 176 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_longlong ); } 177 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_ulonglong ); } 178 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_float ); } 179 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_double ); } 180 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_longdouble ); } 181 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_bool ); } 182 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_void ); } 183 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_string ); } 184 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_vector2 ); } 185 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_vector3 ); } 186 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_vector4 ); } 187 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } 188 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } 189 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_radian ); } 190 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_degree ); } 157 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_char ) ? ((MT_Value<char> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 158 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_uchar ) ? ((MT_Value<unsigned char> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 159 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_short ) ? ((MT_Value<short> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 160 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_ushort ) ? ((MT_Value<unsigned short> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 161 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_int ) ? ((MT_Value<int> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 162 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_uint ) ? ((MT_Value<unsigned int> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 163 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_long ) ? ((MT_Value<long> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 164 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_ulong ) ? ((MT_Value<unsigned long> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 165 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_longlong ) ? ((MT_Value<long long> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 166 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong ) ? ((MT_Value<unsigned long long> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 167 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_float ) ? ((MT_Value<float> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 168 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_double ) ? ((MT_Value<double> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 169 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 170 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (*this->value_)) : false; } /** @brief Returns the current value, converted to the requested type. */ 171 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (*this->value_)) : (void*)0; } /** @brief Returns the current value, converted to the requested type. */ 172 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (*this->value_)) : std::string(); } /** @brief Returns the current value, converted to the requested type. */ 173 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2(); } /** @brief Returns the current value, converted to the requested type. */ 174 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3(); } /** @brief Returns the current value, converted to the requested type. */ 175 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4(); } /** @brief Returns the current value, converted to the requested type. */ 176 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */ 177 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion(); } /** @brief Returns the current value, converted to the requested type. */ 178 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (*this->value_)) : orxonox::Radian(); } /** @brief Returns the current value, converted to the requested type. */ 179 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (*this->value_)) : orxonox::Degree(); } /** @brief Returns the current value, converted to the requested type. */ 180 181 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_char ); } /** @brief Creates a new value container for the given type. */ 182 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_uchar ); } /** @brief Creates a new value container for the given type. */ 183 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_short ); } /** @brief Creates a new value container for the given type. */ 184 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_ushort ); } /** @brief Creates a new value container for the given type. */ 185 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_int ); } /** @brief Creates a new value container for the given type. */ 186 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_uint ); } /** @brief Creates a new value container for the given type. */ 187 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_long ); } /** @brief Creates a new value container for the given type. */ 188 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_ulong ); } /** @brief Creates a new value container for the given type. */ 189 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_longlong ); } /** @brief Creates a new value container for the given type. */ 190 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_ulonglong ); } /** @brief Creates a new value container for the given type. */ 191 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_float ); } /** @brief Creates a new value container for the given type. */ 192 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_double ); } /** @brief Creates a new value container for the given type. */ 193 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_longdouble ); } /** @brief Creates a new value container for the given type. */ 194 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_bool ); } /** @brief Creates a new value container for the given type. */ 195 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_void ); } /** @brief Creates a new value container for the given type. */ 196 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_string ); } /** @brief Creates a new value container for the given type. */ 197 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_vector2 ); } /** @brief Creates a new value container for the given type. */ 198 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_vector3 ); } /** @brief Creates a new value container for the given type. */ 199 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_vector4 ); } /** @brief Creates a new value container for the given type. */ 200 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } /** @brief Creates a new value container for the given type. */ 201 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } /** @brief Creates a new value container for the given type. */ 202 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_radian ); } /** @brief Creates a new value container for the given type. */ 203 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_degree ); } /** @brief Creates a new value container for the given type. */ -
code/trunk/src/util/MultiType.h
r1757 r1791 27 27 */ 28 28 29 /** 30 @file MultiType.h 31 @brief Declaration of the MultiType and some helper constructs. 32 33 The MultiType can hold a value of one of the following types: 34 - all primitives 35 - all pointers 36 - string 37 - Vector2, Vector3, Vector4 38 - Quaternion 39 - ColourValue 40 - Radian, Degree 41 42 The MultiType has a "type" determined by the first assigned value, either through 43 - the constructor, 44 - the assignment operator= or 45 - setValue(value). 46 If you assign another value of another type, the MultiType keeps "it's" type and 47 converts the new value to this type. 48 49 If you want to change the type, there are three possibilities: 50 - convert<T>() set's the type to T and converts the currently assigned value 51 - setType<T>() set's the type to T and resets the value 52 - setValue<T>(value) assigns a new value and changes the type to T. 53 54 @example 55 MultiType a = 10;; // a has now the type int and the value 10 56 a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3 57 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14 58 a.convert<bool>(); // converts 3.14 to bool, which is true 59 a = false; // assigns false, this is equivalent to a.setValue(false) 60 */ 61 29 62 #ifndef _MultiType_H__ 30 63 #define _MultiType_H__ … … 36 69 #include "Math.h" 37 70 71 /** 72 @brief Enum of all possible types of a MultiType. 73 */ 38 74 enum MT_Type 39 75 { … … 64 100 }; 65 101 102 /** 103 @brief The MultiType can hold a value of many possible types and convert them to other types. 104 105 The following types are supported by the MultiType: 106 - all primitves 107 - all pointers 108 - string 109 - Vector2, Vector3, Vector4 110 - Quaternion 111 - ColourValue 112 - Radian, Degree 113 114 The internal type of a MultiType is determined by the first assigned value, but can be 115 changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned 116 the normal way (operator=, setValue(value)), the value gets converted to the current internal 117 type of the MultiType. 118 */ 66 119 class _UtilExport MultiType 67 120 { … … 69 122 template <typename T> friend struct MT_Value; 70 123 124 /** 125 @brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType. 126 This class is only used within the MultiType. 127 */ 71 128 struct _UtilExport MT_ValueBase 72 129 { … … 78 135 virtual void reset() = 0; 79 136 virtual void assimilate(const MultiType& other) = 0; 137 138 /** @brief Returns the type of the current value. */ 80 139 const MT_Type& getType() const { return this->type_; } 81 140 … … 130 189 virtual void toString(std::ostream& outstream) const = 0; 131 190 132 MT_Type type_; 191 MT_Type type_; //! The type of the current value 133 192 }; 134 193 135 194 public: 136 inline MultiType() : value_(0) {} 137 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } 138 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } 139 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } 140 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } 141 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } 142 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } 143 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } 144 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } 145 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } 146 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } 147 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } 148 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } 149 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } 150 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } 151 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } 152 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } 153 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } 154 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } 155 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } 156 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } 157 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } 158 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } 159 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } 160 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } 161 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } 162 inline MultiType(MT_Type type) : value_(0) { this->setType(type); } 163 195 inline MultiType() : value_(0) {} /** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */ 196 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 197 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 198 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 199 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 200 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 201 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 202 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 203 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 204 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 205 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 206 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 207 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 208 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 209 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 210 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 211 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 212 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 213 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 214 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 215 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 216 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 217 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 218 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 219 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */ 220 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } /** @brief Copyconstructor: Assigns value and type of the other MultiType. */ 221 inline MultiType(MT_Type type) : value_(0) { this->setType(type); } /** @brief Constructor: Sets the type, the next assignment will determine the value. */ 222 223 /** @brief Destructor: Deletes the MT_Value. */ 164 224 inline ~MultiType() { if (this->value_) { delete this->value_; } } 165 225 166 template <typename V> inline const MultiType& operator=(const V& value) { this->setValue(value); return (*this); } 167 inline const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } 168 inline const MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } 226 template <typename V> inline const MultiType& operator=(const V& value) { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */ 227 template <typename V> inline const MultiType& operator=(V* value) { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */ 228 inline const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */ 229 inline const MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } /** @brief Resets the value and changes the type. */ 169 230 170 231 inline void setValue(const char& value); … … 191 252 inline void setValue(const orxonox::Radian& value); 192 253 inline void setValue(const orxonox::Degree& value); 254 inline void setValue(const char* value); 255 /** @brief Assigns a pointer. */ 193 256 template <typename V> inline void setValue(V* value) { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } } 257 /** @brief Assigns the value of the other MultiType and converts it to the current type. */ 194 258 void setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } } } 259 /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */ 195 260 template <typename T, typename V> inline void setValue(const V& value) { this->setType<T>(); this->setValue(value); } 196 inline void setValue(const char* value); 197 261 262 263 /** @brief Copies the other MultiType by assigning value and type. */ 198 264 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 199 265 200 template <typename T> inline void convert() { this->setValue<T>((T)(*this)); } 201 inline void convert(const MultiType& other) { this->convert(other.getType()); } 266 template <typename T> inline void convert() { this->setValue<T>((T)(*this)); } /** @brief Converts the current value to type T. */ 267 inline void convert(const MultiType& other) { this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 202 268 void convert(MT_Type type); 203 269 270 /** @brief Resets the value to the defaultvalue of the current type. */ 204 271 inline void reset() { if (this->value_) { delete this->value_; this->value_ = 0; } } 205 272 206 template <typename T> inline void setType() { this->assignValue(T()); } 207 inline void setType(const MultiType& other) { this->setType(other.getType()); } 208 inline void setType(MT_Type type) { this->reset(); this->convert(type); } 209 273 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ 274 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 275 inline void setType(MT_Type type) { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */ 276 277 /** @brief Returns the current type. */ 210 278 inline MT_Type getType() const { return (this->value_) ? this->value_->type_ : MT_null; } 279 /** @brief Returns true if the current type equals the given type. */ 211 280 inline bool isType(MT_Type type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); } 212 template <typename T> inline bool isType() const { return false; } 281 /** @brief Returns true if the current type is T. */ 282 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 213 283 std::string getTypename() const; 214 284 … … 236 306 operator orxonox::Radian() const; 237 307 operator orxonox::Degree() const; 308 /** @brief Returns the current value, converted to a T* pointer. */ 238 309 template <class T> operator T*() const { return ((T*)this->operator void*()); } 239 310 240 inline void getValue(char* value) const { if (this->value_) { (*value) = (*this->value_); } } 241 inline void getValue(unsigned char* value) const { if (this->value_) { (*value) = (*this->value_); } } 242 inline void getValue(short* value) const { if (this->value_) { (*value) = (*this->value_); } } 243 inline void getValue(unsigned short* value) const { if (this->value_) { (*value) = (*this->value_); } } 244 inline void getValue(int* value) const { if (this->value_) { (*value) = (*this->value_); } } 245 inline void getValue(unsigned int* value) const { if (this->value_) { (*value) = (*this->value_); } } 246 inline void getValue(long* value) const { if (this->value_) { (*value) = (*this->value_); } } 247 inline void getValue(unsigned long* value) const { if (this->value_) { (*value) = (*this->value_); } } 248 inline void getValue(long long* value) const { if (this->value_) { (*value) = (*this->value_); } } 249 inline void getValue(unsigned long long* value) const { if (this->value_) { (*value) = (*this->value_); } } 250 inline void getValue(float* value) const { if (this->value_) { (*value) = (*this->value_); } } 251 inline void getValue(double* value) const { if (this->value_) { (*value) = (*this->value_); } } 252 inline void getValue(long double* value) const { if (this->value_) { (*value) = (*this->value_); } } 253 inline void getValue(bool* value) const { if (this->value_) { (*value) = (*this->value_); } } 254 inline void getValue(void* value) const { if (this->value_) { value = (*this->value_); } } 255 inline void getValue(std::string* value) const { if (this->value_) { (*value) = this->value_->operator std::string(); } } 256 inline void getValue(orxonox::Vector2* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2(); } } 257 inline void getValue(orxonox::Vector3* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3(); } } 258 inline void getValue(orxonox::Vector4* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4(); } } 259 inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } 260 inline void getValue(orxonox::Quaternion* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion(); } } 261 inline void getValue(orxonox::Radian* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian(); } } 262 inline void getValue(orxonox::Degree* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree(); } } 263 264 inline char getChar() const { return this->operator char(); } 265 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } 266 inline short getShort() const { return this->operator short(); } 267 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } 268 inline int getInt() const { return this->operator int(); } 269 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } 270 inline long getLong() const { return this->operator long(); } 271 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } 272 inline long long getLongLong() const { return this->operator long long(); } 273 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } 274 inline float getFloat() const { return this->operator float(); } 275 inline double getDouble() const { return this->operator double(); } 276 inline long double getLongDouble() const { return this->operator long double(); } 277 inline bool getBool() const { return this->operator bool(); } 278 inline void* getVoid() const { return this->operator void*(); } 279 inline std::string getString() const { return this->operator std::string(); } 280 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } 281 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } 282 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } 283 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } 284 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } 285 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } 286 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } 287 template <typename T> inline T* getPointer() const { return ((T*)this->getVoid()); } 311 inline void getValue(char* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 312 inline void getValue(unsigned char* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 313 inline void getValue(short* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 314 inline void getValue(unsigned short* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 315 inline void getValue(int* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 316 inline void getValue(unsigned int* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 317 inline void getValue(long* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 318 inline void getValue(unsigned long* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 319 inline void getValue(long long* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 320 inline void getValue(unsigned long long* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 321 inline void getValue(float* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 322 inline void getValue(double* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 323 inline void getValue(long double* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 324 inline void getValue(bool* value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 325 inline void getValue(void* value) const { if (this->value_) { value = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 326 inline void getValue(std::string* value) const { if (this->value_) { (*value) = this->value_->operator std::string(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 327 inline void getValue(orxonox::Vector2* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 328 inline void getValue(orxonox::Vector3* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 329 inline void getValue(orxonox::Vector4* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 330 inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 331 inline void getValue(orxonox::Quaternion* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 332 inline void getValue(orxonox::Radian* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 333 inline void getValue(orxonox::Degree* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 334 335 inline char getChar() const { return this->operator char(); } /** @brief Returns the current value, converted to the requested type. */ 336 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } /** @brief Returns the current value, converted to the requested type. */ 337 inline short getShort() const { return this->operator short(); } /** @brief Returns the current value, converted to the requested type. */ 338 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } /** @brief Returns the current value, converted to the requested type. */ 339 inline int getInt() const { return this->operator int(); } /** @brief Returns the current value, converted to the requested type. */ 340 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } /** @brief Returns the current value, converted to the requested type. */ 341 inline long getLong() const { return this->operator long(); } /** @brief Returns the current value, converted to the requested type. */ 342 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } /** @brief Returns the current value, converted to the requested type. */ 343 inline long long getLongLong() const { return this->operator long long(); } /** @brief Returns the current value, converted to the requested type. */ 344 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } /** @brief Returns the current value, converted to the requested type. */ 345 inline float getFloat() const { return this->operator float(); } /** @brief Returns the current value, converted to the requested type. */ 346 inline double getDouble() const { return this->operator double(); } /** @brief Returns the current value, converted to the requested type. */ 347 inline long double getLongDouble() const { return this->operator long double(); } /** @brief Returns the current value, converted to the requested type. */ 348 inline bool getBool() const { return this->operator bool(); } /** @brief Returns the current value, converted to the requested type. */ 349 inline void* getVoid() const { return this->operator void*(); } /** @brief Returns the current value, converted to the requested type. */ 350 inline std::string getString() const { return this->operator std::string(); } /** @brief Returns the current value, converted to the requested type. */ 351 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } /** @brief Returns the current value, converted to the requested type. */ 352 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } /** @brief Returns the current value, converted to the requested type. */ 353 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } /** @brief Returns the current value, converted to the requested type. */ 354 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */ 355 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } /** @brief Returns the current value, converted to the requested type. */ 356 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } /** @brief Returns the current value, converted to the requested type. */ 357 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } /** @brief Returns the current value, converted to the requested type. */ 358 template <typename T> inline T* getPointer() const { return ((T*)this->getVoid()); } /** @brief Returns the current value, converted to a T* pointer. */ 288 359 289 360 private: 290 inline void assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { this->value_->setValue(value); } else { this->changeValueContainer<char>(value); } } 291 inline void assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); } } 292 inline void assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { this->value_->setValue(value); } else { this->changeValueContainer<short>(value); } } 293 inline void assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); } } 294 inline void assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { this->value_->setValue(value); } else { this->changeValueContainer<int>(value); } } 295 inline void assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); } } 296 inline void assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { this->value_->setValue(value); } else { this->changeValueContainer<long>(value); } } 297 inline void assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); } } 298 inline void assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); } } 299 inline void assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); } } 300 inline void assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { this->value_->setValue(value); } else { this->changeValueContainer<float>(value); } } 301 inline void assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { this->value_->setValue(value); } else { this->changeValueContainer<double>(value); } } 302 inline void assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); } } 303 inline void assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); } } 304 inline void assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); } } 305 inline void assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); } } 306 inline void assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); } } 307 inline void assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); } } 308 inline void assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); } } 309 inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } 310 inline void assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); } } 311 inline void assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); } } 312 inline void assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); } } 313 361 inline void assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { this->value_->setValue(value); } else { this->changeValueContainer<char>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 362 inline void assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 363 inline void assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { this->value_->setValue(value); } else { this->changeValueContainer<short>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 364 inline void assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 365 inline void assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { this->value_->setValue(value); } else { this->changeValueContainer<int>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 366 inline void assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 367 inline void assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { this->value_->setValue(value); } else { this->changeValueContainer<long>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 368 inline void assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 369 inline void assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 370 inline void assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 371 inline void assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { this->value_->setValue(value); } else { this->changeValueContainer<float>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 372 inline void assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { this->value_->setValue(value); } else { this->changeValueContainer<double>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 373 inline void assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 374 inline void assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 375 inline void assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 376 inline void assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 377 inline void assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 378 inline void assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 379 inline void assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 380 inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 381 inline void assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 382 inline void assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 383 inline void assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */ 384 385 /** @brief Changes the value container. */ 314 386 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 387 /** @brief Creates a new value container (works only with specialized types). */ 315 388 template <typename T> void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } 316 389 317 MT_ValueBase* value_; 390 MT_ValueBase* value_; //! A pointer to the value container 318 391 }; 319 392 393 /** @brief Puts the MultiType on a stream by using the native << operator of the current type. */ 320 394 _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } 321 395 322 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_char); } 323 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_uchar); } 324 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_short); } 325 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_ushort); } 326 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_int); } 327 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_uint); } 328 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_long); } 329 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_ulong); } 330 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_longlong); } 331 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_ulonglong); } 332 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_float); } 333 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_double); } 334 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_longdouble); } 335 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_bool); } 336 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_void); } 337 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_string); } 338 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_vector2); } 339 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_vector3); } 340 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_vector4); } 341 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } 342 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_quaternion); } 343 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_radian); } 344 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_degree); } 345 346 template <> inline void MultiType::convert<std::string>() { this->setValue<std::string> (this->operator std::string()); } 347 template <> inline void MultiType::convert<orxonox::Vector2>() { this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } 348 template <> inline void MultiType::convert<orxonox::Vector3>() { this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } 349 template <> inline void MultiType::convert<orxonox::Vector4>() { this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } 350 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } 351 template <> inline void MultiType::convert<orxonox::Quaternion>() { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } 352 template <> inline void MultiType::convert<orxonox::Radian>() { this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } 353 template <> inline void MultiType::convert<orxonox::Degree>() { this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } 354 355 template <> inline void MultiType::convert<const std::string&>() { this->convert<std::string>(); } 356 template <> inline void MultiType::convert<const orxonox::Vector2&>() { this->convert<orxonox::Vector2>(); } 357 template <> inline void MultiType::convert<const orxonox::Vector3&>() { this->convert<orxonox::Vector3>(); } 358 template <> inline void MultiType::convert<const orxonox::Vector4&>() { this->convert<orxonox::Vector4>(); } 359 template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } 360 template <> inline void MultiType::convert<const orxonox::Quaternion&>() { this->convert<orxonox::Quaternion>(); } 361 template <> inline void MultiType::convert<const orxonox::Radian&>() { this->convert<orxonox::Radian>(); } 362 template <> inline void MultiType::convert<const orxonox::Degree&>() { this->convert<orxonox::Degree>(); } 396 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_char); } /** @brief Returns true if the current type equals the given type. */ 397 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_uchar); } /** @brief Returns true if the current type equals the given type. */ 398 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_short); } /** @brief Returns true if the current type equals the given type. */ 399 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_ushort); } /** @brief Returns true if the current type equals the given type. */ 400 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_int); } /** @brief Returns true if the current type equals the given type. */ 401 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_uint); } /** @brief Returns true if the current type equals the given type. */ 402 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_long); } /** @brief Returns true if the current type equals the given type. */ 403 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_ulong); } /** @brief Returns true if the current type equals the given type. */ 404 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_longlong); } /** @brief Returns true if the current type equals the given type. */ 405 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_ulonglong); } /** @brief Returns true if the current type equals the given type. */ 406 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_float); } /** @brief Returns true if the current type equals the given type. */ 407 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_double); } /** @brief Returns true if the current type equals the given type. */ 408 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_longdouble); } /** @brief Returns true if the current type equals the given type. */ 409 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_bool); } /** @brief Returns true if the current type equals the given type. */ 410 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_void); } /** @brief Returns true if the current type equals the given type. */ 411 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_string); } /** @brief Returns true if the current type equals the given type. */ 412 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_vector2); } /** @brief Returns true if the current type equals the given type. */ 413 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_vector3); } /** @brief Returns true if the current type equals the given type. */ 414 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_vector4); } /** @brief Returns true if the current type equals the given type. */ 415 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } /** @brief Returns true if the current type equals the given type. */ 416 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_quaternion); } /** @brief Returns true if the current type equals the given type. */ 417 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_radian); } /** @brief Returns true if the current type equals the given type. */ 418 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_degree); } /** @brief Returns true if the current type equals the given type. */ 419 420 // Specialization to avoid ambiguities with the conversion operator 421 template <> inline void MultiType::convert<std::string>() { this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */ 422 template <> inline void MultiType::convert<orxonox::Vector2>() { this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } /** @brief Converts the current value to the given type. */ 423 template <> inline void MultiType::convert<orxonox::Vector3>() { this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } /** @brief Converts the current value to the given type. */ 424 template <> inline void MultiType::convert<orxonox::Vector4>() { this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } /** @brief Converts the current value to the given type. */ 425 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */ 426 template <> inline void MultiType::convert<orxonox::Quaternion>() { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } /** @brief Converts the current value to the given type. */ 427 template <> inline void MultiType::convert<orxonox::Radian>() { this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } /** @brief Converts the current value to the given type. */ 428 template <> inline void MultiType::convert<orxonox::Degree>() { this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } /** @brief Converts the current value to the given type. */ 429 430 // Specialization to avoid ambiguities with the conversion operator 431 template <> inline void MultiType::convert<const std::string&>() { this->convert<std::string>(); } /** @brief Converts the current value to the given type. */ 432 template <> inline void MultiType::convert<const orxonox::Vector2&>() { this->convert<orxonox::Vector2>(); } /** @brief Converts the current value to the given type. */ 433 template <> inline void MultiType::convert<const orxonox::Vector3&>() { this->convert<orxonox::Vector3>(); } /** @brief Converts the current value to the given type. */ 434 template <> inline void MultiType::convert<const orxonox::Vector4&>() { this->convert<orxonox::Vector4>(); } /** @brief Converts the current value to the given type. */ 435 template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */ 436 template <> inline void MultiType::convert<const orxonox::Quaternion&>() { this->convert<orxonox::Quaternion>(); } /** @brief Converts the current value to the given type. */ 437 template <> inline void MultiType::convert<const orxonox::Radian&>() { this->convert<orxonox::Radian>(); } /** @brief Converts the current value to the given type. */ 438 template <> inline void MultiType::convert<const orxonox::Degree&>() { this->convert<orxonox::Degree>(); } /** @brief Converts the current value to the given type. */ 363 439 364 440 template <> void MultiType::createNewValueContainer(const char& value); … … 386 462 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value); 387 463 388 inline void MultiType::setValue(const char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 389 inline void MultiType::setValue(const unsigned char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 390 inline void MultiType::setValue(const short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 391 inline void MultiType::setValue(const unsigned short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 392 inline void MultiType::setValue(const int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 393 inline void MultiType::setValue(const unsigned int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 394 inline void MultiType::setValue(const long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 395 inline void MultiType::setValue(const unsigned long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 396 inline void MultiType::setValue(const long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 397 inline void MultiType::setValue(const unsigned long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 398 inline void MultiType::setValue(const float& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 399 inline void MultiType::setValue(const double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 400 inline void MultiType::setValue(const long double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 401 inline void MultiType::setValue(const bool& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 402 inline void MultiType::setValue( void* const& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 403 inline void MultiType::setValue(const std::string& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 404 inline void MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 405 inline void MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 406 inline void MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 407 inline void MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 408 inline void MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 409 inline void MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 410 inline void MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 411 412 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } } 464 inline void MultiType::setValue(const char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 465 inline void MultiType::setValue(const unsigned char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 466 inline void MultiType::setValue(const short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 467 inline void MultiType::setValue(const unsigned short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 468 inline void MultiType::setValue(const int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 469 inline void MultiType::setValue(const unsigned int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 470 inline void MultiType::setValue(const long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 471 inline void MultiType::setValue(const unsigned long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 472 inline void MultiType::setValue(const long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 473 inline void MultiType::setValue(const unsigned long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 474 inline void MultiType::setValue(const float& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 475 inline void MultiType::setValue(const double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 476 inline void MultiType::setValue(const long double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 477 inline void MultiType::setValue(const bool& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 478 inline void MultiType::setValue( void* const& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 479 inline void MultiType::setValue(const std::string& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 480 inline void MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 481 inline void MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 482 inline void MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 483 inline void MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 484 inline void MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 485 inline void MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 486 inline void MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 487 488 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } } /** @brief Assigns the given value and converts it to the current type. */ 413 489 414 490 #endif /* _MultiType_H__ */ -
code/trunk/src/util/MultiTypeValue.h
r1747 r1791 27 27 */ 28 28 29 /** 30 @file MultiTypeValue.h 31 @brief Declaration and Implementation of the MT_Value<T> class. 32 33 The MT_Value<T> class is used to hold a value of type T within a MultiType. 34 */ 35 29 36 #ifndef _MultiTypeValue_H__ 30 37 #define _MultiTypeValue_H__ … … 34 41 #include "MultiType.h" 35 42 43 /** 44 @brief The MT_Value<T> class is used to hold a value of type T within a MultiType. 45 */ 36 46 template <typename T> 37 47 struct MT_Value : public MultiType::MT_ValueBase 38 48 { 49 /** @brief Constructor: Assigns the value and the type identifier. */ 39 50 MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {} 40 51 52 /** @brief Creates a copy of itself. */ 41 53 inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); } 54 55 /** @brief Resets the current value to the default. */ 42 56 inline void reset() { this->value_ = T(); } 57 58 /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */ 43 59 inline void assimilate(const MultiType& other) { if (other.value_) { T temp; other.getValue(&temp); this->value_ = temp; } else { this->value_ = T(); } } 44 60 45 inline void setValue(const char& value) { this->value_ = getConvertedValue<char, T>(value); } 46 inline void setValue(const unsigned char& value) { this->value_ = getConvertedValue<unsigned char, T>(value); } 47 inline void setValue(const short& value) { this->value_ = getConvertedValue<short, T>(value); } 48 inline void setValue(const unsigned short& value) { this->value_ = getConvertedValue<unsigned short, T>(value); } 49 inline void setValue(const int& value) { this->value_ = getConvertedValue<int, T>(value); } 50 inline void setValue(const unsigned int& value) { this->value_ = getConvertedValue<unsigned int, T>(value); } 51 inline void setValue(const long& value) { this->value_ = getConvertedValue<long, T>(value); } 52 inline void setValue(const unsigned long& value) { this->value_ = getConvertedValue<unsigned long, T>(value); } 53 inline void setValue(const long long& value) { this->value_ = getConvertedValue<long long, T>(value); } 54 inline void setValue(const unsigned long long& value) { this->value_ = getConvertedValue<unsigned long long, T>(value); } 55 inline void setValue(const float& value) { this->value_ = getConvertedValue<float, T>(value); } 56 inline void setValue(const double& value) { this->value_ = getConvertedValue<double, T>(value); } 57 inline void setValue(const long double& value) { this->value_ = getConvertedValue<long double, T>(value); } 58 inline void setValue(const bool& value) { this->value_ = getConvertedValue<bool, T>(value); } 59 inline void setValue( void* const& value) { this->value_ = getConvertedValue<void*, T>(value); } 60 inline void setValue(const std::string& value) { this->value_ = getConvertedValue<std::string, T>(value); } 61 inline void setValue(const orxonox::Vector2& value) { this->value_ = getConvertedValue<orxonox::Vector2, T>(value); } 62 inline void setValue(const orxonox::Vector3& value) { this->value_ = getConvertedValue<orxonox::Vector3, T>(value); } 63 inline void setValue(const orxonox::Vector4& value) { this->value_ = getConvertedValue<orxonox::Vector4, T>(value); } 64 inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } 65 inline void setValue(const orxonox::Quaternion& value) { this->value_ = getConvertedValue<orxonox::Quaternion, T>(value); } 66 inline void setValue(const orxonox::Radian& value) { this->value_ = getConvertedValue<orxonox::Radian, T>(value); } 67 inline void setValue(const orxonox::Degree& value) { this->value_ = getConvertedValue<orxonox::Degree, T>(value); } 61 inline void setValue(const char& value) { this->value_ = getConvertedValue<char, T>(value); } /** @brief Assigns the value by converting it to T. */ 62 inline void setValue(const unsigned char& value) { this->value_ = getConvertedValue<unsigned char, T>(value); } /** @brief Assigns the value by converting it to T. */ 63 inline void setValue(const short& value) { this->value_ = getConvertedValue<short, T>(value); } /** @brief Assigns the value by converting it to T. */ 64 inline void setValue(const unsigned short& value) { this->value_ = getConvertedValue<unsigned short, T>(value); } /** @brief Assigns the value by converting it to T. */ 65 inline void setValue(const int& value) { this->value_ = getConvertedValue<int, T>(value); } /** @brief Assigns the value by converting it to T. */ 66 inline void setValue(const unsigned int& value) { this->value_ = getConvertedValue<unsigned int, T>(value); } /** @brief Assigns the value by converting it to T. */ 67 inline void setValue(const long& value) { this->value_ = getConvertedValue<long, T>(value); } /** @brief Assigns the value by converting it to T. */ 68 inline void setValue(const unsigned long& value) { this->value_ = getConvertedValue<unsigned long, T>(value); } /** @brief Assigns the value by converting it to T. */ 69 inline void setValue(const long long& value) { this->value_ = getConvertedValue<long long, T>(value); } /** @brief Assigns the value by converting it to T. */ 70 inline void setValue(const unsigned long long& value) { this->value_ = getConvertedValue<unsigned long long, T>(value); } /** @brief Assigns the value by converting it to T. */ 71 inline void setValue(const float& value) { this->value_ = getConvertedValue<float, T>(value); } /** @brief Assigns the value by converting it to T. */ 72 inline void setValue(const double& value) { this->value_ = getConvertedValue<double, T>(value); } /** @brief Assigns the value by converting it to T. */ 73 inline void setValue(const long double& value) { this->value_ = getConvertedValue<long double, T>(value); } /** @brief Assigns the value by converting it to T. */ 74 inline void setValue(const bool& value) { this->value_ = getConvertedValue<bool, T>(value); } /** @brief Assigns the value by converting it to T. */ 75 inline void setValue( void* const& value) { this->value_ = getConvertedValue<void*, T>(value); } /** @brief Assigns the value by converting it to T. */ 76 inline void setValue(const std::string& value) { this->value_ = getConvertedValue<std::string, T>(value); } /** @brief Assigns the value by converting it to T. */ 77 inline void setValue(const orxonox::Vector2& value) { this->value_ = getConvertedValue<orxonox::Vector2, T>(value); } /** @brief Assigns the value by converting it to T. */ 78 inline void setValue(const orxonox::Vector3& value) { this->value_ = getConvertedValue<orxonox::Vector3, T>(value); } /** @brief Assigns the value by converting it to T. */ 79 inline void setValue(const orxonox::Vector4& value) { this->value_ = getConvertedValue<orxonox::Vector4, T>(value); } /** @brief Assigns the value by converting it to T. */ 80 inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } /** @brief Assigns the value by converting it to T. */ 81 inline void setValue(const orxonox::Quaternion& value) { this->value_ = getConvertedValue<orxonox::Quaternion, T>(value); } /** @brief Assigns the value by converting it to T. */ 82 inline void setValue(const orxonox::Radian& value) { this->value_ = getConvertedValue<orxonox::Radian, T>(value); } /** @brief Assigns the value by converting it to T. */ 83 inline void setValue(const orxonox::Degree& value) { this->value_ = getConvertedValue<orxonox::Degree, T>(value); } /** @brief Assigns the value by converting it to T. */ 68 84 69 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } 70 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } 71 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } 72 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } 73 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } 74 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } 75 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } 76 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } 77 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } 78 inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } 79 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } 80 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } 81 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } 82 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, false); } 83 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } 84 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_); } 85 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_); } 86 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_); } 87 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_); } 88 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); } 89 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); } 90 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_); } 91 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_); } 85 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 86 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 87 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 88 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 89 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 90 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 91 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 92 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 93 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 94 inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 95 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 96 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 97 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 98 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, false); } /** @brief Returns the current value, converted to the requested type. */ 99 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */ 100 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 101 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 102 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 103 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 104 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); } /** @brief Returns the current value, converted to the requested type. */ 105 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 106 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 107 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_); } /** @brief Returns the current value, converted to the requested type. */ 92 108 109 /** @brief Puts the current value on the stream */ 93 110 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 94 111 95 T value_; 112 T value_; //! The stored value 96 113 }; 97 114 -
code/trunk/src/util/OutputBuffer.cc
r1784 r1791 27 27 */ 28 28 29 /** 30 @file OutputBuffer.cc 31 @brief Implementation of the OutputBuffer. 32 */ 33 29 34 #include "OutputBuffer.h" 30 31 35 32 36 namespace orxonox 33 37 { 34 const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; 38 const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; //! The maximal number of lines that can be stored within the OutputBuffer. 35 39 40 /** 41 @brief Adds a new listener to the list. 42 @param listener The new listener 43 */ 36 44 void OutputBuffer::registerListener(OutputBufferListener* listener) 37 45 { … … 39 47 } 40 48 49 /** 50 @brief Removes a listener from the list. 51 @param listener The listener 52 */ 41 53 void OutputBuffer::unregisterListener(OutputBufferListener* listener) 42 54 { … … 50 62 } 51 63 64 /** 65 @brief Puts a stream manipulator to the stream. 66 @param manipulator The manipulator 67 */ 52 68 OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&)) 53 69 { … … 57 73 } 58 74 75 /** 76 @brief Puts a stream manipulator to the stream. 77 @param manipulator The manipulator 78 */ 59 79 OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&)) 60 80 { … … 64 84 } 65 85 86 /** 87 @brief Puts a stream manipulator to the stream. 88 @param manipulator The manipulator 89 */ 66 90 OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&)) 67 91 { … … 71 95 } 72 96 97 /** 98 @brief Removes the first line from the stream and assigns it to a given string object. 99 @param output The string object to assign the first line 100 @return True if there was at least one line in the stream and this line was successfully assigned 101 102 It's important to know the returned line will be removed from the stream. If there are more than one 103 listener, they have to cooperate to avoid conflicts. 104 */ 73 105 bool OutputBuffer::getLine(std::string* output) 74 106 { … … 90 122 } 91 123 124 /** 125 @brief Calls the outputChanged() function of all registered listeners. 126 */ 92 127 void OutputBuffer::callListeners() 93 128 { -
code/trunk/src/util/OutputBuffer.h
r1747 r1791 27 27 */ 28 28 29 /** 30 @file OutputBuffer.h 31 @brief Declaration of the OutputBuffer class. 32 33 The OutputBuffer acts almost like std::ostream. You can put text and other values to the 34 OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd 35 listeners if new text gets assigned. 36 The listeners are then able to retrieve the text line by line. 37 38 It's important to know that getLine actually removes the line from the OutputBuffer, so it's 39 better to only have one "active" listener. 40 */ 41 29 42 #ifndef _OutputBuffer_H__ 30 43 #define _OutputBuffer_H__ … … 38 51 namespace orxonox 39 52 { 53 /** 54 @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer. 55 56 This class is pure virtual, so an inheriting class has to implement the function on it's own. 57 The function get's called, if an instance of the inheriting class registers as a listener at 58 an OutputBuffer and this buffer changes. 59 */ 40 60 class _UtilExport OutputBufferListener 41 61 { … … 49 69 }; 50 70 71 /** 72 @brief The OutputBuffer acts almost like std::ostream and stores the assigned text. 73 74 If text gets assigned by using the << operator or another function, the OutputBuffer 75 calls it's listeners, allowing them to retrieve the text line by line. 76 77 It's important to know that getLine actually removes the line from the OutputBuffer, so it's 78 better to only have one "active" listener. 79 */ 51 80 class _UtilExport OutputBuffer 52 81 { … … 55 84 ~OutputBuffer() {} 56 85 86 /** 87 @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners. 88 @param object The object/value to assign 89 */ 57 90 template <class T> 58 91 inline OutputBuffer& operator<<(T object) … … 63 96 } 64 97 98 /** 99 @brief Reads the stored text of the other OutputBuffer and calls the listeners. 100 @param object The other OutputBuffer 101 */ 65 102 template <const OutputBuffer&> 66 103 inline OutputBuffer& operator<<(const OutputBuffer& object) … … 75 112 OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&)); 76 113 114 /** 115 @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners. 116 @param object The object/value 117 */ 77 118 template <class T> 78 119 inline void add(T object) … … 82 123 } 83 124 125 /** 126 @brief Assigns an object/value and adds std::endl. 127 @param object The object/value 128 */ 84 129 template <class T> 85 130 inline void addLine(T object) … … 89 134 } 90 135 136 /** 137 @brief Puts std::endl to the stream and calls the listeners. 138 */ 91 139 inline void newline() 92 140 { … … 95 143 } 96 144 145 /** 146 @brief Flushes the stored text (~empties the OutputBuffer). 147 */ 97 148 inline void flush() 98 149 { … … 105 156 void unregisterListener(OutputBufferListener* listener); 106 157 158 /** 159 @brief Returns the internal stringstream object. 160 */ 107 161 inline std::stringstream& getStream() 108 { return this->stream_; } 162 { 163 return this->stream_; 164 } 109 165 110 166 private: 111 167 void callListeners(); 112 168 113 std::stringstream stream_; 114 std::list<OutputBufferListener*> listeners_; 169 std::stringstream stream_; //! The stringstream that stores the assigned text 170 std::list<OutputBufferListener*> listeners_; //! A list of all listeners 115 171 }; 116 172 } -
code/trunk/src/util/OutputHandler.cc
r1747 r1791 46 46 this->logfilename_ = logfilename; 47 47 this->logfile_.open(this->logfilename_.c_str(), std::fstream::out); 48 this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl; 48 this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl; // Todo: Get date and time 49 49 this->logfile_.flush(); 50 50 } … … 122 122 123 123 /** 124 @brief Overloaded << operator, redirects the output to the console and the logfile.124 @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell. 125 125 @param manipulator A function, manipulating the outstream. 126 126 @return A reference to the OutputHandler itself … … 144 144 145 145 /** 146 @brief Overloaded << operator, redirects the output to the console and the logfile.146 @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell. 147 147 @param manipulator A function, manipulating the outstream. 148 148 @return A reference to the OutputHandler itself … … 166 166 167 167 /** 168 @brief Overloaded << operator, redirects the output to the console and the logfile.168 @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell. 169 169 @param manipulator A function, manipulating the outstream. 170 170 @return A reference to the OutputHandler itself -
code/trunk/src/util/OutputHandler.h
r1747 r1791 32 32 33 33 The OutputHandler acts like std::cout, but output isn't only shown in the console, 34 but also written to the logfile .34 but also written to the logfile and the ingame shell. 35 35 */ 36 36 … … 48 48 namespace orxonox 49 49 { 50 //! The OutputHandler acts like std::cout, but redirects output to the console AND the logfile.50 //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell. 51 51 class _UtilExport OutputHandler 52 52 { -
code/trunk/src/util/String.cc
r1625 r1791 27 27 */ 28 28 29 /** 30 @file String.cc 31 @brief Implementation of several string manipulation functions. 32 */ 33 29 34 #include "String.h" 30 35 … … 33 38 34 39 /** 35 @brief Blank string as variable so you can use const std::string& even 36 if you have to return "". 40 @brief Blank string as variable so you can use const std::string& even if you have to return "". 37 41 */ 38 42 std::string blankString = ""; … … 273 277 } 274 278 279 /** 280 @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled. 281 @param str The string to manipulate 282 @return The string with added slashes 283 */ 275 284 std::string addSlashes(const std::string& str) 276 285 { … … 291 300 } 292 301 302 /** 303 @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash. 304 @param str The string to manipulate 305 @return The string with removed slashes 306 */ 293 307 std::string removeSlashes(const std::string& str) 294 308 { -
code/trunk/src/util/String.h
r1625 r1791 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * Benjamin Grauer25 * ... 26 26 * 27 27 */ 28 29 /** 30 @file String.h 31 @brief Declaration of several string manipulation functions, used in many parts of the game. 32 */ 28 33 29 34 #ifndef _Util_String_H__ -
code/trunk/src/util/SubString.cc
r1505 r1791 25 25 * Benjamin Grauer 26 26 * 27 27 28 // 28 29 // splitLine … … 33 34 // Copyright (c) 2005 Clemens Wacha. All rights reserved. 34 35 // 36 37 * Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode. 35 38 */ 36 39 -
code/trunk/src/util/SubString.h
r1784 r1791 34 34 // Copyright (c) 2005 Clemens Wacha. All rights reserved. 35 35 36 * Extended by Fabian 'x3n' Landau withthe SL_PARENTHESES mode.36 * Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode. 37 37 */ 38 38 -
code/trunk/src/util/XMLIncludes.h
r1505 r1791 21 21 * 22 22 * Author: 23 * ...23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... 26 26 * 27 27 */ 28 29 /** 30 @file XMLIncludes.h 31 @brief Forward declarations of some XML classes. 32 */ 28 33 29 34 #include "UtilPrereqs.h"
Note: See TracChangeset
for help on using the changeset viewer.