Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 14, 2008, 3:42:49 AM (16 years ago)
Author:
landauf
Message:

merged core2 back to trunk
there might be some errors, wasn't able to test it yet due to some strange g++ and linker behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/util/MultiTypePrimitive.h

    r890 r1052  
    3636#include "MultiType.h"
    3737
     38namespace orxonox
     39{
     40    class BaseObject;
     41}
    3842class _UtilExport MultiTypePrimitive
    3943{
    4044    public:
    41         MultiTypePrimitive(MultiType      type = MT_null);
     45        MultiTypePrimitive(MultiType type = MT_null);
     46        inline MultiTypePrimitive(void*          value) { this->setValue(value); }
    4247        inline MultiTypePrimitive(int            value) { this->setValue(value); }
    4348        inline MultiTypePrimitive(unsigned int   value) { this->setValue(value); }
     
    5661
    5762        inline MultiTypePrimitive& operator=(MultiType      value) { this->type_ = MT_null; return *this; }
     63        inline MultiTypePrimitive& operator=(void*          value) { this->setValue(value); return *this; }
    5864        inline MultiTypePrimitive& operator=(int            value) { this->setValue(value); return *this; }
    5965        inline MultiTypePrimitive& operator=(unsigned int   value) { this->setValue(value); return *this; }
     
    7076        inline MultiTypePrimitive& operator=(const MultiTypePrimitive& mtp) { this->setValue(mtp); return *this; }
    7177
     78        inline bool operator==(void*          value) const { return (this->value_.void_       == value); }
    7279        inline bool operator==(int            value) const { return (this->value_.int_        == value); }
    7380        inline bool operator==(unsigned int   value) const { return (this->value_.uint_       == value); }
     
    8491        bool operator==(const MultiTypePrimitive& mtp) const;
    8592
    86         inline bool operator!=(int            value) const { return (this->value_.int_        != value); }
     93        inline bool operator!=(void*          value) const { return (this->value_.void_       != value); }
    8794        inline bool operator!=(unsigned int   value) const { return (this->value_.uint_       != value); }
    8895        inline bool operator!=(char           value) const { return (this->value_.char_       != value); }
     
    98105        bool operator!=(const MultiTypePrimitive& mtp) const;
    99106
     107        template <class T>
     108        operator T*()                     const
     109        { return ((T*)this->value_.void_); }
     110        virtual operator void*()          const;
    100111        virtual operator int()            const;
    101112        virtual operator unsigned int()   const;
     
    111122        virtual operator bool()           const;
    112123
     124        inline void setValue(void*          value) { this->type_ = MT_void;       this->value_.void_       = value; }
    113125        inline void setValue(int            value) { this->type_ = MT_int;        this->value_.int_        = value; }
    114126        inline void setValue(unsigned int   value) { this->type_ = MT_uint;       this->value_.uint_       = value; }
     
    125137        void setValue(const MultiTypePrimitive& mtp);
    126138
     139        inline void*          getVoid()          const { return this->value_.void_;        }
    127140        inline int            getInt()           const { return this->value_.int_;        }
    128141        inline unsigned int   getUnsignedInt()   const { return this->value_.uint_;       }
     
    151164        inline bool&           getBool()          { return this->value_.bool_;       }
    152165
     166        inline void getValue(void*           variable) const { variable    = this->value_.void_;       }
    153167        inline void getValue(int*            variable) const { (*variable) = this->value_.int_;        }
    154168        inline void getValue(unsigned int*   variable) const { (*variable) = this->value_.uint_;       }
     
    167181        inline bool      isA(MultiType type) const { return (this->type_ == type); }
    168182
     183        virtual std::string getTypename() const;
     184
    169185        virtual std::string toString() const;
    170186        virtual bool fromString(const std::string value);
Note: See TracChangeset for help on using the changeset viewer.