Orxonox: src/util/MultiType.h File Reference

# MultiType.h File Reference

Declaration of the MultiType and some helper constructs. More...

`#include "UtilPrereqs.h"`
`#include <cassert>`
`#include <string>`
`#include <OgreVector2.h>`
`#include <OgreVector3.h>`
`#include <OgreVector4.h>`
`#include <OgreQuaternion.h>`
`#include <OgreColourValue.h>`
`#include "TemplateUtils.h"`

## Namespaces

namespace | orxonox
namespace | orxonox::MT_Type

## Classes

class | orxonox::MultiType
| The MultiType can hold a value of many possible types and convert them to other types. More...
class | orxonox::MultiType::MT_ValueBase
| MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType. This class is only used within the MultiType. More...

## Enumerations

enum

orxonox::MT_Type::Value {
orxonox::MT_Type::Null, orxonox::MT_Type::Char, orxonox::MT_Type::UnsignedChar, orxonox::MT_Type::Short,
orxonox::MT_Type::UnsignedShort, orxonox::MT_Type::Int, orxonox::MT_Type::UnsignedInt, orxonox::MT_Type::Long,
orxonox::MT_Type::UnsignedLong, orxonox::MT_Type::LongLong, orxonox::MT_Type::UnsignedLongLong, orxonox::MT_Type::Float,
orxonox::MT_Type::Double, orxonox::MT_Type::LongDouble, orxonox::MT_Type::Bool, orxonox::MT_Type::VoidPointer,
orxonox::MT_Type::String, orxonox::MT_Type::Vector2, orxonox::MT_Type::Vector3, orxonox::MT_Type::Vector4,
orxonox::MT_Type::ColourValue, orxonox::MT_Type::Quaternion, orxonox::MT_Type::Radian, orxonox::MT_Type::Degree
}

## Functions

template<>
bool | orxonox::MultiType::convert< const orxonox::ColourValue & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Degree & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Quaternion & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Radian & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Vector2 & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Vector3 & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const orxonox::Vector4 & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< const std::string & > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::ColourValue > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Degree > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Quaternion > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Radian > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Vector2 > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Vector3 > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< orxonox::Vector4 > ()
| Converts the current value to the given type.
template<>
bool | orxonox::MultiType::convert< std::string > ()
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::ColourValue > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Degree > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Quaternion > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Radian > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Vector2 > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Vector3 > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< orxonox::Vector4 > () const
| Returns true if the current type equals the given type.
template<>
bool | orxonox::MultiType::isType< std::string > () const
| Returns true if the current type equals the given type.
_UtilExport std::ostream & | orxonox::operator<< (std::ostream &outstream, const MultiType &mt)
| Puts the MultiType on a stream by using the native << operator of the current type.

## Detailed Description

Declaration of the MultiType and some helper constructs.

The MultiType can hold a value of one of the following types:

- all primitives
- all pointers
- 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.

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
- setValue<T>(value) assigns a new value and changes the type to T.