Orxonox
0.0.5 Codename: Arcturus
|
Declaration of the MultiType and some helper constructs. More...
#include "UtilPrereqs.h"
#include <cassert>
#include <string>
#include <utility>
#include <OgreVector2.h>
#include <OgreVector3.h>
#include <OgreVector4.h>
#include <OgreQuaternion.h>
#include <OgreColourValue.h>
#include <loki/TypeTraits.h>
#include "Math.h"
#include "mbool.h"
Go to the source code of this file.
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. More... | |
Namespaces | |
orxonox | |
Die Wagnis Klasse hat die folgenden Aufgaben: | |
Functions | |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::ColourValue > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Degree > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Quaternion > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Radian > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Vector2 > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Vector3 > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< orxonox::Vector4 > () const |
template<> | |
bool | orxonox::MultiType::MT_ValueBase::isType< std::string > () const |
_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. More... | |
Declaration of the MultiType and some helper constructs.
The MultiType can hold a value of one of the following types:
The MultiType has an internal "type" determined by the first assigned value, using one of these ways:
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:
Examples:
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:
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.