Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1728


Ignore:
Timestamp:
Sep 7, 2008, 3:29:25 AM (16 years ago)
Author:
landauf
Message:

Added getXXX() functions to MultiType, where XXX stands for any supported typename.
getString() replaces toString().
Like in getValue(type* pointer), the current value gets converted to the requested type. It's basically just a call to the convert-operator, so (1) "type a = mymultitype;", (2) "type a; mymultitype.getValue(&a);" and (3) "type a = get'Type'();" are equivalent, but the implicit cast (1) may be ambiguous.

Location:
code/branches/core3/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/CommandEvaluation.cc

    r1716 r1728  
    304304
    305305            if (command->defaultValueSet(i))
    306                 output += "=" + command->getDefaultValue(i).toString() + "]";
     306                output += "=" + command->getDefaultValue(i).getString() + "]";
    307307            else
    308308                output += "}";
  • code/branches/core3/src/core/ConfigValueContainer.cc

    r1720 r1728  
    6969        this->bIsVector_ = false;
    7070
    71         this->defvalueString_ = this->value_.toString();
     71        this->defvalueString_ = this->value_.getString();
    7272        this->update();
    7373    }
  • code/branches/core3/src/core/TclBind.cc

    r1594 r1728  
    115115
    116116        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    117             return CommandExecutor::getLastEvaluation().getReturnvalue().toString();
     117            return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    118118
    119119        return "";
  • code/branches/core3/src/core/TclThreadManager.cc

    r1682 r1728  
    519519
    520520                if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    521                     output = CommandExecutor::getLastEvaluation().getReturnvalue().toString();
     521                    output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    522522            }
    523523
  • code/branches/core3/src/util/MultiType.h

    r1726 r1728  
    214214        inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); }
    215215
     216        inline MT_Type                    getType()                 const { return (this->value_) ? this->value_->type_ : MT_null; }
     217        inline bool                       isType(MT_Type type)      const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
     218        template <typename T> inline bool isType()                  const { return false; }
     219        std::string                       getTypename()             const;
     220
    216221        operator char()                  const;
    217222        operator unsigned char()         const;
     
    263268        inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } }
    264269
    265         inline MT_Type                    getType()            const { return (this->value_) ? this->value_->type_ : MT_null; }
    266         inline bool                       isType(MT_Type type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
    267         template <typename T> inline bool isType()             const { return false; }
    268         std::string                       getTypename()        const;
    269 
    270         inline std::string toString() const { return this->operator std::string(); }
     270        inline char                     getChar()             const { return this->operator char();                 }
     271        inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        }
     272        inline short                    getShort()            const { return this->operator short();                }
     273        inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       }
     274        inline int                      getInt()              const { return this->operator int();                  }
     275        inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         }
     276        inline long                     getLong()             const { return this->operator long();                 }
     277        inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        }
     278        inline long long                getLongLong()         const { return this->operator long long();            }
     279        inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   }
     280        inline float                    getFloat()            const { return this->operator float();                }
     281        inline double                   getDouble()           const { return this->operator double();               }
     282        inline long double              getLongDouble()       const { return this->operator long double();          }
     283        inline bool                     getBool()             const { return this->operator bool();                 }
     284        inline void*                    getVoid()             const { return this->operator void*();                }
     285        inline std::string              getString()           const { return this->operator std::string();          }
     286        inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     }
     287        inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     }
     288        inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     }
     289        inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); }
     290        inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  }
     291        inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      }
     292        inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      }
     293        template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 }
    271294
    272295    private:
Note: See TracChangeset for help on using the changeset viewer.