Changeset 7323 for code/branches
- Timestamp:
- Sep 2, 2010, 3:16:08 AM (14 years ago)
- Location:
- code/branches/doc
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/doc/api/Groups.h
r7318 r7323 26 26 * 27 27 */ 28 28 29 29 /** 30 30 @defgroup Util Util … … 37 37 /** 38 38 @defgroup Core Core 39 39 40 40 The core library contains the framework of Orxonox - all important classes, functions, and macros 41 41 that are used to create and manage classes and objects. Almost all classes in Orxonox need at least … … 85 85 /** 86 86 @defgroup Network Network 87 87 88 88 The network library is used to connect clients and server, to synchronize objects and variables, and 89 89 to transmit network function calls. It contains the central @ref orxonox::Server "Server" and … … 94 94 /** 95 95 @defgroup Tools Tools 96 96 97 97 The tools are a bunch of utilities that belong to the Orxonox library, but are independent of other 98 98 features. … … 101 101 /** 102 102 @defgroup Orxonox Orxonox 103 103 104 104 The Orxonox library contains the central and most important classes of the game. Managers, interfaces, 105 105 base-classes, and more are located in Orxonox. More specialized classes that inherit of the base-classes … … 109 109 /** 110 110 @defgroup Modules Modules 111 111 112 112 The modules are libraries that depend on the Orxonox library and that are loaded dynamically on runtime 113 113 (in contrast to statically loaded libraries like util and core). Each module contains some classes that -
code/branches/doc/src/libraries/core/Iterator.h
r7271 r7323 200 200 @return The Iterator itself 201 201 */ 202 inline Iterator<T> operator++(int i)202 inline Iterator<T> operator++(int) 203 203 { 204 204 Iterator<T> copy = *this; -
code/branches/doc/src/libraries/core/ObjectListIterator.h
r7297 r7323 131 131 @return The ObjectListIterator itself 132 132 */ 133 inline ObjectListIterator<T> operator++(int i)133 inline ObjectListIterator<T> operator++(int) 134 134 { 135 135 ObjectListIterator<T> copy = *this; -
code/branches/doc/src/libraries/util/Clipboard.cc
r6417 r7323 54 54 55 55 /** 56 @brief Puts text into the windows-clipboard 57 @param text The text 56 @brief Puts text into the Windows-clipboard 58 57 @return True if the action was successful 59 58 */ … … 119 118 namespace orxonox 120 119 { 121 static std::string clipboard; // !< Keeps the text of our internal clipboard120 static std::string clipboard; ///< Keeps the text of our internal clipboard 122 121 123 122 /** 124 123 @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard. 125 @param text The text 126 @return True 124 @see fromClipboard() 127 125 */ 128 126 bool toClipboard(const std::string& text) … … 134 132 /** 135 133 @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard. 136 @ return The text134 @see toClipboard() 137 135 */ 138 136 std::string fromClipboard() -
code/branches/doc/src/libraries/util/Clipboard.h
r5781 r7323 29 29 /** 30 30 @file 31 @brief Some functions to exchange text between the OS clipboard and Orxonox. 31 @ingroup Util Command 32 @brief Some functions to exchange text between the OS clipboard and the Shell in Orxonox. 32 33 33 34 Use fromClipboard() to get text from the clipboard (if there is any text) and 34 toClipboard( text) to put text into the clipboard.35 toClipboard() to put text into the clipboard. 35 36 36 Th ose 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 exchange38 with other programs isn't possible.37 These functions can only work properly if there's an OS-specific implementation 38 in Clipboard.cc. If a specific OS is not supported, the clipboard only works 39 within Orxonox, but the exchange with other programs is not possible. 39 40 */ 40 41 -
code/branches/doc/src/libraries/util/Debug.h
r7318 r7323 30 30 /** 31 31 @defgroup COUT COUT(x) output macro 32 @ingroup Output32 @ingroup Util Output 33 33 */ 34 34 35 35 /** 36 36 @file 37 @ingroup COUT37 @ingroup Util COUT 38 38 @brief 39 39 Handles different output-levels of errors, warnings, infos, and debug information. -
code/branches/doc/src/libraries/util/Math.cc
r7291 r7323 91 91 @param mydirection My viewing direction 92 92 @param otherposition The position of the other object 93 @return The angle 93 @return The angle in radian 94 94 95 95 Examples: 96 If the other object is exactly in front of me, the function returns 0.97 If the other object is exactly behind me, the function returns pi.98 If the other object is exactly right/left to me (or above/below), the function returns pi/2.96 - If the other object is exactly in front of me, the function returns 0. 97 - If the other object is exactly behind me, the function returns pi. 98 - If the other object is exactly right/left to me (or above/below), the function returns pi/2. 99 99 */ 100 100 float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition) … … 117 117 118 118 Examples: 119 If the other object is exactly in front of me, the function returns Vector2(0, 0).120 If the other object is exactly at my left, the function returns Vector2(-1, 0).121 If the other object is exactly at my right, the function returns Vector2(1, 0).122 If the other object is only a bit at my right, the function still returns Vector2(1, 0).123 If the other object is exactly above me, the function returns Vector2(0, 1).119 - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>. 120 - If the other object is exactly at my left, the function returns <tt>Vector2(-1, 0)</tt>. 121 - If the other object is exactly at my right, the function returns <tt>Vector2(1, 0)</tt>. 122 - If the other object is only a bit at my right, the function still returns <tt>Vector2(1, 0)</tt>. 123 - If the other object is exactly above me, the function returns <tt>Vector2(0, 1)</tt>. 124 124 */ 125 125 orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) … … 157 157 158 158 Examples: 159 If the other object is exactly in front of me, the function returns Vector2(0, 0).160 If the other object is exactly at my left, the function returns Vector2(-0.5, 0).161 If the other object is exactly at my right, the function returns Vector2(0.5, 0).162 If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).163 If the other object is exactly above me, the function returns Vector2(0, 0.5).159 - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>. 160 - If the other object is exactly at my left, the function returns <tt>Vector2(-0.5, 0)</tt>. 161 - If the other object is exactly at my right, the function returns <tt>Vector2(0.5, 0)</tt>. 162 - If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>. 163 - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>. 164 164 */ 165 165 orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition) … … 220 220 } 221 221 222 /** 223 @brief Returns a unique number. This function will never return the same value twice. 224 */ 222 225 unsigned long getUniqueNumber() 223 226 { -
code/branches/doc/src/libraries/util/Math.h
r7184 r7323 28 28 29 29 /** 30 @defgroup Math Mathematical functions 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup Util Math 31 37 @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace. 32 38 */ … … 62 68 namespace math 63 69 { 64 const float pi = 3.14159265f; 65 const float pi_2 = 1.57079633f; 66 const float pi_4 = 7.85398163e-1f; 67 const float e = 2.71828183f; 68 const float sqrt2 = 1.41421356f; 69 const float sqrt2_2 = 7.07106781e-1f; 70 71 const double pi_d = 3.14159265358979324; 72 const double pi_2_d = 1.57079632679489662; 73 const double pi_4_d = 7.85398163397448310e-1; 74 const double e_d = 2.71828182845904524; 75 const double sqrt2_d = 1.41421356237309505; 76 const double sqrt2_2_d = 7.07106781186547524e-1; 70 const float pi = 3.14159265f; ///< PI 71 const float pi_2 = 1.57079633f; ///< PI / 2 72 const float pi_4 = 7.85398163e-1f; ///< PI / 4 73 const float e = 2.71828183f; ///< e 74 const float sqrt2 = 1.41421356f; ///< sqrt(2) 75 const float sqrt2_2 = 7.07106781e-1f; ///< sqrt(2) / 2 76 77 const double pi_d = 3.14159265358979324; ///< PI (double) 78 const double pi_2_d = 1.57079632679489662; ///< PI / 2 (double) 79 const double pi_4_d = 7.85398163397448310e-1; ///< PI / 4 (double) 80 const double e_d = 2.71828182845904524; ///< e (double) 81 const double sqrt2_d = 1.41421356237309505; ///< sqrt(2) (double) 82 const double sqrt2_2_d = 7.07106781186547524e-1; ///< sqrt(2) / 2 (double) 77 83 } 78 84 … … 101 107 102 108 /** 103 @brief Keeps a value between a lower and an upper limit. 109 @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max. 104 110 @param x The value 105 111 @param min The lower limit … … 119 125 120 126 /** 121 @brief Returns the square value (x^2).127 @brief Returns the squared value (x^2). 122 128 */ 123 129 template <typename T> … … 128 134 129 135 /** 130 @brief Returns the cube value (x^3).136 @brief Returns the cubed value (x^3). 131 137 */ 132 138 template <typename T> … … 137 143 138 144 /** 139 @brief Rounds the value .145 @brief Rounds the value to the nearest integer. 140 146 */ 141 147 template <typename T> … … 149 155 @param x The value 150 156 @param max The operand 157 158 The built in modulo operator % yields a strange behavior with negative values. 159 This function corrects this - the result is guaranteed to lie always between 160 zero and (max-1). 161 162 Example: 163 @code 164 int var = 11 % 10; // 1 165 int var = -1 % 10; // -1 166 167 int var = mod(11, 10); // 1 168 int var = mod(-1, 10); // 9 169 @endcode 151 170 */ 152 171 template <typename T> … … 159 178 } 160 179 180 /** 181 @brief Returns a "zero" value for the given type. 182 @note This is the default template of the zeroise() function. The template is spezialized for each supported type. 183 184 The exact return value of the function depends on the type. For @c int this is 0, 185 for @c float it's 0.0f. For a @c std::string the function returns "" and for 186 @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>. 187 */ 161 188 template <typename T> 162 189 inline T zeroise() … … 192 219 template <> inline orxonox::Quaternion zeroise<orxonox::Quaternion>() { return orxonox::Quaternion (0, 0, 0, 0); } 193 220 194 //! Provides zero value symbols that can be returned as reference 221 /** 222 @brief Provides zero value symbols that can be returned as reference 223 @see zeroise() 224 */ 195 225 template <typename T> 196 226 struct NilValue … … 207 237 /** 208 238 @brief Interpolates between two values for a time between 0 and 1. 209 @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 iftime is between 0 and 1.210 @param start The value at time = 0211 @param end The value at time = 1212 @return The interpolat ionat a given time239 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 240 @param start The value at @a time = 0 241 @param end The value at @a time = 1 242 @return The interpolated value at a given time 213 243 */ 214 244 template <typename T> … … 220 250 /** 221 251 @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again. 222 @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 iftime is between 0 and 1.223 @param start The value at time = 0224 @param end The value at time = 1225 @return The smoothed interpolationat a given time252 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 253 @param start The value at @a time = 0 254 @param end The value at @a time = 1 255 @return The interpolated value at a given time 226 256 */ 227 257 template <typename T> … … 232 262 233 263 /** 234 @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.264 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. 235 265 */ 236 266 inline float rnd() … … 240 270 241 271 /** 242 @brief Returns a random number between 0 and almost max: 0 <= rnd < max.272 @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>. 243 273 @param max The maximum 244 274 */ … … 249 279 250 280 /** 251 @brief Returns a random number between min and almost max: min <= rnd < max.281 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 252 282 @param min The minimum 253 283 @param max The maximum … … 268 298 _UtilExport unsigned long getUniqueNumber(); 269 299 300 /** 301 @brief A Vector class containing two integers @a x and @a y. 302 */ 270 303 class IntVector2 271 304 { … … 277 310 }; 278 311 312 /** 313 @brief A Vector class containing three integers @a x, @a y, and @a z. 314 */ 279 315 class IntVector3 280 316 { -
code/branches/doc/src/libraries/util/MultiType.cc
r5738 r7323 159 159 } 160 160 161 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */162 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */163 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */164 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */165 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */166 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */167 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */168 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */169 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */170 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */171 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */172 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */173 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */174 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */175 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } / ** @brief Returns the current value, converted to the requested type. */176 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } / ** @brief Returns the current value, converted to the requested type. */177 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } / ** @brief Returns the current value, converted to the requested type. */178 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } / ** @brief Returns the current value, converted to the requested type. */179 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } / ** @brief Returns the current value, converted to the requested type. */180 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } / ** @brief Returns the current value, converted to the requested type. */181 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } / ** @brief Returns the current value, converted to the requested type. */182 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } / ** @brief Returns the current value, converted to the requested type. */183 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } / ** @brief Returns the current value, converted to the requested type. */184 185 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } / ** @brief Creates a new value container for the given type. */186 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } / ** @brief Creates a new value container for the given type. */187 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } / ** @brief Creates a new value container for the given type. */188 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } / ** @brief Creates a new value container for the given type. */189 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } / ** @brief Creates a new value container for the given type. */190 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } / ** @brief Creates a new value container for the given type. */191 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } / ** @brief Creates a new value container for the given type. */192 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } / ** @brief Creates a new value container for the given type. */193 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } / ** @brief Creates a new value container for the given type. */194 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } / ** @brief Creates a new value container for the given type. */195 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } / ** @brief Creates a new value container for the given type. */196 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } / ** @brief Creates a new value container for the given type. */197 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } / ** @brief Creates a new value container for the given type. */198 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } / ** @brief Creates a new value container for the given type. */199 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } / ** @brief Creates a new value container for the given type. */200 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } / ** @brief Creates a new value container for the given type. */201 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } / ** @brief Creates a new value container for the given type. */202 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } / ** @brief Creates a new value container for the given type. */203 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } / ** @brief Creates a new value container for the given type. */204 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } / ** @brief Creates a new value container for the given type. */205 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } / ** @brief Creates a new value container for the given type. */206 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } / ** @brief Creates a new value container for the given type. */207 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } / ** @brief Creates a new value container for the given type. */161 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 162 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 163 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 164 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 165 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 166 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 167 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 168 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 169 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 170 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 171 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 172 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 173 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 174 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 175 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type. 176 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } ///< Returns the current value, converted to the requested type. 177 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } ///< Returns the current value, converted to the requested type. 178 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } ///< Returns the current value, converted to the requested type. 179 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } ///< Returns the current value, converted to the requested type. 180 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } ///< Returns the current value, converted to the requested type. 181 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } ///< Returns the current value, converted to the requested type. 182 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } ///< Returns the current value, converted to the requested type. 183 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } ///< Returns the current value, converted to the requested type. 184 185 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } ///< Creates a new value container for the given type. 186 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } ///< Creates a new value container for the given type. 187 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } ///< Creates a new value container for the given type. 188 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } ///< Creates a new value container for the given type. 189 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } ///< Creates a new value container for the given type. 190 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } ///< Creates a new value container for the given type. 191 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } ///< Creates a new value container for the given type. 192 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } ///< Creates a new value container for the given type. 193 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } ///< Creates a new value container for the given type. 194 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } ///< Creates a new value container for the given type. 195 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } ///< Creates a new value container for the given type. 196 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } ///< Creates a new value container for the given type. 197 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } ///< Creates a new value container for the given type. 198 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } ///< Creates a new value container for the given type. 199 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } ///< Creates a new value container for the given type. 200 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } ///< Creates a new value container for the given type. 201 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } ///< Creates a new value container for the given type. 202 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } ///< Creates a new value container for the given type. 203 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } ///< Creates a new value container for the given type. 204 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } ///< Creates a new value container for the given type. 205 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } ///< Creates a new value container for the given type. 206 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } ///< Creates a new value container for the given type. 207 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } ///< Creates a new value container for the given type. 208 208 } -
code/branches/doc/src/libraries/util/MultiType.h
r7291 r7323 28 28 29 29 /** 30 @defgroup MultiType MultiType 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup Util MultiType 31 37 @brief Declaration of the MultiType and some helper constructs. 32 38 39 @anchor MultiTypeExamples 40 33 41 The MultiType can hold a value of one of the following types: 34 - all primitives 35 - all pointers 36 - st ring42 - all primitives (int, float, bool, etc.) 43 - all pointers (void* and T*) 44 - std::string 37 45 - Vector2, Vector3, Vector4 38 46 - Quaternion … … 40 48 - Radian, Degree 41 49 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. 50 The MultiType has an internal "type" determined by the first assigned value, using one of these ways: 51 - @ref orxonox::MultiType::MultiType "The constructor" 52 - The assignment operator= (orxonox::MultiType::operator=()) 53 - @ref orxonox::MultiType::setValue() "setValue(value)" 54 55 If you assign another value of another type, the MultiType keeps "its" type and 56 converts the new value to the old type. 48 57 49 58 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 value51 - setType<T>() set's the type to T and resets the value59 - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value 60 - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>() 52 61 - setValue<T>(value) assigns a new value and changes the type to T. 53 62 54 63 Examples: 55 64 @code 56 MultiType a = 10; ;// a has now the type int and the value 1065 MultiType a = 10; // a has now the type int and the value 10 57 66 a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3 58 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14 59 a.convert<bool>(); // converts 3.14 to bool, which is true67 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f 68 a.convert<bool>(); // converts 3.14f to bool, which is true 60 69 a = false; // assigns false, this is equivalent to a.setValue(false) 61 70 @endcode 71 72 You can pass a MultiType to a function as an argument, even if the argument is 73 not of type MultiType. This works, because the MultiType is automatically converted 74 to the right type. 75 76 Example: 77 @code 78 void myfunction(int value) 79 { 80 COUT(0) << "doubled value is " << (2 * value) << std::endl; 81 } 82 83 MultiType a = "50"; // Note: We assigned a string 84 myfunction(a); // a is converted to int and passed to the function, which prints "value is 100" 85 @endcode 86 87 Note however that it is of course quite expensive to convert values, especially std::string <-> value. 88 So if you can, always assign a value with the right type to avoid conversion. 62 89 63 90 @note … … 129 156 - Radian, Degree 130 157 131 The internal type of a MultiType is determined by the first assigned value, but can be 132 changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned 133 the normal way (operator=, setValue(value)), the value gets converted to the current internal 134 type of the MultiType. 158 For more information and some examples see the description @ref MultiTypeExamples "here". 159 160 @see MultiType.h 135 161 */ 136 162 class _UtilExport MultiType … … 155 181 virtual bool assimilate(const MultiType& other) = 0; 156 182 157 / ** @brief Returns the type of the current value. */183 /// Returns the type of the current value. 158 184 const MT_Type::Value& getType() const { return this->type_; } 159 185 160 / ** @brief Checks whether the value is a default one. */186 /// Checks whether the value is a default one. 161 187 bool hasDefaultValue() const { return this->bHasDefaultValue_; } 162 188 … … 239 265 virtual uint8_t getSize() const=0; 240 266 241 MT_Type::Value type_; // !< The type of the current value242 bool bHasDefaultValue_; // !< True if the last conversion wasn't successful267 MT_Type::Value type_; ///< The type of the current value 268 bool bHasDefaultValue_; ///< True if the last conversion wasn't successful 243 269 }; 244 270 245 271 public: 246 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. */247 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */248 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */249 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */250 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */251 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */252 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */253 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */254 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */255 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */256 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */257 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */258 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */259 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */260 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */261 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */262 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */263 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */264 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */265 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */266 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */267 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */268 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */269 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */270 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } / ** @brief Constructor: Assigns the given mbool and converts it to bool. */271 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. */272 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } / ** @brief Copyconstructor: Assigns value and type of the other MultiType. */273 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } / ** @brief Constructor: Sets the type, the next assignment will determine the value. */274 275 / ** @brief Destructor: Deletes the MT_Value. */272 inline MultiType() : value_(0) {} ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 273 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 274 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 275 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 276 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 277 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 278 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 279 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 280 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 281 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 282 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 283 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 284 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 285 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 286 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 287 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 288 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 289 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 290 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 291 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 292 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 293 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 294 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 295 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 296 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } ///< Constructor: Assigns the given mbool and converts it to bool. 297 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type. 298 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } ///< Copyconstructor: Assigns value and type of the other MultiType. 299 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } ///< Constructor: Sets the type, the next assignment will determine the value. 300 301 /// Destructor: Deletes the MT_Value. 276 302 inline ~MultiType() { if (this->value_) { delete this->value_; } } 277 303 278 template <typename V> inline 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. */279 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } / ** @brief Assigns a pointer. */280 inline 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. */281 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } / ** @brief Resets the value and changes the type. */304 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType. 305 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } ///< Assigns a pointer. 306 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType. 307 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } ///< Resets the value and changes the type. 282 308 283 309 inline bool setValue(const char& value); … … 305 331 inline bool setValue(const orxonox::Degree& value); 306 332 inline bool setValue(const char* value); 307 / ** @brief Assigns a pointer. */333 /// Assigns a pointer. 308 334 template <typename V> inline bool setValue(V* value) 309 335 { … … 313 339 return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); 314 340 } 315 / ** @brief Assigns the value of the other MultiType and converts it to the current type. */341 /// Assigns the value of the other MultiType and converts it to the current type. 316 342 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } 317 / ** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */343 /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). 318 344 template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); } 319 345 320 346 321 / ** @brief Copies the other MultiType by assigning value and type. */347 /// Copies the other MultiType by assigning value and type. 322 348 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 323 349 324 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } /** @brief Converts the current value to type T. */ 325 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 350 /// Converts the current value to type T. 351 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } 352 /// Converts the current value to the type of the other MultiType. 353 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } 326 354 bool convert(MT_Type::Value type); 327 355 328 / ** @brief Current content gets deleted. New type is MT_Type::Null */356 /// Current content gets deleted. New type is MT_Type::Null 329 357 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; } 330 / ** @brief Current content gets overridden with default zero value */358 /// Current content gets overridden with default zero value 331 359 inline void resetValue() { if (this->value_) this->value_->reset(); } 332 360 333 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */ 334 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. */ 335 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */ 336 337 /** @brief Returns the current type. */ 361 /// Resets the value and changes the internal type to T. 362 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } 363 /// Resets the value and changes the internal type to the type of the other MultiType. 364 inline void setType(const MultiType& other) { this->setType(other.getType()); } 365 /// Resets the value and changes the internal type to the given type. 366 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } 367 368 /// Returns the current type. 338 369 inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; } 339 / ** @brief Returns true if the current type equals the given type. */370 /// Returns true if the current type equals the given type. 340 371 inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); } 341 / ** @brief Returns true if the current type is T. */372 /// Returns true if the current type is T. 342 373 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 343 374 std::string getTypename() const; 344 375 345 / ** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */376 /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT 346 377 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); } 347 / ** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */378 /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT 348 379 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); } 349 / ** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */380 /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT 350 381 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } 351 / ** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */382 /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT 352 383 inline void operator >> (uint8_t*& mem) const { exportData(mem); } 353 384 inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); } 354 385 355 / ** @brief Checks whether the value is a default one. */386 /// Checks whether the value is a default one (assigned after a failed conversion) 356 387 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 357 388 358 / ** @brief Checks if the MT contains no value. */389 /// Checks if the MT contains no value. 359 390 bool null() const { return (!this->value_); } 360 391 … … 382 413 operator orxonox::Radian() const; 383 414 operator orxonox::Degree() const; 384 / ** @brief Returns the current value, converted to a T* pointer. */415 /// Returns the current value, converted to a T* pointer. 385 416 template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); } 386 417 387 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */388 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */389 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */390 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */391 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */392 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */393 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */394 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */395 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */396 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */397 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */398 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */399 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */400 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */401 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */402 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */403 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */404 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */405 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */406 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */407 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */408 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */409 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */410 411 inline char getChar() const { return this->operator char(); } / ** @brief Returns the current value, converted to the requested type. */412 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } / ** @brief Returns the current value, converted to the requested type. */413 inline short getShort() const { return this->operator short(); } / ** @brief Returns the current value, converted to the requested type. */414 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } / ** @brief Returns the current value, converted to the requested type. */415 inline int getInt() const { return this->operator int(); } / ** @brief Returns the current value, converted to the requested type. */416 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } / ** @brief Returns the current value, converted to the requested type. */417 inline long getLong() const { return this->operator long(); } / ** @brief Returns the current value, converted to the requested type. */418 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } / ** @brief Returns the current value, converted to the requested type. */419 inline long long getLongLong() const { return this->operator long long(); } / ** @brief Returns the current value, converted to the requested type. */420 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } / ** @brief Returns the current value, converted to the requested type. */421 inline float getFloat() const { return this->operator float(); } / ** @brief Returns the current value, converted to the requested type. */422 inline double getDouble() const { return this->operator double(); } / ** @brief Returns the current value, converted to the requested type. */423 inline long double getLongDouble() const { return this->operator long double(); } / ** @brief Returns the current value, converted to the requested type. */424 inline bool getBool() const { return this->operator bool(); } / ** @brief Returns the current value, converted to the requested type. */425 inline void* getVoid() const { return this->operator void*(); } / ** @brief Returns the current value, converted to the requested type. */426 inline std::string getString() const { return this->operator std::string(); } / ** @brief Returns the current value, converted to the requested type. */427 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } / ** @brief Returns the current value, converted to the requested type. */428 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } / ** @brief Returns the current value, converted to the requested type. */429 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } / ** @brief Returns the current value, converted to the requested type. */430 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } / ** @brief Returns the current value, converted to the requested type. */431 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } / ** @brief Returns the current value, converted to the requested type. */432 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } / ** @brief Returns the current value, converted to the requested type. */433 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } / ** @brief Returns the current value, converted to the requested type. */434 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } / ** @brief Returns the current value, converted to a T* pointer. */418 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 419 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 420 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 421 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 422 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 423 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 424 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 425 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 426 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 427 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 428 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 429 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 430 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 431 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 432 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 433 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 434 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 435 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 436 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 437 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 438 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 439 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 440 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 441 442 inline char getChar() const { return this->operator char(); } ///< Returns the current value, converted to the requested type. 443 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } ///< Returns the current value, converted to the requested type. 444 inline short getShort() const { return this->operator short(); } ///< Returns the current value, converted to the requested type. 445 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } ///< Returns the current value, converted to the requested type. 446 inline int getInt() const { return this->operator int(); } ///< Returns the current value, converted to the requested type. 447 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } ///< Returns the current value, converted to the requested type. 448 inline long getLong() const { return this->operator long(); } ///< Returns the current value, converted to the requested type. 449 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } ///< Returns the current value, converted to the requested type. 450 inline long long getLongLong() const { return this->operator long long(); } ///< Returns the current value, converted to the requested type. 451 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } ///< Returns the current value, converted to the requested type. 452 inline float getFloat() const { return this->operator float(); } ///< Returns the current value, converted to the requested type. 453 inline double getDouble() const { return this->operator double(); } ///< Returns the current value, converted to the requested type. 454 inline long double getLongDouble() const { return this->operator long double(); } ///< Returns the current value, converted to the requested type. 455 inline bool getBool() const { return this->operator bool(); } ///< Returns the current value, converted to the requested type. 456 inline void* getVoid() const { return this->operator void*(); } ///< Returns the current value, converted to the requested type. 457 inline std::string getString() const { return this->operator std::string(); } ///< Returns the current value, converted to the requested type. 458 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } ///< Returns the current value, converted to the requested type. 459 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } ///< Returns the current value, converted to the requested type. 460 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } ///< Returns the current value, converted to the requested type. 461 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type. 462 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } ///< Returns the current value, converted to the requested type. 463 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } ///< Returns the current value, converted to the requested type. 464 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } ///< Returns the current value, converted to the requested type. 465 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } ///< Returns the current value, converted to a T* pointer. 435 466 436 467 private: 437 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */438 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */439 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */440 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */441 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */442 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */443 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */444 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */445 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */446 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */447 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */448 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */449 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */450 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */451 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */452 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */453 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */454 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */455 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */456 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */457 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */458 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */459 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } / ** @brief Assigns a new value by changing type and creating a new container. */460 461 / ** @brief Changes the value container. */468 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 469 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 470 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 471 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 472 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 473 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 474 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 475 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 476 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 477 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 478 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 479 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 480 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 481 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 482 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 483 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 484 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 485 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 486 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 487 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 488 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 489 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 490 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 491 492 /// Changes the value container. 462 493 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 463 / ** @brief Creates a new value container (works only with specialized types). */494 /// Creates a new value container (works only with specialized types). 464 495 template <typename T> void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 465 496 … … 467 498 }; 468 499 469 / ** @brief Puts the MultiType on a stream by using the native << operator of the current type. */500 /// Puts the MultiType on a stream by using the native << operator of the current type. 470 501 _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } 471 502 472 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } /** @brief Returns true if the current type equals the given type. */ 473 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } /** @brief Returns true if the current type equals the given type. */ 474 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } /** @brief Returns true if the current type equals the given type. */ 475 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } /** @brief Returns true if the current type equals the given type. */ 476 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } /** @brief Returns true if the current type equals the given type. */ 477 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } /** @brief Returns true if the current type equals the given type. */ 478 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } /** @brief Returns true if the current type equals the given type. */ 479 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } /** @brief Returns true if the current type equals the given type. */ 480 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } /** @brief Returns true if the current type equals the given type. */ 481 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */ 482 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } /** @brief Returns true if the current type equals the given type. */ 483 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } /** @brief Returns true if the current type equals the given type. */ 484 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } /** @brief Returns true if the current type equals the given type. */ 485 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } /** @brief Returns true if the current type equals the given type. */ 486 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } /** @brief Returns true if the current type equals the given type. */ 487 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } /** @brief Returns true if the current type equals the given type. */ 488 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } /** @brief Returns true if the current type equals the given type. */ 489 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } /** @brief Returns true if the current type equals the given type. */ 490 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } /** @brief Returns true if the current type equals the given type. */ 491 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } /** @brief Returns true if the current type equals the given type. */ 492 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } /** @brief Returns true if the current type equals the given type. */ 493 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } /** @brief Returns true if the current type equals the given type. */ 494 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */ 495 496 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */ 503 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } ///< Returns true if the current type equals the given type. 504 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } ///< Returns true if the current type equals the given type. 505 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } ///< Returns true if the current type equals the given type. 506 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } ///< Returns true if the current type equals the given type. 507 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } ///< Returns true if the current type equals the given type. 508 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } ///< Returns true if the current type equals the given type. 509 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } ///< Returns true if the current type equals the given type. 510 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } ///< Returns true if the current type equals the given type. 511 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } ///< Returns true if the current type equals the given type. 512 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type. 513 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } ///< Returns true if the current type equals the given type. 514 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } ///< Returns true if the current type equals the given type. 515 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } ///< Returns true if the current type equals the given type. 516 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } ///< Returns true if the current type equals the given type. 517 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } ///< Returns true if the current type equals the given type. 518 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } ///< Returns true if the current type equals the given type. 519 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } ///< Returns true if the current type equals the given type. 520 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } ///< Returns true if the current type equals the given type. 521 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } ///< Returns true if the current type equals the given type. 522 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } ///< Returns true if the current type equals the given type. 523 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } ///< Returns true if the current type equals the given type. 524 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } ///< Returns true if the current type equals the given type. 525 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } ///< Returns true if the current type equals the given type. 526 527 /// Deletes the content, type becomes MT_Type::Null. 528 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } 497 529 498 530 // Specialization to avoid ambiguities with the conversion operator 499 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } / ** @brief Converts the current value to the given type. */500 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } / ** @brief Converts the current value to the given type. */501 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } / ** @brief Converts the current value to the given type. */502 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } / ** @brief Converts the current value to the given type. */503 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } / ** @brief Converts the current value to the given type. */504 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } / ** @brief Converts the current value to the given type. */505 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } / ** @brief Converts the current value to the given type. */506 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } / ** @brief Converts the current value to the given type. */531 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } ///< Converts the current value to the given type. 532 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } ///< Converts the current value to the given type. 533 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } ///< Converts the current value to the given type. 534 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } ///< Converts the current value to the given type. 535 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type. 536 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } ///< Converts the current value to the given type. 537 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } ///< Converts the current value to the given type. 538 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } ///< Converts the current value to the given type. 507 539 508 540 // Specialization to avoid ambiguities with the conversion operator 509 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } / ** @brief Converts the current value to the given type. */510 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } / ** @brief Converts the current value to the given type. */511 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } / ** @brief Converts the current value to the given type. */512 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } / ** @brief Converts the current value to the given type. */513 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } / ** @brief Converts the current value to the given type. */514 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } / ** @brief Converts the current value to the given type. */515 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } / ** @brief Converts the current value to the given type. */516 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } / ** @brief Converts the current value to the given type. */541 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } ///< Converts the current value to the given type. 542 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } ///< Converts the current value to the given type. 543 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } ///< Converts the current value to the given type. 544 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } ///< Converts the current value to the given type. 545 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type. 546 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } ///< Converts the current value to the given type. 547 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } ///< Converts the current value to the given type. 548 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } ///< Converts the current value to the given type. 517 549 518 550 template <> _UtilExport void MultiType::createNewValueContainer(const char& value); … … 540 572 template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value); 541 573 542 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 543 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 544 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 545 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 546 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 547 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 548 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 549 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 550 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 551 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 552 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 553 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 554 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 555 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 556 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 557 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 558 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 559 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 560 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 561 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 562 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 563 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 564 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 565 566 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } /** @brief Assigns the given value and converts it to the current type. */ 574 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 575 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 576 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 577 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 578 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 579 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 580 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 581 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 582 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 583 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 584 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 585 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 586 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 587 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 588 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 589 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 590 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 591 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 592 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 593 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 594 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 595 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 596 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 597 598 /// Assigns the given value and converts it to the current type. 599 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } 567 600 } 568 601 -
code/branches/doc/src/libraries/util/MultiTypeValue.h
r6417 r7323 29 29 /** 30 30 @file 31 @ingroup Util MultiType 31 32 @brief Declaration and Implementation of the MT_Value<T> class. 32 33 … … 53 54 { 54 55 public: 55 / ** @brief Constructor: Assigns the value and the type identifier. */56 /// Constructor: Assigns the value and the type identifier. 56 57 MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {} 57 58 58 / ** @brief Creates a copy of itself. */59 /// Creates a copy of itself. 59 60 inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); } 60 61 61 / ** @brief Resets the current value to the default. */62 /// Resets the current value to the default. 62 63 inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; } 63 64 64 /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */ 65 /** 66 @brief Assigns the value of the other MultiType, converted to T. 67 @param other The other MultiType 68 */ 65 69 inline bool assimilate(const MultiType& other) 66 70 { … … 76 80 } 77 81 78 inline bool getValue(char* value) const { return convertValue<T, char >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */79 inline bool getValue(unsigned char* value) const { return convertValue<T, unsigned char >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */80 inline bool getValue(short* value) const { return convertValue<T, short >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */81 inline bool getValue(unsigned short* value) const { return convertValue<T, unsigned short >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */82 inline bool getValue(int* value) const { return convertValue<T, int >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */83 inline bool getValue(unsigned int* value) const { return convertValue<T, unsigned int >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */84 inline bool getValue(long* value) const { return convertValue<T, long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */85 inline bool getValue(unsigned long* value) const { return convertValue<T, unsigned long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */86 inline bool getValue(long long* value) const { return convertValue<T, long long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */87 inline bool getValue(unsigned long long* value) const { return convertValue<T, unsigned long long >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */88 inline bool getValue(float* value) const { return convertValue<T, float >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */89 inline bool getValue(double* value) const { return convertValue<T, double >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */90 inline bool getValue(long double* value) const { return convertValue<T, long double >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */91 inline bool getValue(bool* value) const { return convertValue<T, bool >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */92 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */93 inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, zeroise<std::string> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */94 inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, zeroise<orxonox::Vector2> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */95 inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, zeroise<orxonox::Vector3> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */96 inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, zeroise<orxonox::Vector4> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */97 inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */98 inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */99 inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, zeroise<orxonox::Radian> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */100 inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, zeroise<orxonox::Degree> ()); } / ** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */101 102 inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */103 inline bool setValue(const unsigned char& value) { return !(bHasDefaultValue_ = !convertValue<unsigned char , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */104 inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */105 inline bool setValue(const unsigned short& value) { return !(bHasDefaultValue_ = !convertValue<unsigned short , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */106 inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */107 inline bool setValue(const unsigned int& value) { return !(bHasDefaultValue_ = !convertValue<unsigned int , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */108 inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */109 inline bool setValue(const unsigned long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */110 inline bool setValue(const long long& value) { return !(bHasDefaultValue_ = !convertValue<long long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */111 inline bool setValue(const unsigned long long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long long , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */112 inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */113 inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */114 inline bool setValue(const long double& value) { return !(bHasDefaultValue_ = !convertValue<long double , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */115 inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */116 inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */117 inline bool setValue(const std::string& value) { return !(bHasDefaultValue_ = !convertValue<std::string , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */118 inline bool setValue(const orxonox::Vector2& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */119 inline bool setValue(const orxonox::Vector3& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */120 inline bool setValue(const orxonox::Vector4& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4 , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */121 inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */122 inline bool setValue(const orxonox::Quaternion& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */123 inline bool setValue(const orxonox::Radian& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */124 inline bool setValue(const orxonox::Degree& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree , T>(&value_, value, zeroise<T>())); } / ** @brief Assigns the value by converting it to T. */125 126 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */127 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */128 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */129 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */130 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */131 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */132 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */133 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */134 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */135 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. */136 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */137 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */138 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */139 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */140 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } / ** @brief Returns the current value, converted to the requested type. */141 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } / ** @brief Returns the current value, converted to the requested type. */142 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } / ** @brief Returns the current value, converted to the requested type. */143 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } / ** @brief Returns the current value, converted to the requested type. */144 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } / ** @brief Returns the current value, converted to the requested type. */145 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } / ** @brief Returns the current value, converted to the requested type. */146 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } / ** @brief Returns the current value, converted to the requested type. */147 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } / ** @brief Returns the current value, converted to the requested type. */148 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } / ** @brief Returns the current value, converted to the requested type. */149 150 / ** @brief Puts the current value on the stream */82 inline bool getValue(char* value) const { return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 83 inline bool getValue(unsigned char* value) const { return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 84 inline bool getValue(short* value) const { return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 85 inline bool getValue(unsigned short* value) const { return convertValue<T, unsigned short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 86 inline bool getValue(int* value) const { return convertValue<T, int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 87 inline bool getValue(unsigned int* value) const { return convertValue<T, unsigned int >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 88 inline bool getValue(long* value) const { return convertValue<T, long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 89 inline bool getValue(unsigned long* value) const { return convertValue<T, unsigned long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 90 inline bool getValue(long long* value) const { return convertValue<T, long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 91 inline bool getValue(unsigned long long* value) const { return convertValue<T, unsigned long long >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 92 inline bool getValue(float* value) const { return convertValue<T, float >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 93 inline bool getValue(double* value) const { return convertValue<T, double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 94 inline bool getValue(long double* value) const { return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 95 inline bool getValue(bool* value) const { return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 96 inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 97 inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, zeroise<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 98 inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, zeroise<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 99 inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, zeroise<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 100 inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, zeroise<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 101 inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 102 inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 103 inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, zeroise<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 104 inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, zeroise<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 105 106 inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 107 inline bool setValue(const unsigned char& value) { return !(bHasDefaultValue_ = !convertValue<unsigned char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 108 inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 109 inline bool setValue(const unsigned short& value) { return !(bHasDefaultValue_ = !convertValue<unsigned short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 110 inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 111 inline bool setValue(const unsigned int& value) { return !(bHasDefaultValue_ = !convertValue<unsigned int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 112 inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 113 inline bool setValue(const unsigned long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 114 inline bool setValue(const long long& value) { return !(bHasDefaultValue_ = !convertValue<long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 115 inline bool setValue(const unsigned long long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 116 inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 117 inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 118 inline bool setValue(const long double& value) { return !(bHasDefaultValue_ = !convertValue<long double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 119 inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 120 inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 121 inline bool setValue(const std::string& value) { return !(bHasDefaultValue_ = !convertValue<std::string , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 122 inline bool setValue(const orxonox::Vector2& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 123 inline bool setValue(const orxonox::Vector3& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 124 inline bool setValue(const orxonox::Vector4& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 125 inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 126 inline bool setValue(const orxonox::Quaternion& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 127 inline bool setValue(const orxonox::Radian& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 128 inline bool setValue(const orxonox::Degree& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T. 129 130 inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 131 inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 132 inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 133 inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 134 inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 135 inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 136 inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 137 inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 138 inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 139 inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 140 inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 141 inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 142 inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 143 inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 144 inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } ///< Returns the current value, converted to the requested type. 145 inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } ///< Returns the current value, converted to the requested type. 146 inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } ///< Returns the current value, converted to the requested type. 147 inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } ///< Returns the current value, converted to the requested type. 148 inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } ///< Returns the current value, converted to the requested type. 149 inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type. 150 inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type. 151 inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } ///< Returns the current value, converted to the requested type. 152 inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } ///< Returns the current value, converted to the requested type. 153 154 /// Puts the current value on the stream 151 155 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 152 156 153 / ** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */157 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data 154 158 inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); } 155 / ** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */159 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data 156 160 inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); } 157 / ** @brief returns the size of the data that would be saved by exportData */161 /// returns the size of the data that would be saved by exportData 158 162 inline uint8_t getSize() const { return returnSize( this->value_ ); } 159 163 160 T value_; // !< The stored value164 T value_; ///< The stored value 161 165 }; 162 166 -
code/branches/doc/src/libraries/util/OutputHandler.cc
r7297 r7323 114 114 115 115 private: 116 std::ofstream logFile_; //! File handle for the log file117 std::string logFilename_; //! Filename of the log file116 std::ofstream logFile_; //!< File handle for the log file 117 std::string logFilename_; //!< Filename of the log file 118 118 }; 119 119 … … 180 180 181 181 private: 182 std::ostringstream buffer_; //! Stream object used to process the output183 std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output182 std::ostringstream buffer_; //!< Stream object used to process the output 183 std::vector<std::pair<int, std::string> > output_; //!< Vector containing ALL output 184 184 }; 185 185 -
code/branches/doc/src/libraries/util/OutputHandler.h
r7284 r7323 29 29 /** 30 30 @file 31 @ingroup Util Output 31 32 @brief 32 Declaration of classes related to output (logging) .33 Declaration of classes related to output (logging), most notably OutputHandler and OutputListener. 33 34 */ 34 35 … … 50 51 Denotes different levels of text output (log output) 51 52 52 0, None : Very important output53 1, Error : Errors54 2, Warning: Warnings55 3, Info : Information56 4, Debug : Debug information57 5, Verbose: More debug information58 6, Ultra : Crazy debug information53 - 0, None : Very important output 54 - 1, Error : Errors 55 - 2, Warning: Warnings 56 - 3, Info : Information 57 - 4, Debug : Debug information 58 - 5, Verbose: More debug information 59 - 6, Ultra : Crazy debug information 59 60 */ 60 61 namespace OutputLevel … … 79 80 /** 80 81 @brief 81 The OutputHandler acts like std::cout, but output isn't only shown in the console. 82 83 You can register your own listener for output by inheriting from OutputListner. 82 The OutputHandler acts like @c std::cout, but output isn't only shown in the console. 83 84 Output passed to the OutputHandler is distributed to all registered listeners, 85 for example the console, the logfile, or the ingame shell. 86 87 You can register your own listener for output by inheriting from OutputListener. 84 88 And if you need the output previously processed, iterate over it with 85 OutputHandler::getOutputVector[Begin/End]. 89 OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd. 90 86 91 The way to output text is to first set the desired output level with 87 OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout. 92 @ref getOutStream "OutputHandler::getOutStream(level)" and then use 93 the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro. 88 94 */ 89 95 class _UtilExport OutputHandler … … 213 219 OutputHandler(); 214 220 ~OutputHandler(); 215 OutputHandler(const OutputHandler& rhs); //!Unused and undefined221 OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined 216 222 217 223 std::list<OutputListener*> listeners_; //!< Array with all registered output listeners -
code/branches/doc/src/libraries/util/Scope.cc
r5738 r7323 27 27 */ 28 28 29 /** 30 @file 31 @brief Static linkage of the two maps in orxonox::ScopeManager. 32 */ 33 29 34 #include "Scope.h" 30 35 -
code/branches/doc/src/libraries/util/Scope.h
r7266 r7323 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Util SingletonScope 32 @brief Declaration of the classes that are needed to use Scopes: 33 orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager. 34 35 @anchor Scope 36 37 A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template 38 an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the 39 available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated. 40 Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the 41 corresponding orxonox::Scope object changes its state. 42 43 To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope 44 registers in orxonox::ScopeManager, where they are linked statically in the util library. 45 46 Scopes are usually used to control the creation and destruction of Singletons. 47 48 @see orxonox::ScopedSingletonManager 49 @see orxonox::Singleton 50 */ 51 29 52 #ifndef __Util_Scope_H__ 30 53 #define __Util_Scope_H__ … … 42 65 { 43 66 /** 44 @brief The ScopeManager stores the variables of the scope templates in a statically linked context. 67 @brief The ScopeManager stores the variables of the Scope templates in a statically linked context. 68 69 If all Scope objects are managed by this class, they are statically linked in the util library. 70 Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox, 71 which is of course not the desired behavior. 72 73 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 45 74 */ 46 75 class _UtilExport ScopeManager … … 56 85 57 86 /** 58 @brief ScopeListeners register themselves in the corresponding scope and wait for notifications. 87 @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications. 88 Notifications are sent if a Scope is activated or deactivated. 89 90 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 59 91 */ 60 92 class _UtilExport ScopeListener … … 86 118 Objects inheriting from a ScopeListener are registered in a list (different for each scope). 87 119 If the scope gets activated or deactivated, all objects in this list are notified. 120 121 @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager. 88 122 */ 89 123 template <ScopeID::Value scope> … … 130 164 } 131 165 166 //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails. 132 167 void deactivateListeners() 133 168 { -
code/branches/doc/src/libraries/util/ScopedSingletonManager.cc
r7284 r7323 27 27 */ 28 28 29 /** 30 @file 31 @brief Static linkage of the ScopedSingletonManager maps. 32 */ 33 29 34 #include "ScopedSingletonManager.h" 30 35 -
code/branches/doc/src/libraries/util/ScopedSingletonManager.h
r7284 r7323 26 26 * 27 27 */ 28 29 /** 30 @file 31 @ingroup Util SingletonScope 32 @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro. 33 34 ScopedSingletonManager is used to create and destroy Singletons that belong to 35 a given Scope. For each one of these singletons, the macro ManageScopedSingleton() 36 has to be called to register the singleton with orxonox::ScopedSingletonManager. 37 38 See @ref SingletonExample "this code" for an example. 39 40 @see orxonox::Singleton 41 @see orxonox::Scope 42 */ 28 43 29 44 #ifndef __ScopedSingletonManager_H__ … … 38 53 #include "util/Singleton.h" 39 54 55 /** 56 @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager. 57 @param className The name of the singleton class 58 @param scope The scope in which the singleton should exist 59 @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton. 60 61 If this macro is called for a singleton, it is registered with ScopedSingletonManager 62 and will thus be created if its scope becomes active and destroyed if is deactivated. 63 */ 40 64 #define ManageScopedSingleton(className, scope, allowedToFail) \ 41 65 className* className::singletonPtr_s = NULL; \ … … 46 70 class OrxonoxClass; 47 71 72 /** 73 @brief Base class of ClassScopedSingletonManager, implements some static functions 74 used to dispatch calls to preUpdate and postUpdate to all instances of this class. 75 It also keeps track of all existing ScopedSingletonManagers and stores them in a 76 map, sorted by the scope they belong to. 77 */ 48 78 class _UtilExport ScopedSingletonManager 49 79 { 50 80 public: 81 /// Constructor: Initializes all the values 51 82 ScopedSingletonManager(const std::string& className, ScopeID::Value scope) 52 83 : className_(className) … … 54 85 { } 55 86 virtual ~ScopedSingletonManager() { } 87 88 /// Adds a new instance of ScopedSingletonManager to the map. 56 89 static void addManager(ScopedSingletonManager* manager); 57 90 91 /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map. 58 92 template<ScopeID::Value scope> 59 93 static void preUpdate(const Clock& time) … … 64 98 } 65 99 virtual void preUpdate(const Clock& time) = 0; 100 101 /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map. 66 102 template<ScopeID::Value scope> 67 103 static void postUpdate(const Clock& time) … … 78 114 79 115 protected: 80 const std::string className_; 81 const ScopeID::Value scope_; 116 const std::string className_; ///< The name of the scoped singleton class that is managed by this object 117 const ScopeID::Value scope_; ///< The scope of the singleton that is managed by this object 82 118 }; 83 119 120 /** 121 @anchor ClassScopedSingletonManager 122 123 @brief Manages a scoped singleton for a given scope. 124 @param T The managed singleton class 125 @param scope The scope in which the singleton @a T should be active 126 @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures. 127 128 This class inherits from ScopeListener for the given scope and thus its functions 129 activated() and deactivated() are called whenever the Scope changes its state. 130 131 If the Scope is activated, a new instance of @a T (which must be a singleton) is created. 132 If the Scope is deactivated, the singleton is destroyed. 133 134 @see Singleton 135 */ 84 136 template <class T, ScopeID::Value scope, bool allowedToFail> 85 137 class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener 86 138 { 87 139 public: 140 //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener 88 141 ClassScopedSingletonManager(const std::string& className) 89 142 : ScopedSingletonManager(className, scope) … … 113 166 } 114 167 168 //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy() 115 169 void destroy(OrxonoxClass*) 116 170 { 117 171 singletonPtr_->destroy(); 118 172 } 173 //! Destroys the singleton instance - overloaded for all other pointers, calls delete 119 174 void destroy(void*) 120 175 { … … 139 194 140 195 private: 141 T* singletonPtr_; 196 T* singletonPtr_; ///< Unique instance of the singleton class @a T 142 197 }; 143 198 199 /** 200 @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail. 201 @param T The managed singleton class 202 @param scope The scope in which the singleton @a T should be active 203 204 Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager 205 uses a try-catch block to handle exceptions. 206 207 See @ref ClassScopedSingletonManager for a full documentation of the basis template. 208 */ 144 209 template <class T, ScopeID::Value scope> 145 210 class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener 146 211 { 147 212 public: 213 //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener 148 214 ClassScopedSingletonManager(const std::string& className) 149 215 : ScopedSingletonManager(className, scope) … … 180 246 } 181 247 248 //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy() 182 249 void destroy(OrxonoxClass* ptr) 183 250 { 184 251 singletonPtr_->destroy(); 185 252 } 253 //! Destroys the singleton instance - overloaded for void*, calls delete 186 254 void destroy(void* ptr) 187 255 { … … 208 276 209 277 private: 210 T* singletonPtr_; 278 T* singletonPtr_; ///< Unique instance of the singleton class @a T 211 279 }; 212 280 } -
code/branches/doc/src/libraries/util/Singleton.h
r7163 r7323 27 27 */ 28 28 29 /** 30 @defgroup SingletonScope Singletons and Scope 31 @ingroup Util 32 */ 33 34 /** 35 @file 36 @ingroup Util SingletonScope 37 @brief Definition of the Singleton template that is used as base class for classes that allow only one instance. 38 39 @anchor SingletonExample 40 41 Classes that inherit from orxonox::Singleton follow the singleton pattern and thus 42 allow only one instance of the class to exist. This istance is stored in a static 43 variable called @c singletonPtr_s. orxonox::Singleton will access this variable, but 44 it must be implemented in the deriving class. 45 46 Example: 47 @code 48 class TestSingleton : public Singleton<TestSingleton> // inherit from Singleton, pass the own class as template argument 49 { 50 friend class Singleton<TestSingleton>; // friend declaration so Singleton can access singletonPtr_s 51 52 public: 53 TestSingleton(); // public constructor because we may want to manage this singleton 54 // with an orxonox::ScopedSingletonManager (see below) 55 virtual ~TestSingleton(); // public destructor 56 57 void testFunction(); // put your functions here 58 59 private: 60 int testValue_; // put your variables here 61 62 static TestSingleton* singletonPtr_s; // static singleton instance pointer, used by the Singleton template 63 }; 64 @endcode 65 66 And don't forget to initialize the static singleton pointer in the source (*.cc) %file: 67 @code 68 TestSingleton* TestSingleton::singletonPtr_s = NULL; 69 @endcode 70 71 Usually a singleton gets created automatically when it is first used, but it will never 72 be destroyed (unless the singleton explicitly deletes itself). To allow controlled 73 construction and destruction, the singleton can be put within a virtual scope. This is 74 done by registering the singleton class with orxonox::ScopedSingletonManager. To 75 do so, the ManageScopedSingleton() macro has to be called: 76 77 @code 78 ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file 79 @endcode 80 81 @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore, 82 because that's already done by the macro. 83 84 Now the singleton TestSingleton gets automatically created if the scope Graphics becomes 85 active and also gets destroyed if the scope is deactivated. 86 87 Note that not all singletons must register with a scope, but it's recommended. 88 89 If a class inherits from orxonox::Singleton, it also inherits its functions. The most important 90 function is orxonox::Singleton::getInstance() which returns a reference to the only instance 91 of the singleton. 92 93 Example: 94 @code 95 TestSingleton::TestSingleton() // implement the constructor 96 { 97 this->testValue_ = 15; 98 } 99 100 void TestSingleton::testFunction() // implement testFunction 101 { 102 COUT(0) << "My value is " << this->testValue_ << std::endl; 103 } 104 105 TestSingleton::getInstance().testFunction(); // prints "My value is 15" 106 @endcode 107 */ 108 29 109 #ifndef __Util_Singleton_H__ 30 110 #define __Util_Singleton_H__ … … 42 122 43 123 Usage: 44 Inherit publicly from Singleton<MyClass> and provide access to 45 MyClass::singletonPtr_s. 124 Inherit publicly from Singleton<MyClass> and provide access to MyClass::singletonPtr_s. 46 125 This can easily be done with a friend declaration. 126 127 See @ref SingletonExample "this example" for an exemplary implementation. 47 128 */ 48 129 template <class T> … … 80 161 } 81 162 82 //! Constructor resets the singleton instance pointer163 //! Destructor resets the singleton instance pointer 83 164 ~Singleton() 84 165 { -
code/branches/doc/src/libraries/util/mbool.h
r7268 r7323 27 27 */ 28 28 29 /** 30 @file 31 @ingroup Util 32 @brief Declaration and implementation of the @ref orxonox::mbool class. 33 */ 34 29 35 #ifndef _mbool_H__ 30 36 #define _mbool_H__ … … 34 40 namespace orxonox 35 41 { 42 /** 43 @brief mbool is a small helper class that acts like a bool, but keeps track of the number of its state changes. 44 45 The mbool class acts like a bool, but it has an internal counter that counts 46 the number state changes (i.e. when the bool changes from true to false or 47 back). This is used in the network if a boolean value is synchronized, because 48 if a value changes quickly from false to true and back in the same tick, the 49 clients will never be notified of this action. By using mbool however this 50 behaviour is fixed, which is important for triggers and other objects. 51 52 @note This is efficiently solved by using a union that combines a counter and a 53 boolean bitfield of size 1. The boolean value corresponds always to the first 54 bit of the counter - this means, if the counter is incremented, the boolean state 55 changes. On the other hand, if you want to change the state, you can simply increase 56 the counter. 57 */ 36 58 struct _UtilExport mbool 37 59 { 38 60 public: 61 /// Constructor: Creates the mbool and initializes the boolean value (default to false). 39 62 inline mbool(bool value = false) 40 63 { this->value_.memory_ = 0; this->value_.bool_ = value; } 64 /// Copy-constructor, copies state and memory. 41 65 inline mbool(const mbool& value) 42 66 { this->value_.memory_ = value.value_.memory_; } 43 67 68 /// Assigns a boolean value (and increases the memory value if the value is different to the old value). 44 69 inline mbool& operator=(bool value) 45 70 { if (value != this->value_.bool_) { ++this->value_.memory_; } return (*this); } 71 /// Assigns another mbool, copies state and memory. 46 72 inline mbool& operator=(const mbool& value) 47 73 { this->value_.memory_ = value.value_.memory_; return (*this); } 48 74 75 /// Increases the memory which also inverts it's state (++mbool). 49 76 inline mbool& operator++() 50 77 { ++this->value_.memory_; return (*this); } 51 inline mbool operator++(int i) 78 /// Increases the memory which also inverts it's state (mbool++). 79 inline mbool operator++(int) 52 80 { mbool temp = (*this); ++this->value_.memory_; return temp; } 53 81 82 /// Implicitly converts the mbool to a bool. 54 83 inline operator bool() const 55 84 { return this->value_.bool_; } 56 85 86 /// Compares the mbool to a bool, returns true if the bool has the same value as the state of the mbool. 57 87 inline bool operator==(bool other) const 58 88 { return this->value_.bool_ == other; } 89 /// Compares the mbool to a bool, returns true if the bool has a different value than the state of the mbool. 59 90 inline bool operator!=(bool other) const 60 91 { return this->value_.bool_ != other; } 61 92 93 /// Compares two mbools, returns true if their memory matches. 62 94 inline bool operator==(const mbool& other) const 63 95 { return this->value_.memory_ == other.value_.memory_; } 96 /// Compares two mbools, returns true if they have a different memory value. 64 97 inline bool operator!=(const mbool& other) const 65 98 { return this->value_.memory_ != other.value_.memory_; } 66 99 100 /// Returns the inverted state of the bool (doesn't change the internal state). 67 101 inline bool operator!() const 68 102 { return (!this->value_.bool_); } 69 103 104 /// Returns the memory value. 70 105 inline unsigned char& getMemory(){ return value_.memory_; } 71 106 … … 73 108 union 74 109 { 75 bool bool_ : 1; 76 unsigned char memory_; 77 } value_; 110 bool bool_ : 1; ///< The boolean state of the mbool, is located on the first bit of the memory variable 111 unsigned char memory_; ///< The memory of the mbool, counts the state-changes (and the first bit represents also the boolean value) 112 } value_; ///< A union containing the state and the memory of the mbool 78 113 }; 79 114 }
Note: See TracChangeset
for help on using the changeset viewer.