Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 9, 2008, 4:04:23 AM (17 years ago)
Author:
landauf
Message:

cool shit's happening here… it works! wow. I wonder why, but hey, don't ask, just commit. this update might also be helpful for the network guys.

  • fixed a bug in XMLPort
  • fixed a bug in the MultiTypes
  • implemented some XMLPort functions in Model, SpaceShip, Skybox and Ambient (and of course the WorldEntity), but this is just a workaround as all those classes are more or less just temporary solutions
Location:
code/branches/core/src/util
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/util/MultiTypeMath.cc

    r855 r869  
    8888}
    8989
     90MultiTypeMath::operator int() const
     91{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeMath, int>(*this); }
     92MultiTypeMath::operator unsigned int() const
     93{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeMath, unsigned int>(*this); }
     94MultiTypeMath::operator char() const
     95{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeMath, char>(*this); }
     96MultiTypeMath::operator unsigned char() const
     97{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeMath, unsigned char>(*this); }
     98MultiTypeMath::operator short() const
     99{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeMath, short>(*this); }
     100MultiTypeMath::operator unsigned short() const
     101{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeMath, unsigned short>(*this); }
     102MultiTypeMath::operator long() const
     103{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeMath, long>(*this); }
     104MultiTypeMath::operator unsigned long() const
     105{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeMath, unsigned long>(*this); }
     106MultiTypeMath::operator float() const
     107{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeMath, float>(*this); }
     108MultiTypeMath::operator double() const
     109{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeMath, double>(*this); }
     110MultiTypeMath::operator long double() const
     111{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeMath, long double>(*this); }
     112MultiTypeMath::operator bool() const
     113{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeMath, bool>(*this); }
     114MultiTypeMath::operator std::string() const
     115{ return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeMath, std::string>(*this); }
     116MultiTypeMath::operator const char*() const
     117{ return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeMath, std::string>(*this)).c_str(); }
    90118MultiTypeMath::operator orxonox::Vector2() const
    91 {
    92     return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector2>(*this);
    93 }
    94 
     119{ return (this->type_ == MT_vector2) ? this->vector2_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector2>(*this); }
    95120MultiTypeMath::operator orxonox::Vector3() const
    96 {
    97     return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this);
    98 }
    99 
     121{ return (this->type_ == MT_vector3) ? this->vector3_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Vector3>(*this); }
    100122MultiTypeMath::operator orxonox::Quaternion() const
    101 {
    102     return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Quaternion>(*this);
    103 }
    104 
     123{ return (this->type_ == MT_quaternion) ? this->quaternion_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Quaternion>(*this); }
    105124MultiTypeMath::operator orxonox::ColourValue() const
    106 {
    107     return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypeMath, orxonox::ColourValue>(*this);
    108 }
    109 
     125{ return (this->type_ == MT_colourvalue) ? this->colourvalue_ : ConvertValueAndReturn<MultiTypeMath, orxonox::ColourValue>(*this); }
    110126MultiTypeMath::operator orxonox::Radian() const
    111 {
    112     return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Radian>(*this);
    113 }
    114 
     127{ return (this->type_ == MT_radian) ? this->radian_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Radian>(*this); }
    115128MultiTypeMath::operator orxonox::Degree() const
    116 {
    117     return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Degree>(*this);
    118 }
     129{ return (this->type_ == MT_degree) ? this->degree_ : ConvertValueAndReturn<MultiTypeMath, orxonox::Degree>(*this); }
    119130
    120131void MultiTypeMath::setValue(const MultiTypeMath& mtm)
     
    171182std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm)
    172183{
    173     if (mtm.isA(MT_vector2))
    174         out << mtm.getVector2();
    175     else if (mtm.isA(MT_vector3))
    176         out << mtm.getVector3();
    177     else if (mtm.isA(MT_colourvalue))
    178         out << mtm.getColourValue();
    179     else if (mtm.isA(MT_quaternion))
    180         out << mtm.getQuaternion();
    181     else if (mtm.isA(MT_radian))
    182         out << mtm.getRadian();
    183     else if (mtm.isA(MT_degree))
    184         out << mtm.getDegree();
    185     else
    186         out << ((MultiTypeString)mtm);
    187 
     184    out << mtm.toString();
    188185    return out;
    189186}
  • code/branches/core/src/util/MultiTypeMath.h

    r854 r869  
    6060        inline MultiTypeMath(const orxonox::Degree&      value) { this->setValue(value); }
    6161        inline MultiTypeMath(const MultiTypeMath& mtm)          { this->setValue(mtm);   }
     62        virtual inline ~MultiTypeMath() {}
    6263
    6364        using MultiTypeString::operator=;
     
    8889        bool operator!=(const MultiTypeMath& mtm) const;
    8990
    90         operator orxonox::Vector2()     const;
    91         operator orxonox::Vector3()     const;
    92         operator orxonox::ColourValue() const;
    93         operator orxonox::Quaternion()  const;
    94         operator orxonox::Radian()      const;
    95         operator orxonox::Degree()      const;
     91        virtual operator int()                  const;
     92        virtual operator unsigned int()         const;
     93        virtual operator char()                 const;
     94        virtual operator unsigned char()        const;
     95        virtual operator short()                const;
     96        virtual operator unsigned short()       const;
     97        virtual operator long()                 const;
     98        virtual operator unsigned long()        const;
     99        virtual operator float ()               const;
     100        virtual operator double ()              const;
     101        virtual operator long double()          const;
     102        virtual operator bool()                 const;
     103        virtual operator std::string()          const;
     104        virtual operator const char*()          const;
     105        virtual operator orxonox::Vector2()     const;
     106        virtual operator orxonox::Vector3()     const;
     107        virtual operator orxonox::ColourValue() const;
     108        virtual operator orxonox::Quaternion()  const;
     109        virtual operator orxonox::Radian()      const;
     110        virtual operator orxonox::Degree()      const;
    96111
    97112        using MultiTypeString::setValue;
     
    126141        inline void getValue(orxonox::Degree*      variable) const { (*variable) = orxonox::Degree      (this->degree_);      }
    127142
    128         std::string toString() const;
    129         bool fromString(const std::string value);
     143        virtual std::string toString() const;
     144        virtual bool fromString(const std::string value);
    130145
    131146    protected:
  • code/branches/core/src/util/MultiTypePrimitive.cc

    r854 r869  
    129129
    130130MultiTypePrimitive::operator int() const
    131 {
    132     return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this);
    133 }
    134 
     131{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypePrimitive, int>(*this); }
    135132MultiTypePrimitive::operator unsigned int() const
    136 {
    137     return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this);
    138 }
    139 
     133{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned int>(*this); }
    140134MultiTypePrimitive::operator char() const
    141 {
    142     return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this);
    143 }
    144 
     135{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypePrimitive, char>(*this); }
    145136MultiTypePrimitive::operator unsigned char() const
    146 {
    147     return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this);
    148 }
    149 
     137{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned char>(*this); }
    150138MultiTypePrimitive::operator short() const
    151 {
    152     return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this);
    153 }
    154 
     139{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypePrimitive, short>(*this); }
    155140MultiTypePrimitive::operator unsigned short() const
    156 {
    157     return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this);
    158 }
    159 
     141{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned short>(*this); }
    160142MultiTypePrimitive::operator long() const
    161 {
    162     return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this);
    163 }
    164 
     143{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypePrimitive, long>(*this); }
    165144MultiTypePrimitive::operator unsigned long() const
    166 {
    167     return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this);
    168 }
    169 
     145{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypePrimitive, unsigned long>(*this); }
    170146MultiTypePrimitive::operator float() const
    171 {
    172     return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this);
    173 }
    174 
     147{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypePrimitive, float>(*this); }
    175148MultiTypePrimitive::operator double() const
    176 {
    177     return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this);
    178 }
    179 
     149{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypePrimitive, double>(*this); }
    180150MultiTypePrimitive::operator long double() const
    181 {
    182     return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this);
    183 }
    184 
     151{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypePrimitive, long double>(*this); }
    185152MultiTypePrimitive::operator bool() const
    186 {
    187     return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this);
    188 }
     153{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypePrimitive, bool>(*this); }
    189154
    190155void MultiTypePrimitive::setValue(const MultiTypePrimitive& mtp)
     
    258223std::ostream& operator<<(std::ostream& out, const MultiTypePrimitive& mtp)
    259224{
    260     if (mtp.isA(MT_int))
    261         out << mtp.getInt();
    262     else if (mtp.isA(MT_uint))
    263         out << mtp.getUnsignedInt();
    264     else if (mtp.isA(MT_char))
    265         out << mtp.getChar();
    266     else if (mtp.isA(MT_uchar))
    267         out << mtp.getUnsignedChar();
    268     else if (mtp.isA(MT_short))
    269         out << mtp.getShort();
    270     else if (mtp.isA(MT_ushort))
    271         out << mtp.getUnsignedShort();
    272     else if (mtp.isA(MT_long))
    273         out << mtp.getLong();
    274     else if (mtp.isA(MT_ulong))
    275         out << mtp.getUnsignedLong();
    276     else if (mtp.isA(MT_float))
    277         out << mtp.getFloat();
    278     else if (mtp.isA(MT_double))
    279         out << mtp.getDouble();
    280     else if (mtp.isA(MT_longdouble))
    281         out << mtp.getLongDouble();
    282     else if (mtp.isA(MT_bool))
    283         out << mtp.getBool();
    284 
     225    out << mtp.toString();
    285226    return out;
    286227}
  • code/branches/core/src/util/MultiTypePrimitive.h

    r853 r869  
    5353        inline MultiTypePrimitive(bool           value) { this->setValue(value); }
    5454        inline MultiTypePrimitive(const MultiTypePrimitive& mtp) { this->setValue(mtp); }
     55        virtual inline ~MultiTypePrimitive() {}
    5556
    5657        inline MultiTypePrimitive& operator=(MultiType      value) { this->type_ = MT_null; return *this; }
     
    9798        bool operator!=(const MultiTypePrimitive& mtp) const;
    9899
    99         operator int()            const;
    100         operator unsigned int()   const;
    101         operator char()           const;
    102         operator unsigned char()  const;
    103         operator short()          const;
    104         operator unsigned short() const;
    105         operator long()           const;
    106         operator unsigned long()  const;
    107         operator float ()         const;
    108         operator double ()        const;
    109         operator long double()    const;
    110         operator bool()           const;
     100        virtual operator int()            const;
     101        virtual operator unsigned int()   const;
     102        virtual operator char()           const;
     103        virtual operator unsigned char()  const;
     104        virtual operator short()          const;
     105        virtual operator unsigned short() const;
     106        virtual operator long()           const;
     107        virtual operator unsigned long()  const;
     108        virtual operator float ()         const;
     109        virtual operator double ()        const;
     110        virtual operator long double()    const;
     111        virtual operator bool()           const;
    111112
    112113        inline void setValue(int            value) { this->type_ = MT_int;        this->value_.int_        = value; }
     
    166167        inline bool      isA(MultiType type) const { return (this->type_ == type); }
    167168
    168         std::string toString() const;
    169         bool fromString(const std::string value);
     169        virtual std::string toString() const;
     170        virtual bool fromString(const std::string value);
    170171
    171172    protected:
  • code/branches/core/src/util/MultiTypeString.cc

    r853 r869  
    6464}
    6565
     66MultiTypeString::operator int() const
     67{ return (this->type_ == MT_int) ? this->value_.int_ : ConvertValueAndReturn<MultiTypeString, int>(*this); }
     68MultiTypeString::operator unsigned int() const
     69{ return (this->type_ == MT_uint) ? this->value_.uint_ : ConvertValueAndReturn<MultiTypeString, unsigned int>(*this); }
     70MultiTypeString::operator char() const
     71{ return (this->type_ == MT_char) ? this->value_.char_ : ConvertValueAndReturn<MultiTypeString, char>(*this); }
     72MultiTypeString::operator unsigned char() const
     73{ return (this->type_ == MT_uchar) ? this->value_.uchar_ : ConvertValueAndReturn<MultiTypeString, unsigned char>(*this); }
     74MultiTypeString::operator short() const
     75{ return (this->type_ == MT_short) ? this->value_.short_ : ConvertValueAndReturn<MultiTypeString, short>(*this); }
     76MultiTypeString::operator unsigned short() const
     77{ return (this->type_ == MT_ushort) ? this->value_.ushort_ : ConvertValueAndReturn<MultiTypeString, unsigned short>(*this); }
     78MultiTypeString::operator long() const
     79{ return (this->type_ == MT_long) ? this->value_.long_ : ConvertValueAndReturn<MultiTypeString, long>(*this); }
     80MultiTypeString::operator unsigned long() const
     81{ return (this->type_ == MT_ulong) ? this->value_.ulong_ : ConvertValueAndReturn<MultiTypeString, unsigned long>(*this); }
     82MultiTypeString::operator float() const
     83{ return (this->type_ == MT_float) ? this->value_.float_ : ConvertValueAndReturn<MultiTypeString, float>(*this); }
     84MultiTypeString::operator double() const
     85{ return (this->type_ == MT_double) ? this->value_.double_ : ConvertValueAndReturn<MultiTypeString, double>(*this); }
     86MultiTypeString::operator long double() const
     87{ return (this->type_ == MT_longdouble) ? this->value_.longdouble_ : ConvertValueAndReturn<MultiTypeString, long double>(*this); }
     88MultiTypeString::operator bool() const
     89{ return (this->type_ == MT_bool) ? this->value_.bool_ : ConvertValueAndReturn<MultiTypeString, bool>(*this); }
    6690MultiTypeString::operator std::string() const
    67 {
    68     return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this);
    69 }
    70 
     91{ return (this->type_ == MT_string) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this); }
    7192MultiTypeString::operator const char*() const
    72 {
    73     return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str();
    74 }
     93{ return ((this->type_ == MT_constchar) ? this->string_ : ConvertValueAndReturn<MultiTypeString, std::string>(*this)).c_str(); }
    7594
    7695void MultiTypeString::setValue(const MultiTypeString& mts)
     
    104123std::ostream& operator<<(std::ostream& out, MultiTypeString& mts)
    105124{
    106     if (mts.isA(MT_constchar))
    107         out << mts.getConstChar();
    108     else if (mts.isA(MT_string))
    109         out << mts.getString();
    110     else
    111         out << ((MultiTypePrimitive)mts);
    112 
     125    out << mts.toString();
    113126    return out;
    114127}
  • code/branches/core/src/util/MultiTypeString.h

    r854 r869  
    5555        inline MultiTypeString(const std::string& value)   { this->setValue(value); }
    5656        inline MultiTypeString(const MultiTypeString& mts) { this->setValue(mts);   }
     57        virtual inline ~MultiTypeString() {}
    5758
    5859        using MultiTypePrimitive::operator=;
     
    7172        bool operator!=(const MultiTypeString& mts) const;
    7273
    73         operator std::string() const;
    74         operator const char*() const;
     74        virtual operator int()            const;
     75        virtual operator unsigned int()   const;
     76        virtual operator char()           const;
     77        virtual operator unsigned char()  const;
     78        virtual operator short()          const;
     79        virtual operator unsigned short() const;
     80        virtual operator long()           const;
     81        virtual operator unsigned long()  const;
     82        virtual operator float ()         const;
     83        virtual operator double ()        const;
     84        virtual operator long double()    const;
     85        virtual operator bool()           const;
     86        virtual operator std::string()    const;
     87        virtual operator const char*()    const;
    7588
    7689        using MultiTypePrimitive::setValue;
     
    89102        inline void getValue(const char** variable) const { (*variable) = this->string_.c_str(); }
    90103
    91         std::string toString() const;
    92         bool fromString(const std::string value);
     104        virtual std::string toString() const;
     105        virtual bool fromString(const std::string value);
    93106
    94107    protected:
Note: See TracChangeset for help on using the changeset viewer.