Orxonox
0.0.5 Codename: Arcturus
|
The MultiType can hold a value of many possible types and convert them to other types. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/util/MultiType.h>
Classes | |
class | MT_ValueBase |
MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType. More... | |
Public Member Functions | |
MultiType () | |
Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. More... | |
template<typename V > | |
MultiType (const V &value) | |
Constructor: Assigns the given value and sets the type. More... | |
MultiType (const MultiType &other) | |
Copyconstructor: Assigns value and type of the other MultiType. More... | |
MultiType (MultiType &&other) | |
Moveconstructor: Moves the value and its type from the other MultiType. More... | |
~MultiType () | |
Destructor: Deletes the MT_Value. More... | |
template<typename T > | |
bool | convert () |
Converts the current value to type T. More... | |
template<> | |
bool | convert () |
void | copy (const MultiType &other) |
Copies the other MultiType by assigning value and type. More... | |
template<> | |
void | createNewValueContainer (const char &value) |
template<> | |
void | createNewValueContainer (const unsigned char &value) |
template<> | |
void | createNewValueContainer (const short &value) |
template<> | |
void | createNewValueContainer (const unsigned short &value) |
template<> | |
void | createNewValueContainer (const int &value) |
template<> | |
void | createNewValueContainer (const unsigned int &value) |
template<> | |
void | createNewValueContainer (const long &value) |
template<> | |
void | createNewValueContainer (const unsigned long &value) |
template<> | |
void | createNewValueContainer (const long long &value) |
template<> | |
void | createNewValueContainer (const unsigned long long &value) |
template<> | |
void | createNewValueContainer (const float &value) |
template<> | |
void | createNewValueContainer (const double &value) |
template<> | |
void | createNewValueContainer (const long double &value) |
template<> | |
void | createNewValueContainer (const bool &value) |
template<> | |
void | createNewValueContainer (void *const &value) |
template<> | |
void | createNewValueContainer (const std::string &value) |
template<> | |
void | createNewValueContainer (const orxonox::Vector2 &value) |
template<> | |
void | createNewValueContainer (const orxonox::Vector3 &value) |
template<> | |
void | createNewValueContainer (const orxonox::Vector4 &value) |
template<> | |
void | createNewValueContainer (const orxonox::ColourValue &value) |
template<> | |
void | createNewValueContainer (const orxonox::Quaternion &value) |
template<> | |
void | createNewValueContainer (const orxonox::Radian &value) |
template<> | |
void | createNewValueContainer (const orxonox::Degree &value) |
template<> | |
_UtilExport void | createNewValueContainer (const char &value) |
template<> | |
_UtilExport void | createNewValueContainer (const unsigned char &value) |
template<> | |
_UtilExport void | createNewValueContainer (const short &value) |
template<> | |
_UtilExport void | createNewValueContainer (const unsigned short &value) |
template<> | |
_UtilExport void | createNewValueContainer (const int &value) |
template<> | |
_UtilExport void | createNewValueContainer (const unsigned int &value) |
template<> | |
_UtilExport void | createNewValueContainer (const long &value) |
template<> | |
_UtilExport void | createNewValueContainer (const unsigned long &value) |
template<> | |
_UtilExport void | createNewValueContainer (const long long &value) |
template<> | |
_UtilExport void | createNewValueContainer (const unsigned long long &value) |
template<> | |
_UtilExport void | createNewValueContainer (const float &value) |
template<> | |
_UtilExport void | createNewValueContainer (const double &value) |
template<> | |
_UtilExport void | createNewValueContainer (const bool &value) |
template<> | |
_UtilExport void | createNewValueContainer (const long double &value) |
template<> | |
_UtilExport void | createNewValueContainer (void *const &value) |
template<> | |
_UtilExport void | createNewValueContainer (const std::string &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Vector2 &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Vector3 &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Vector4 &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::ColourValue &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Quaternion &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Radian &value) |
template<> | |
_UtilExport void | createNewValueContainer (const orxonox::Degree &value) |
void | exportData (uint8_t *&mem) const |
Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT. More... | |
template<typename T , typename V > | |
bool | force (const V &value) |
Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). More... | |
template<typename T > | |
std::enable_if<!std::is_pointer< T >::value, T >::type | get () const |
Returns the current value, converted to the requested type. More... | |
template<typename T > | |
std::enable_if< std::is_pointer< T >::value, T >::type | get () const |
Returns the current value, converted to a pointer of the requested type. More... | |
uint32_t | getNetworkSize () const |
std::string | getTypename () const |
Returns the name of the current type. More... | |
template<typename T > | |
bool | getValue (T *value) const |
Assigns the value to the given pointer. The value gets converted if the types don't match. More... | |
void | importData (uint8_t *&mem) |
Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT. More... | |
template<typename T > | |
bool | isType () const |
Returns true if the type of the current value is T. More... | |
template<> | |
bool | isType () const |
bool | lastConversionSuccessful () const |
Checks whether the last conversion was successful. More... | |
bool | null () const |
Checks if the MT contains no value. More... | |
template<class T > | |
operator T () const | |
Conversion operator for all types. More... | |
uint8_t *& | operator<< (uint8_t *&mem) |
Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT. More... | |
template<typename V > | |
MultiType & | operator= (const V &value) |
Assigns a new value. The value will be converted to the current type of the MultiType. More... | |
template<typename V > | |
MultiType & | operator= (V *value) |
Assigns a pointer. More... | |
MultiType & | operator= (const MultiType &other) |
Assigns the value of the other MultiType and converts it to the current type of the MultiType. More... | |
MultiType & | operator= (MultiType &&other) |
Moves the value and the type of the other MultiType to this one. More... | |
void | operator>> (uint8_t *&mem) const |
Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT. More... | |
void | reset () |
Resets value and type. Type will be void afterwards and null() returns true. More... | |
template<typename T > | |
void | reset () |
Resets the value and changes the internal type to T. More... | |
void | resetValue () |
Current value gets overridden with default zero value. More... | |
template<typename V > | |
bool | set (const V &value) |
Assigns the given value and converts it to the current type. More... | |
template<typename V > | |
bool | set (V *value) |
Assigns a pointer. More... | |
bool | set (const MultiType &other) |
Assigns the value of the other MultiType and converts it to the current type. More... | |
template<> | |
bool | set (const char *value) |
template<> | |
bool | set (const mbool &value) |
Static Public Attributes | |
static const MultiType | Null |
Private Types | |
enum | Type : uint8_t { Type::Null, Type::Char, Type::UnsignedChar, Type::Short, Type::UnsignedShort, Type::Int, Type::UnsignedInt, Type::Long, Type::UnsignedLong, Type::LongLong, Type::UnsignedLongLong, Type::Float, Type::Double, Type::LongDouble, Type::Bool, Type::VoidPointer, Type::String, Type::Vector2, Type::Vector3, Type::Vector4, Type::ColourValue, Type::Quaternion, Type::Radian, Type::Degree } |
Enum of all possible types of a MultiType. More... | |
Private Member Functions | |
template<typename T > | |
void | assignValue (const T &value) |
Assigns a new value by changing type and creating a new container. More... | |
template<typename T > | |
void | assignValue (T *const &value) |
Assigns a new value by changing type and creating a new container (overload for pointers). More... | |
template<typename T > | |
void | changeValueContainer (const T &value) |
Changes the value container. More... | |
bool | convert (Type type) |
Converts the current value to the given type. More... | |
template<typename T > | |
std::enable_if<!std::is_enum< T >::value >::type | createNewValueContainer (const T &value) |
Creates a new value container (works only with specialized types). More... | |
template<typename T > | |
std::enable_if< std::is_enum< T >::value >::type | createNewValueContainer (const T &value) |
Creates a new value container (implementation for enum classes that must be cast to the underlying type). More... | |
Type | getType () const |
Returns the current type. More... | |
void | setType (Type type) |
Resets the value and changes the internal type to the given type. More... | |
Private Attributes | |
MT_ValueBase * | value_ |
A pointer to the value container. More... | |
Friends | |
template<typename T > | |
class | MT_Value |
_UtilExport friend std::ostream & | operator<< (std::ostream &outstream, const MultiType &mt) |
Puts the MultiType on a stream by using the native << operator of the current type. More... | |
The MultiType can hold a value of many possible types and convert them to other types.
The following types are supported by the MultiType:
For more information and some examples see the description here.
|
strongprivate |
Enum of all possible types of a MultiType.
|
inline |
Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
|
inline |
Constructor: Assigns the given value and sets the type.
|
inline |
Copyconstructor: Assigns value and type of the other MultiType.
|
inline |
Moveconstructor: Moves the value and its type from the other MultiType.
|
inline |
Destructor: Deletes the MT_Value.
|
inlineprivate |
Assigns a new value by changing type and creating a new container.
|
inlineprivate |
Assigns a new value by changing type and creating a new container (overload for pointers).
|
inlineprivate |
Changes the value container.
|
inline |
Converts the current value to type T.
|
private |
Converts the current value to the given type.
Converts the current value of the MultiType to a new type.
type | The type |
|
inline |
Copies the other MultiType by assigning value and type.
void orxonox::MultiType::createNewValueContainer | ( | const char & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const unsigned char & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const short & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const unsigned short & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const int & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const unsigned int & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const long & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const unsigned long & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const long long & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const unsigned long long & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const float & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const double & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const long double & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const bool & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const std::string & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector2 & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector3 & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector4 & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::ColourValue & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Quaternion & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Radian & | value | ) |
void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Degree & | value | ) |
|
inlineprivate |
Creates a new value container (works only with specialized types).
|
inlineprivate |
Creates a new value container (implementation for enum classes that must be cast to the underlying type).
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const char & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const unsigned char & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const short & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const unsigned short & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const int & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const unsigned int & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const long & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const unsigned long & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const long long & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const unsigned long long & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const float & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const double & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const bool & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const long double & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | void *const & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const std::string & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector2 & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector3 & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Vector4 & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::ColourValue & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Quaternion & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Radian & | value | ) |
_UtilExport void orxonox::MultiType::createNewValueContainer | ( | const orxonox::Degree & | value | ) |
|
inline |
Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT.
|
inline |
Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
|
inline |
Returns the current value, converted to the requested type.
|
inline |
Returns the current value, converted to a pointer of the requested type.
|
inline |
|
inlineprivate |
Returns the current type.
std::string orxonox::MultiType::getTypename | ( | ) | const |
Returns the name of the current type.
|
inline |
Assigns the value to the given pointer. The value gets converted if the types don't match.
|
inline |
Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT.
|
inline |
Returns true if the type of the current value is T.
|
inline |
|
inline |
Checks whether the last conversion was successful.
|
inline |
Checks if the MT contains no value.
|
inline |
Conversion operator for all types.
|
inline |
Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT.
|
inline |
Assigns a new value. The value will be converted to the current type of the MultiType.
|
inline |
Assigns a pointer.
Moves the value and the type of the other MultiType to this one.
|
inline |
Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT.
|
inline |
Resets value and type. Type will be void afterwards and null() returns true.
|
inline |
Resets the value and changes the internal type to T.
|
inline |
Current value gets overridden with default zero value.
|
inline |
Assigns the given value and converts it to the current type.
|
inline |
Assigns a pointer.
|
inline |
Assigns the value of the other MultiType and converts it to the current type.
|
inline |
|
inline |
Resets the value and changes the internal type to the given type.
|
friend |
|
friend |
Puts the MultiType on a stream by using the native << operator of the current type.
|
static |
|
private |
A pointer to the value container.