[Orxonox-commit 2618] r7323 - in code/branches/doc: doc/api src/libraries/core src/libraries/util
landauf at orxonox.net
landauf at orxonox.net
Thu Sep 2 03:16:09 CEST 2010
Author: landauf
Date: 2010-09-02 03:16:08 +0200 (Thu, 02 Sep 2010)
New Revision: 7323
Modified:
code/branches/doc/doc/api/Groups.h
code/branches/doc/src/libraries/core/Iterator.h
code/branches/doc/src/libraries/core/ObjectListIterator.h
code/branches/doc/src/libraries/util/Clipboard.cc
code/branches/doc/src/libraries/util/Clipboard.h
code/branches/doc/src/libraries/util/Debug.h
code/branches/doc/src/libraries/util/Math.cc
code/branches/doc/src/libraries/util/Math.h
code/branches/doc/src/libraries/util/MultiType.cc
code/branches/doc/src/libraries/util/MultiType.h
code/branches/doc/src/libraries/util/MultiTypeValue.h
code/branches/doc/src/libraries/util/OutputHandler.cc
code/branches/doc/src/libraries/util/OutputHandler.h
code/branches/doc/src/libraries/util/Scope.cc
code/branches/doc/src/libraries/util/Scope.h
code/branches/doc/src/libraries/util/ScopedSingletonManager.cc
code/branches/doc/src/libraries/util/ScopedSingletonManager.h
code/branches/doc/src/libraries/util/Singleton.h
code/branches/doc/src/libraries/util/mbool.h
Log:
added documentation
Modified: code/branches/doc/doc/api/Groups.h
===================================================================
--- code/branches/doc/doc/api/Groups.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/doc/api/Groups.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -25,7 +25,7 @@
* ...
*
*/
-
+
/**
@defgroup Util Util
@@ -36,7 +36,7 @@
/**
@defgroup Core Core
-
+
The core library contains the framework of Orxonox - all important classes, functions, and macros
that are used to create and manage classes and objects. Almost all classes in Orxonox need at least
one of the core features.
@@ -84,7 +84,7 @@
/**
@defgroup Network Network
-
+
The network library is used to connect clients and server, to synchronize objects and variables, and
to transmit network function calls. It contains the central @ref orxonox::Server "Server" and
@ref orxonox::Client "Client" classes as well as several functions and macros for
@@ -93,14 +93,14 @@
/**
@defgroup Tools Tools
-
+
The tools are a bunch of utilities that belong to the Orxonox library, but are independent of other
features.
*/
/**
@defgroup Orxonox Orxonox
-
+
The Orxonox library contains the central and most important classes of the game. Managers, interfaces,
base-classes, and more are located in Orxonox. More specialized classes that inherit of the base-classes
in Orxonox are often sourced out to the modules.
@@ -108,7 +108,7 @@
/**
@defgroup Modules Modules
-
+
The modules are libraries that depend on the Orxonox library and that are loaded dynamically on runtime
(in contrast to statically loaded libraries like util and core). Each module contains some classes that
are usually connected to each other, but they are independent of other modules. However modules can still
Modified: code/branches/doc/src/libraries/core/Iterator.h
===================================================================
--- code/branches/doc/src/libraries/core/Iterator.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/core/Iterator.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -199,7 +199,7 @@
@brief Overloading of the it++ operator: Iterator points to the next object in the list.
@return The Iterator itself
*/
- inline Iterator<T> operator++(int i)
+ inline Iterator<T> operator++(int)
{
Iterator<T> copy = *this;
this->element_ = this->element_->next_;
Modified: code/branches/doc/src/libraries/core/ObjectListIterator.h
===================================================================
--- code/branches/doc/src/libraries/core/ObjectListIterator.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/core/ObjectListIterator.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -130,7 +130,7 @@
@brief Overloading of the it++ operator: ObjectListIterator points to the next object in the list.
@return The ObjectListIterator itself
*/
- inline ObjectListIterator<T> operator++(int i)
+ inline ObjectListIterator<T> operator++(int)
{
ObjectListIterator<T> copy = *this;
this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
Modified: code/branches/doc/src/libraries/util/Clipboard.cc
===================================================================
--- code/branches/doc/src/libraries/util/Clipboard.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Clipboard.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -53,8 +53,7 @@
{
/**
- @brief Puts text into the windows-clipboard
- @param text The text
+ @brief Puts text into the Windows-clipboard
@return True if the action was successful
*/
bool toClipboard(const std::string& text)
@@ -118,12 +117,11 @@
namespace orxonox
{
- static std::string clipboard; //!< Keeps the text of our internal clipboard
+ static std::string clipboard; ///< Keeps the text of our internal clipboard
/**
@brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
- @param text The text
- @return True
+ @see fromClipboard()
*/
bool toClipboard(const std::string& text)
{
@@ -133,7 +131,7 @@
/**
@brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard.
- @return The text
+ @see toClipboard()
*/
std::string fromClipboard()
{
Modified: code/branches/doc/src/libraries/util/Clipboard.h
===================================================================
--- code/branches/doc/src/libraries/util/Clipboard.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Clipboard.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -28,14 +28,15 @@
/**
@file
- @brief Some functions to exchange text between the OS clipboard and Orxonox.
+ @ingroup Util Command
+ @brief Some functions to exchange text between the OS clipboard and the Shell in Orxonox.
Use fromClipboard() to get text from the clipboard (if there is any text) and
- toClipboard(text) to put text into the clipboard.
+ toClipboard() to put text into the clipboard.
- Those functions can only work properly if there's an OS-specific implementation.
- If an OS isn't supported, the clipboard only works within Orxonox, but exchange
- with other programs isn't possible.
+ These functions can only work properly if there's an OS-specific implementation
+ in Clipboard.cc. If a specific OS is not supported, the clipboard only works
+ within Orxonox, but the exchange with other programs is not possible.
*/
#ifndef _Clipboard_H__
Modified: code/branches/doc/src/libraries/util/Debug.h
===================================================================
--- code/branches/doc/src/libraries/util/Debug.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Debug.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -29,12 +29,12 @@
/**
@defgroup COUT COUT(x) output macro
- @ingroup Output
+ @ingroup Util Output
*/
/**
@file
- at ingroup COUT
+ at ingroup Util COUT
@brief
Handles different output-levels of errors, warnings, infos, and debug information.
Modified: code/branches/doc/src/libraries/util/Math.cc
===================================================================
--- code/branches/doc/src/libraries/util/Math.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Math.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -90,12 +90,12 @@
@param myposition My position
@param mydirection My viewing direction
@param otherposition The position of the other object
- @return The angle
+ @return The angle in radian
Examples:
- If the other object is exactly in front of me, the function returns 0.
- If the other object is exactly behind me, the function returns pi.
- If the other object is exactly right/left to me (or above/below), the function returns pi/2.
+ - If the other object is exactly in front of me, the function returns 0.
+ - If the other object is exactly behind me, the function returns pi.
+ - If the other object is exactly right/left to me (or above/below), the function returns pi/2.
*/
float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
{
@@ -116,11 +116,11 @@
@return The viewing direction
Examples:
- If the other object is exactly in front of me, the function returns Vector2(0, 0).
- If the other object is exactly at my left, the function returns Vector2(-1, 0).
- If the other object is exactly at my right, the function returns Vector2(1, 0).
- If the other object is only a bit at my right, the function still returns Vector2(1, 0).
- If the other object is exactly above me, the function returns Vector2(0, 1).
+ - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
+ - If the other object is exactly at my left, the function returns <tt>Vector2(-1, 0)</tt>.
+ - If the other object is exactly at my right, the function returns <tt>Vector2(1, 0)</tt>.
+ - If the other object is only a bit at my right, the function still returns <tt>Vector2(1, 0)</tt>.
+ - If the other object is exactly above me, the function returns <tt>Vector2(0, 1)</tt>.
*/
orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
{
@@ -156,11 +156,11 @@
@return The viewing direction
Examples:
- If the other object is exactly in front of me, the function returns Vector2(0, 0).
- If the other object is exactly at my left, the function returns Vector2(-0.5, 0).
- If the other object is exactly at my right, the function returns Vector2(0.5, 0).
- If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).
- If the other object is exactly above me, the function returns Vector2(0, 0.5).
+ - If the other object is exactly in front of me, the function returns <tt>Vector2(0, 0)</tt>.
+ - If the other object is exactly at my left, the function returns <tt>Vector2(-0.5, 0)</tt>.
+ - If the other object is exactly at my right, the function returns <tt>Vector2(0.5, 0)</tt>.
+ - If the other object is only a bit at my right, the function still returns <tt>Vector2(0.01, 0)</tt>.
+ - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>.
*/
orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
{
@@ -219,6 +219,9 @@
return (targetposition + targetvelocity * time);
}
+ /**
+ @brief Returns a unique number. This function will never return the same value twice.
+ */
unsigned long getUniqueNumber()
{
static unsigned long aNumber = 135;
Modified: code/branches/doc/src/libraries/util/Math.h
===================================================================
--- code/branches/doc/src/libraries/util/Math.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Math.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -27,7 +27,13 @@
*/
/**
+ @defgroup Math Mathematical functions
+ @ingroup Util
+*/
+
+/**
@file
+ @ingroup Util Math
@brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
*/
@@ -61,19 +67,19 @@
// C++ doesn't define any constants for pi, e, etc.
namespace math
{
- const float pi = 3.14159265f;
- const float pi_2 = 1.57079633f;
- const float pi_4 = 7.85398163e-1f;
- const float e = 2.71828183f;
- const float sqrt2 = 1.41421356f;
- const float sqrt2_2 = 7.07106781e-1f;
+ const float pi = 3.14159265f; ///< PI
+ const float pi_2 = 1.57079633f; ///< PI / 2
+ const float pi_4 = 7.85398163e-1f; ///< PI / 4
+ const float e = 2.71828183f; ///< e
+ const float sqrt2 = 1.41421356f; ///< sqrt(2)
+ const float sqrt2_2 = 7.07106781e-1f; ///< sqrt(2) / 2
- const double pi_d = 3.14159265358979324;
- const double pi_2_d = 1.57079632679489662;
- const double pi_4_d = 7.85398163397448310e-1;
- const double e_d = 2.71828182845904524;
- const double sqrt2_d = 1.41421356237309505;
- const double sqrt2_2_d = 7.07106781186547524e-1;
+ const double pi_d = 3.14159265358979324; ///< PI (double)
+ const double pi_2_d = 1.57079632679489662; ///< PI / 2 (double)
+ const double pi_4_d = 7.85398163397448310e-1; ///< PI / 4 (double)
+ const double e_d = 2.71828182845904524; ///< e (double)
+ const double sqrt2_d = 1.41421356237309505; ///< sqrt(2) (double)
+ const double sqrt2_2_d = 7.07106781186547524e-1; ///< sqrt(2) / 2 (double)
}
#if OGRE_VERSION < 0x010603
@@ -100,7 +106,7 @@
}
/**
- @brief Keeps a value between a lower and an upper limit.
+ @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max.
@param x The value
@param min The lower limit
@param max The upper limit
@@ -118,7 +124,7 @@
}
/**
- @brief Returns the square value (x^2).
+ @brief Returns the squared value (x^2).
*/
template <typename T>
inline T square(T x)
@@ -127,7 +133,7 @@
}
/**
- @brief Returns the cube value (x^3).
+ @brief Returns the cubed value (x^3).
*/
template <typename T>
inline T cube(T x)
@@ -136,7 +142,7 @@
}
/**
- @brief Rounds the value.
+ @brief Rounds the value to the nearest integer.
*/
template <typename T>
inline int round(T x)
@@ -148,6 +154,19 @@
@brief The modulo operation, enhanced to work properly with negative values.
@param x The value
@param max The operand
+
+ The built in modulo operator % yields a strange behavior with negative values.
+ This function corrects this - the result is guaranteed to lie always between
+ zero and (max-1).
+
+ Example:
+ @code
+ int var = 11 % 10; // 1
+ int var = -1 % 10; // -1
+
+ int var = mod(11, 10); // 1
+ int var = mod(-1, 10); // 9
+ @endcode
*/
template <typename T>
inline int mod(T x, int max)
@@ -158,6 +177,14 @@
return ((x % max) + max);
}
+ /**
+ @brief Returns a "zero" value for the given type.
+ @note This is the default template of the zeroise() function. The template is spezialized for each supported type.
+
+ The exact return value of the function depends on the type. For @c int this is 0,
+ for @c float it's 0.0f. For a @c std::string the function returns "" and for
+ @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
+ */
template <typename T>
inline T zeroise()
{
@@ -191,7 +218,10 @@
template <> inline orxonox::ColourValue zeroise<orxonox::ColourValue>() { return orxonox::ColourValue(0, 0, 0, 0); }
template <> inline orxonox::Quaternion zeroise<orxonox::Quaternion>() { return orxonox::Quaternion (0, 0, 0, 0); }
- //! Provides zero value symbols that can be returned as reference
+ /**
+ @brief Provides zero value symbols that can be returned as reference
+ @see zeroise()
+ */
template <typename T>
struct NilValue
{
@@ -206,10 +236,10 @@
/**
@brief Interpolates between two values for a time between 0 and 1.
- @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
- @param start The value at time = 0
- @param end The value at time = 1
- @return The interpolation at a given time
+ @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.
+ @param start The value at @a time = 0
+ @param end The value at @a time = 1
+ @return The interpolated value at a given time
*/
template <typename T>
inline T interpolate(float time, const T& start, const T& end)
@@ -219,10 +249,10 @@
/**
@brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
- @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
- @param start The value at time = 0
- @param end The value at time = 1
- @return The smoothed interpolation at a given time
+ @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.
+ @param start The value at @a time = 0
+ @param end The value at @a time = 1
+ @return The interpolated value at a given time
*/
template <typename T>
inline T interpolateSmooth(float time, const T& start, const T& end)
@@ -231,7 +261,7 @@
}
/**
- @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.
+ @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>.
*/
inline float rnd()
{
@@ -239,7 +269,7 @@
}
/**
- @brief Returns a random number between 0 and almost max: 0 <= rnd < max.
+ @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>.
@param max The maximum
*/
inline float rnd(float max)
@@ -248,7 +278,7 @@
}
/**
- @brief Returns a random number between min and almost max: min <= rnd < max.
+ @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>.
@param min The minimum
@param max The maximum
*/
@@ -267,6 +297,9 @@
_UtilExport unsigned long getUniqueNumber();
+ /**
+ @brief A Vector class containing two integers @a x and @a y.
+ */
class IntVector2
{
public:
@@ -276,6 +309,9 @@
int y;
};
+ /**
+ @brief A Vector class containing three integers @a x, @a y, and @a z.
+ */
class IntVector3
{
public:
Modified: code/branches/doc/src/libraries/util/MultiType.cc
===================================================================
--- code/branches/doc/src/libraries/util/MultiType.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/MultiType.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -158,51 +158,51 @@
};
}
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
}
Modified: code/branches/doc/src/libraries/util/MultiType.h
===================================================================
--- code/branches/doc/src/libraries/util/MultiType.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/MultiType.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -27,39 +27,66 @@
*/
/**
+ @defgroup MultiType MultiType
+ @ingroup Util
+*/
+
+/**
@file
+ @ingroup Util MultiType
@brief Declaration of the MultiType and some helper constructs.
+ @anchor MultiTypeExamples
+
The MultiType can hold a value of one of the following types:
- - all primitives
- - all pointers
- - string
+ - all primitives (int, float, bool, etc.)
+ - all pointers (void* and T*)
+ - std::string
- Vector2, Vector3, Vector4
- Quaternion
- ColourValue
- Radian, Degree
- The MultiType has a "type" determined by the first assigned value, either through
- - the constructor,
- - the assignment operator= or
- - setValue(value).
- If you assign another value of another type, the MultiType keeps "it's" type and
- converts the new value to this type.
+ The MultiType has an internal "type" determined by the first assigned value, using one of these ways:
+ - @ref orxonox::MultiType::MultiType "The constructor"
+ - The assignment operator= (orxonox::MultiType::operator=())
+ - @ref orxonox::MultiType::setValue() "setValue(value)"
+ If you assign another value of another type, the MultiType keeps "its" type and
+ converts the new value to the old type.
+
If you want to change the type, there are three possibilities:
- - convert<T>() set's the type to T and converts the currently assigned value
- - setType<T>() set's the type to T and resets the value
+ - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
+ - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
- setValue<T>(value) assigns a new value and changes the type to T.
Examples:
@code
- MultiType a = 10;; // a has now the type int and the value 10
+ MultiType a = 10; // a has now the type int and the value 10
a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3
- a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14
- a.convert<bool>(); // converts 3.14 to bool, which is true
+ a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
+ a.convert<bool>(); // converts 3.14f to bool, which is true
a = false; // assigns false, this is equivalent to a.setValue(false)
@endcode
+ You can pass a MultiType to a function as an argument, even if the argument is
+ not of type MultiType. This works, because the MultiType is automatically converted
+ to the right type.
+
+ Example:
+ @code
+ void myfunction(int value)
+ {
+ COUT(0) << "doubled value is " << (2 * value) << std::endl;
+ }
+
+ MultiType a = "50"; // Note: We assigned a string
+ myfunction(a); // a is converted to int and passed to the function, which prints "value is 100"
+ @endcode
+
+ Note however that it is of course quite expensive to convert values, especially std::string <-> value.
+ So if you can, always assign a value with the right type to avoid conversion.
+
@note
Whenever a value gets converted, there is a boolean return value telling you whether it was
successful or not. If it wasn't a zero value is assigned with the help of zeroise<T>().
@@ -128,10 +155,9 @@
- ColourValue
- Radian, Degree
- The internal type of a MultiType is determined by the first assigned value, but can be
- changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned
- the normal way (operator=, setValue(value)), the value gets converted to the current internal
- type of the MultiType.
+ For more information and some examples see the description @ref MultiTypeExamples "here".
+
+ @see MultiType.h
*/
class _UtilExport MultiType
{
@@ -154,10 +180,10 @@
virtual void reset() = 0;
virtual bool assimilate(const MultiType& other) = 0;
- /** @brief Returns the type of the current value. */
+ /// Returns the type of the current value.
const MT_Type::Value& getType() const { return this->type_; }
- /** @brief Checks whether the value is a default one. */
+ /// Checks whether the value is a default one.
bool hasDefaultValue() const { return this->bHasDefaultValue_; }
virtual bool setValue(const char& value) = 0;
@@ -238,47 +264,47 @@
virtual void exportData( uint8_t*& mem ) const=0;
virtual uint8_t getSize() const=0;
- MT_Type::Value type_; //!< The type of the current value
- bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
+ MT_Type::Value type_; ///< The type of the current value
+ bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
};
public:
- 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. */
- inline MultiType(const char& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const short& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const int& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const float& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const double& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
- inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } /** @brief Constructor: Assigns the given mbool and converts it to bool. */
- 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. */
- inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
- inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } /** @brief Constructor: Sets the type, the next assignment will determine the value. */
+ inline MultiType() : value_(0) {} ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
+ inline MultiType(const char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const float& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
+ inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } ///< Constructor: Assigns the given mbool and converts it to bool.
+ 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.
+ inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } ///< Copyconstructor: Assigns value and type of the other MultiType.
+ inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } ///< Constructor: Sets the type, the next assignment will determine the value.
- /** @brief Destructor: Deletes the MT_Value. */
+ /// Destructor: Deletes the MT_Value.
inline ~MultiType() { if (this->value_) { delete this->value_; } }
- 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. */
- template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
- 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. */
- inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } /** @brief Resets the value and changes the type. */
+ 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.
+ template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } ///< Assigns a pointer.
+ 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.
+ inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } ///< Resets the value and changes the type.
inline bool setValue(const char& value);
inline bool setValue(const unsigned char& value);
@@ -304,7 +330,7 @@
inline bool setValue(const orxonox::Radian& value);
inline bool setValue(const orxonox::Degree& value);
inline bool setValue(const char* value);
- /** @brief Assigns a pointer. */
+ /// Assigns a pointer.
template <typename V> inline bool setValue(V* value)
{
if (this->value_)
@@ -312,50 +338,55 @@
else
return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
}
- /** @brief Assigns the value of the other MultiType and converts it to the current type. */
+ /// Assigns the value of the other MultiType and converts it to the current type.
bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
- /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
+ /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
- /** @brief Copies the other MultiType by assigning value and type. */
+ /// Copies the other MultiType by assigning value and type.
inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
- template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } /** @brief Converts the current value to type T. */
- inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
+ /// Converts the current value to type T.
+ template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); }
+ /// Converts the current value to the type of the other MultiType.
+ inline bool convert(const MultiType& other) { return this->convert(other.getType()); }
bool convert(MT_Type::Value type);
- /** @brief Current content gets deleted. New type is MT_Type::Null */
+ /// Current content gets deleted. New type is MT_Type::Null
inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
- /** @brief Current content gets overridden with default zero value */
+ /// Current content gets overridden with default zero value
inline void resetValue() { if (this->value_) this->value_->reset(); }
- template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */
- 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. */
- 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. */
+ /// Resets the value and changes the internal type to T.
+ template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
+ /// Resets the value and changes the internal type to the type of the other MultiType.
+ inline void setType(const MultiType& other) { this->setType(other.getType()); }
+ /// Resets the value and changes the internal type to the given type.
+ inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); }
- /** @brief Returns the current type. */
+ /// Returns the current type.
inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
- /** @brief Returns true if the current type equals the given type. */
+ /// Returns true if the current type equals the given type.
inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
- /** @brief Returns true if the current type is T. */
+ /// Returns true if the current type is T.
template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below
std::string getTypename() const;
- /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
+ /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
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); }
- /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
+ /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
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); }
- /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
+ /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; }
- /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
+ /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
inline void operator >> (uint8_t*& mem) const { exportData(mem); }
inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
- /** @brief Checks whether the value is a default one. */
+ /// Checks whether the value is a default one (assigned after a failed conversion)
bool hasDefaultValue() const { return this->value_->hasDefaultValue(); }
- /** @brief Checks if the MT contains no value. */
+ /// Checks if the MT contains no value.
bool null() const { return (!this->value_); }
operator char() const;
@@ -381,139 +412,140 @@
operator orxonox::Quaternion() const;
operator orxonox::Radian() const;
operator orxonox::Degree() const;
- /** @brief Returns the current value, converted to a T* pointer. */
+ /// Returns the current value, converted to a T* pointer.
template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- inline char getChar() const { return this->operator char(); } /** @brief Returns the current value, converted to the requested type. */
- inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } /** @brief Returns the current value, converted to the requested type. */
- inline short getShort() const { return this->operator short(); } /** @brief Returns the current value, converted to the requested type. */
- inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } /** @brief Returns the current value, converted to the requested type. */
- inline int getInt() const { return this->operator int(); } /** @brief Returns the current value, converted to the requested type. */
- inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } /** @brief Returns the current value, converted to the requested type. */
- inline long getLong() const { return this->operator long(); } /** @brief Returns the current value, converted to the requested type. */
- inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } /** @brief Returns the current value, converted to the requested type. */
- inline long long getLongLong() const { return this->operator long long(); } /** @brief Returns the current value, converted to the requested type. */
- inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } /** @brief Returns the current value, converted to the requested type. */
- inline float getFloat() const { return this->operator float(); } /** @brief Returns the current value, converted to the requested type. */
- inline double getDouble() const { return this->operator double(); } /** @brief Returns the current value, converted to the requested type. */
- inline long double getLongDouble() const { return this->operator long double(); } /** @brief Returns the current value, converted to the requested type. */
- inline bool getBool() const { return this->operator bool(); } /** @brief Returns the current value, converted to the requested type. */
- inline void* getVoid() const { return this->operator void*(); } /** @brief Returns the current value, converted to the requested type. */
- inline std::string getString() const { return this->operator std::string(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } /** @brief Returns the current value, converted to the requested type. */
- inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } /** @brief Returns the current value, converted to the requested type. */
- template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } /** @brief Returns the current value, converted to a T* pointer. */
+ inline char getChar() const { return this->operator char(); } ///< Returns the current value, converted to the requested type.
+ inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } ///< Returns the current value, converted to the requested type.
+ inline short getShort() const { return this->operator short(); } ///< Returns the current value, converted to the requested type.
+ inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } ///< Returns the current value, converted to the requested type.
+ inline int getInt() const { return this->operator int(); } ///< Returns the current value, converted to the requested type.
+ inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } ///< Returns the current value, converted to the requested type.
+ inline long getLong() const { return this->operator long(); } ///< Returns the current value, converted to the requested type.
+ inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } ///< Returns the current value, converted to the requested type.
+ inline long long getLongLong() const { return this->operator long long(); } ///< Returns the current value, converted to the requested type.
+ inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } ///< Returns the current value, converted to the requested type.
+ inline float getFloat() const { return this->operator float(); } ///< Returns the current value, converted to the requested type.
+ inline double getDouble() const { return this->operator double(); } ///< Returns the current value, converted to the requested type.
+ inline long double getLongDouble() const { return this->operator long double(); } ///< Returns the current value, converted to the requested type.
+ inline bool getBool() const { return this->operator bool(); } ///< Returns the current value, converted to the requested type.
+ inline void* getVoid() const { return this->operator void*(); } ///< Returns the current value, converted to the requested type.
+ inline std::string getString() const { return this->operator std::string(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } ///< Returns the current value, converted to the requested type.
+ inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } ///< Returns the current value, converted to the requested type.
+ template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } ///< Returns the current value, converted to a T* pointer.
private:
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- /** @brief Changes the value container. */
+ /// Changes the value container.
template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
- /** @brief Creates a new value container (works only with specialized types). */
+ /// Creates a new value container (works only with specialized types).
template <typename T> void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
MT_ValueBase* value_; //!< A pointer to the value container
};
- /** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
+ /// Puts the MultiType on a stream by using the native << operator of the current type.
_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */
+ /// Deletes the content, type becomes MT_Type::Null.
+ template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
// Specialization to avoid ambiguities with the conversion operator
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } ///< Converts the current value to the given type.
// Specialization to avoid ambiguities with the conversion operator
- template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } /** @brief Converts the current value to the given type. */
- template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } /** @brief Converts the current value to the given type. */
+ template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } ///< Converts the current value to the given type.
+ template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } ///< Converts the current value to the given type.
template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
template <> _UtilExport void MultiType::createNewValueContainer(const unsigned char& value);
@@ -539,31 +571,32 @@
template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- 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. */
+ /// Assigns the given value and converts it to the current type.
+ inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
}
#endif /* _MultiType_H__ */
Modified: code/branches/doc/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/branches/doc/src/libraries/util/MultiTypeValue.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/MultiTypeValue.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -28,6 +28,7 @@
/**
@file
+ @ingroup Util MultiType
@brief Declaration and Implementation of the MT_Value<T> class.
The MT_Value<T> class is used to hold a value of type T within a MultiType.
@@ -52,16 +53,19 @@
class MT_Value : public MultiType::MT_ValueBase
{
public:
- /** @brief Constructor: Assigns the value and the type identifier. */
+ /// Constructor: Assigns the value and the type identifier.
MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
- /** @brief Creates a copy of itself. */
+ /// Creates a copy of itself.
inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
- /** @brief Resets the current value to the default. */
+ /// Resets the current value to the default.
inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
- /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
+ /**
+ @brief Assigns the value of the other MultiType, converted to T.
+ @param other The other MultiType
+ */
inline bool assimilate(const MultiType& other)
{
if (other.value_)
@@ -75,89 +79,89 @@
}
}
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- 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. */
- 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. */
- inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } /** @brief Assigns the value by converting it to T. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ 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.
+ 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.
+ inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
+ 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.
- inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- 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. */
- inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
- 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. */
+ inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
+ inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } ///< Returns the current value, converted to the requested type.
+ inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } ///< Returns the current value, converted to the requested type.
- /** @brief Puts the current value on the stream */
+ /// Puts the current value on the stream
inline void toString(std::ostream& outstream) const { outstream << this->value_; }
- /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
+ /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data
inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
- /** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */
+ /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data
inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); }
- /** @brief returns the size of the data that would be saved by exportData */
+ /// returns the size of the data that would be saved by exportData
inline uint8_t getSize() const { return returnSize( this->value_ ); }
- T value_; //!< The stored value
+ T value_; ///< The stored value
};
// Import / Export specialisation
Modified: code/branches/doc/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/doc/src/libraries/util/OutputHandler.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/OutputHandler.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -113,8 +113,8 @@
}
private:
- std::ofstream logFile_; //! File handle for the log file
- std::string logFilename_; //! Filename of the log file
+ std::ofstream logFile_; //!< File handle for the log file
+ std::string logFilename_; //!< Filename of the log file
};
@@ -179,8 +179,8 @@
}
private:
- std::ostringstream buffer_; //! Stream object used to process the output
- std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output
+ std::ostringstream buffer_; //!< Stream object used to process the output
+ std::vector<std::pair<int, std::string> > output_; //!< Vector containing ALL output
};
Modified: code/branches/doc/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/doc/src/libraries/util/OutputHandler.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/OutputHandler.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -28,8 +28,9 @@
/**
@file
+ at ingroup Util Output
@brief
- Declaration of classes related to output (logging).
+ Declaration of classes related to output (logging), most notably OutputHandler and OutputListener.
*/
#ifndef _OutputHandler_H__
@@ -49,13 +50,13 @@
@brief
Denotes different levels of text output (log output)
- 0, None : Very important output
- 1, Error : Errors
- 2, Warning: Warnings
- 3, Info : Information
- 4, Debug : Debug information
- 5, Verbose: More debug information
- 6, Ultra : Crazy debug information
+ - 0, None : Very important output
+ - 1, Error : Errors
+ - 2, Warning: Warnings
+ - 3, Info : Information
+ - 4, Debug : Debug information
+ - 5, Verbose: More debug information
+ - 6, Ultra : Crazy debug information
*/
namespace OutputLevel
{
@@ -78,13 +79,18 @@
/**
@brief
- The OutputHandler acts like std::cout, but output isn't only shown in the console.
+ The OutputHandler acts like @c std::cout, but output isn't only shown in the console.
- You can register your own listener for output by inheriting from OutputListner.
+ Output passed to the OutputHandler is distributed to all registered listeners,
+ for example the console, the logfile, or the ingame shell.
+
+ You can register your own listener for output by inheriting from OutputListener.
And if you need the output previously processed, iterate over it with
- OutputHandler::getOutputVector[Begin/End].
+ OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd.
+
The way to output text is to first set the desired output level with
- OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout.
+ @ref getOutStream "OutputHandler::getOutStream(level)" and then use
+ the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro.
*/
class _UtilExport OutputHandler
{
@@ -212,7 +218,7 @@
private:
OutputHandler();
~OutputHandler();
- OutputHandler(const OutputHandler& rhs); //! Unused and undefined
+ OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined
std::list<OutputListener*> listeners_; //!< Array with all registered output listeners
int outputLevel_; //!< The level of the incoming output
Modified: code/branches/doc/src/libraries/util/Scope.cc
===================================================================
--- code/branches/doc/src/libraries/util/Scope.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Scope.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,11 @@
*
*/
+/**
+ @file
+ @brief Static linkage of the two maps in orxonox::ScopeManager.
+*/
+
#include "Scope.h"
namespace orxonox
Modified: code/branches/doc/src/libraries/util/Scope.h
===================================================================
--- code/branches/doc/src/libraries/util/Scope.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Scope.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,29 @@
*
*/
+/**
+ at file
+ at ingroup Util SingletonScope
+ at brief Declaration of the classes that are needed to use Scopes:
+orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager.
+
+ at anchor Scope
+
+A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
+an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
+available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
+Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the
+corresponding orxonox::Scope object changes its state.
+
+To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
+registers in orxonox::ScopeManager, where they are linked statically in the util library.
+
+Scopes are usually used to control the creation and destruction of Singletons.
+
+ at see orxonox::ScopedSingletonManager
+ at see orxonox::Singleton
+*/
+
#ifndef __Util_Scope_H__
#define __Util_Scope_H__
@@ -41,7 +64,13 @@
namespace orxonox
{
/**
- @brief The ScopeManager stores the variables of the scope templates in a statically linked context.
+ @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
+
+ If all Scope objects are managed by this class, they are statically linked in the util library.
+ Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
+ which is of course not the desired behavior.
+
+ @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
*/
class _UtilExport ScopeManager
{
@@ -55,7 +84,10 @@
};
/**
- @brief ScopeListeners register themselves in the corresponding scope and wait for notifications.
+ @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
+ Notifications are sent if a Scope is activated or deactivated.
+
+ @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
*/
class _UtilExport ScopeListener
{
@@ -85,6 +117,8 @@
Objects inheriting from a ScopeListener are registered in a list (different for each scope).
If the scope gets activated or deactivated, all objects in this list are notified.
+
+ @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
*/
template <ScopeID::Value scope>
class Scope
@@ -129,6 +163,7 @@
this->deactivateListeners();
}
+ //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
void deactivateListeners()
{
for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
Modified: code/branches/doc/src/libraries/util/ScopedSingletonManager.cc
===================================================================
--- code/branches/doc/src/libraries/util/ScopedSingletonManager.cc 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/ScopedSingletonManager.cc 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,11 @@
*
*/
+/**
+ @file
+ @brief Static linkage of the ScopedSingletonManager maps.
+*/
+
#include "ScopedSingletonManager.h"
namespace orxonox
Modified: code/branches/doc/src/libraries/util/ScopedSingletonManager.h
===================================================================
--- code/branches/doc/src/libraries/util/ScopedSingletonManager.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/ScopedSingletonManager.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,21 @@
*
*/
+/**
+ @file
+ @ingroup Util SingletonScope
+ @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro.
+
+ ScopedSingletonManager is used to create and destroy Singletons that belong to
+ a given Scope. For each one of these singletons, the macro ManageScopedSingleton()
+ has to be called to register the singleton with orxonox::ScopedSingletonManager.
+
+ See @ref SingletonExample "this code" for an example.
+
+ @see orxonox::Singleton
+ @see orxonox::Scope
+*/
+
#ifndef __ScopedSingletonManager_H__
#define __ScopedSingletonManager_H__
@@ -37,6 +52,15 @@
#include "util/Scope.h"
#include "util/Singleton.h"
+/**
+ @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager.
+ @param className The name of the singleton class
+ @param scope The scope in which the singleton should exist
+ @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton.
+
+ If this macro is called for a singleton, it is registered with ScopedSingletonManager
+ and will thus be created if its scope becomes active and destroyed if is deactivated.
+*/
#define ManageScopedSingleton(className, scope, allowedToFail) \
className* className::singletonPtr_s = NULL; \
static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
@@ -45,16 +69,26 @@
{
class OrxonoxClass;
+ /**
+ @brief Base class of ClassScopedSingletonManager, implements some static functions
+ used to dispatch calls to preUpdate and postUpdate to all instances of this class.
+ It also keeps track of all existing ScopedSingletonManagers and stores them in a
+ map, sorted by the scope they belong to.
+ */
class _UtilExport ScopedSingletonManager
{
public:
+ /// Constructor: Initializes all the values
ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
: className_(className)
, scope_(scope)
{ }
virtual ~ScopedSingletonManager() { }
+
+ /// Adds a new instance of ScopedSingletonManager to the map.
static void addManager(ScopedSingletonManager* manager);
+ /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map.
template<ScopeID::Value scope>
static void preUpdate(const Clock& time)
{
@@ -63,6 +97,8 @@
it->second->preUpdate(time);
}
virtual void preUpdate(const Clock& time) = 0;
+
+ /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map.
template<ScopeID::Value scope>
static void postUpdate(const Clock& time)
{
@@ -77,14 +113,31 @@
static ManagerMultiMap& getManagersByScope();
protected:
- const std::string className_;
- const ScopeID::Value scope_;
+ const std::string className_; ///< The name of the scoped singleton class that is managed by this object
+ const ScopeID::Value scope_; ///< The scope of the singleton that is managed by this object
};
+ /**
+ @anchor ClassScopedSingletonManager
+
+ @brief Manages a scoped singleton for a given scope.
+ @param T The managed singleton class
+ @param scope The scope in which the singleton @a T should be active
+ @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.
+
+ This class inherits from ScopeListener for the given scope and thus its functions
+ activated() and deactivated() are called whenever the Scope changes its state.
+
+ If the Scope is activated, a new instance of @a T (which must be a singleton) is created.
+ If the Scope is deactivated, the singleton is destroyed.
+
+ @see Singleton
+ */
template <class T, ScopeID::Value scope, bool allowedToFail>
class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
{
public:
+ //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
ClassScopedSingletonManager(const std::string& className)
: ScopedSingletonManager(className, scope)
, ScopeListener(scope)
@@ -112,10 +165,12 @@
singletonPtr_ = NULL;
}
+ //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy()
void destroy(OrxonoxClass*)
{
singletonPtr_->destroy();
}
+ //! Destroys the singleton instance - overloaded for all other pointers, calls delete
void destroy(void*)
{
delete singletonPtr_;
@@ -138,13 +193,24 @@
}
private:
- T* singletonPtr_;
+ T* singletonPtr_; ///< Unique instance of the singleton class @a T
};
+ /**
+ @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail.
+ @param T The managed singleton class
+ @param scope The scope in which the singleton @a T should be active
+
+ Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager
+ uses a try-catch block to handle exceptions.
+
+ See @ref ClassScopedSingletonManager for a full documentation of the basis template.
+ */
template <class T, ScopeID::Value scope>
class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
{
public:
+ //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
ClassScopedSingletonManager(const std::string& className)
: ScopedSingletonManager(className, scope)
, ScopeListener(scope)
@@ -179,10 +245,12 @@
}
}
+ //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy()
void destroy(OrxonoxClass* ptr)
{
singletonPtr_->destroy();
}
+ //! Destroys the singleton instance - overloaded for void*, calls delete
void destroy(void* ptr)
{
delete singletonPtr_;
@@ -207,7 +275,7 @@
}
private:
- T* singletonPtr_;
+ T* singletonPtr_; ///< Unique instance of the singleton class @a T
};
}
Modified: code/branches/doc/src/libraries/util/Singleton.h
===================================================================
--- code/branches/doc/src/libraries/util/Singleton.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/Singleton.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,86 @@
*
*/
+/**
+ @defgroup SingletonScope Singletons and Scope
+ @ingroup Util
+*/
+
+/**
+ @file
+ @ingroup Util SingletonScope
+ @brief Definition of the Singleton template that is used as base class for classes that allow only one instance.
+
+ @anchor SingletonExample
+
+ Classes that inherit from orxonox::Singleton follow the singleton pattern and thus
+ allow only one instance of the class to exist. This istance is stored in a static
+ variable called @c singletonPtr_s. orxonox::Singleton will access this variable, but
+ it must be implemented in the deriving class.
+
+ Example:
+ @code
+ class TestSingleton : public Singleton<TestSingleton> // inherit from Singleton, pass the own class as template argument
+ {
+ friend class Singleton<TestSingleton>; // friend declaration so Singleton can access singletonPtr_s
+
+ public:
+ TestSingleton(); // public constructor because we may want to manage this singleton
+ // with an orxonox::ScopedSingletonManager (see below)
+ virtual ~TestSingleton(); // public destructor
+
+ void testFunction(); // put your functions here
+
+ private:
+ int testValue_; // put your variables here
+
+ static TestSingleton* singletonPtr_s; // static singleton instance pointer, used by the Singleton template
+ };
+ @endcode
+
+ And don't forget to initialize the static singleton pointer in the source (*.cc) %file:
+ @code
+ TestSingleton* TestSingleton::singletonPtr_s = NULL;
+ @endcode
+
+ Usually a singleton gets created automatically when it is first used, but it will never
+ be destroyed (unless the singleton explicitly deletes itself). To allow controlled
+ construction and destruction, the singleton can be put within a virtual scope. This is
+ done by registering the singleton class with orxonox::ScopedSingletonManager. To
+ do so, the ManageScopedSingleton() macro has to be called:
+
+ @code
+ ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
+ @endcode
+
+ @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
+ because that's already done by the macro.
+
+ Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
+ active and also gets destroyed if the scope is deactivated.
+
+ Note that not all singletons must register with a scope, but it's recommended.
+
+ If a class inherits from orxonox::Singleton, it also inherits its functions. The most important
+ function is orxonox::Singleton::getInstance() which returns a reference to the only instance
+ of the singleton.
+
+ Example:
+ @code
+ TestSingleton::TestSingleton() // implement the constructor
+ {
+ this->testValue_ = 15;
+ }
+
+ void TestSingleton::testFunction() // implement testFunction
+ {
+ COUT(0) << "My value is " << this->testValue_ << std::endl;
+ }
+
+ TestSingleton::getInstance().testFunction(); // prints "My value is 15"
+ @endcode
+*/
+
#ifndef __Util_Singleton_H__
#define __Util_Singleton_H__
@@ -41,9 +121,10 @@
Base for singleton classes.
Usage:
- Inherit publicly from Singleton<MyClass> and provide access to
- MyClass::singletonPtr_s.
+ Inherit publicly from Singleton<MyClass> and provide access to MyClass::singletonPtr_s.
This can easily be done with a friend declaration.
+
+ See @ref SingletonExample "this example" for an exemplary implementation.
*/
template <class T>
class Singleton
@@ -79,7 +160,7 @@
T::singletonPtr_s = static_cast<T*>(this);
}
- //! Constructor resets the singleton instance pointer
+ //! Destructor resets the singleton instance pointer
~Singleton()
{
assert(T::singletonPtr_s != NULL);
Modified: code/branches/doc/src/libraries/util/mbool.h
===================================================================
--- code/branches/doc/src/libraries/util/mbool.h 2010-09-02 01:11:40 UTC (rev 7322)
+++ code/branches/doc/src/libraries/util/mbool.h 2010-09-02 01:16:08 UTC (rev 7323)
@@ -26,6 +26,12 @@
*
*/
+/**
+ @file
+ @ingroup Util
+ @brief Declaration and implementation of the @ref orxonox::mbool class.
+*/
+
#ifndef _mbool_H__
#define _mbool_H__
@@ -33,48 +39,77 @@
namespace orxonox
{
+ /**
+ @brief mbool is a small helper class that acts like a bool, but keeps track of the number of its state changes.
+
+ The mbool class acts like a bool, but it has an internal counter that counts
+ the number state changes (i.e. when the bool changes from true to false or
+ back). This is used in the network if a boolean value is synchronized, because
+ if a value changes quickly from false to true and back in the same tick, the
+ clients will never be notified of this action. By using mbool however this
+ behaviour is fixed, which is important for triggers and other objects.
+
+ @note This is efficiently solved by using a union that combines a counter and a
+ boolean bitfield of size 1. The boolean value corresponds always to the first
+ bit of the counter - this means, if the counter is incremented, the boolean state
+ changes. On the other hand, if you want to change the state, you can simply increase
+ the counter.
+ */
struct _UtilExport mbool
{
public:
+ /// Constructor: Creates the mbool and initializes the boolean value (default to false).
inline mbool(bool value = false)
{ this->value_.memory_ = 0; this->value_.bool_ = value; }
+ /// Copy-constructor, copies state and memory.
inline mbool(const mbool& value)
{ this->value_.memory_ = value.value_.memory_; }
+ /// Assigns a boolean value (and increases the memory value if the value is different to the old value).
inline mbool& operator=(bool value)
{ if (value != this->value_.bool_) { ++this->value_.memory_; } return (*this); }
+ /// Assigns another mbool, copies state and memory.
inline mbool& operator=(const mbool& value)
{ this->value_.memory_ = value.value_.memory_; return (*this); }
+ /// Increases the memory which also inverts it's state (++mbool).
inline mbool& operator++()
{ ++this->value_.memory_; return (*this); }
- inline mbool operator++(int i)
+ /// Increases the memory which also inverts it's state (mbool++).
+ inline mbool operator++(int)
{ mbool temp = (*this); ++this->value_.memory_; return temp; }
+ /// Implicitly converts the mbool to a bool.
inline operator bool() const
{ return this->value_.bool_; }
+ /// Compares the mbool to a bool, returns true if the bool has the same value as the state of the mbool.
inline bool operator==(bool other) const
{ return this->value_.bool_ == other; }
+ /// Compares the mbool to a bool, returns true if the bool has a different value than the state of the mbool.
inline bool operator!=(bool other) const
{ return this->value_.bool_ != other; }
+ /// Compares two mbools, returns true if their memory matches.
inline bool operator==(const mbool& other) const
{ return this->value_.memory_ == other.value_.memory_; }
+ /// Compares two mbools, returns true if they have a different memory value.
inline bool operator!=(const mbool& other) const
{ return this->value_.memory_ != other.value_.memory_; }
+ /// Returns the inverted state of the bool (doesn't change the internal state).
inline bool operator!() const
{ return (!this->value_.bool_); }
+ /// Returns the memory value.
inline unsigned char& getMemory(){ return value_.memory_; }
private:
union
{
- bool bool_ : 1;
- unsigned char memory_;
- } value_;
+ bool bool_ : 1; ///< The boolean state of the mbool, is located on the first bit of the memory variable
+ unsigned char memory_; ///< The memory of the mbool, counts the state-changes (and the first bit represents also the boolean value)
+ } value_; ///< A union containing the state and the memory of the mbool
};
}
More information about the Orxonox-commit
mailing list