Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 6, 2008, 4:21:56 PM (16 years ago)
Author:
landauf
Message:

Added new 'MultiType', replacing MultiTypePrimitive, MultiTypeString and MultiTypeMath. MultiType can hold all types MultiTypeMath was able to hold, namely all primitives, pointers, string and several math objects (vector2, 3 and 4, quaternion, colourvalue, radian, degree).

The new MultiType has a completely changed behaviour, I'll explain this on a wiki page somewhen.
But to say the most important things in a few words:
The MultiType has a fixed type. This type is determined by the first assigned value (by using setValue(value), operator=(value) or MultiType(value)). Every other value getting assigned later, will be converted to the first type. But you can change the type (setType<T>()), convert the value (convert<T>()) or force the type of a newly assigned value manually (setValue<T>(value)) by using template functions.

In contrast, the old MultiTypeMath changed it's internal type whenever a new type was assigned. So be aware of this important change.

At the moment I can't see any issues, but there might very well be several problems yet to discover, so further tests will be done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/ConfigValueContainer.h

    r1611 r1716  
    5050
    5151#include "util/Math.h"
    52 #include "util/MultiTypeMath.h"
     52#include "util/MultiType.h"
    5353#include "ConfigFileManager.h"
    5454
     
    124124                this->value_ = V();
    125125                for (unsigned int i = 0; i < defvalue.size(); i++)
    126                     this->valueVector_.push_back(MultiTypeMath(defvalue[i]));
     126                    this->valueVector_.push_back(MultiType(defvalue[i]));
    127127
    128128                this->initVector();
     
    247247            }
    248248
    249             bool set(const MultiTypeMath& input);
    250             bool tset(const MultiTypeMath& input);
    251 
    252             bool set(unsigned int index, const MultiTypeMath& input);
    253             bool tset(unsigned int index, const MultiTypeMath& input);
    254             bool add(const MultiTypeMath& input);
     249            bool set(const MultiType& input);
     250            bool tset(const MultiType& input);
     251
     252            bool set(unsigned int index, const MultiType& input);
     253            bool tset(unsigned int index, const MultiType& input);
     254            bool add(const MultiType& input);
    255255            bool remove(unsigned int index);
    256256
     
    260260            /** @brief Converts the config-value to a string. @return The string */
    261261            inline std::string toString() const
    262                 { return this->value_.toString(); }
     262                { return this->value_; }
    263263            /** @brief Returns the typename of the assigned config-value. @return The typename */
    264264            inline std::string getTypename() const
     
    267267        private:
    268268            void init(ConfigFileType type, Identifier* identifier, const std::string& varname);
    269             void initValue(const MultiTypeMath& defvalue);
     269            void initValue(const MultiType& defvalue);
    270270            void initVector();
    271             bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input);
     271            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input);
    272272
    273273            bool                       bIsVector_;                  //!< True if the container contains a std::vector
     
    280280            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
    281281
    282             MultiTypeMath              value_;                      //!< The value
    283             std::vector<MultiTypeMath> valueVector_;                //!< A vector, containg the values in case we're storing a vector
     282            MultiType                  value_;                      //!< The value
     283            std::vector<MultiType>    valueVector_;                //!< A vector, containg the values in case we're storing a vector
    284284
    285285            bool                       bAddedDescription_;          //!< True if a description was added
Note: See TracChangeset for help on using the changeset viewer.