Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 6, 2008, 6:30:40 PM (16 years ago)
Author:
landauf
Message:

bugfix + cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/util/MultiTypeValue.h

    r1718 r1720  
    3737struct MT_Value : public MultiType::MT_ValueBase
    3838{
    39 /*
    40     template <class A, class B, class Btest = B>
    41     class StaticConversion
    42     {
    43         private:
    44             template <class V, bool convertable> struct Convert
    45             {   static inline A convert(const V& value) { return A(); }   };
    46             template <class V>                   struct Convert<V, true>
    47             {   static inline A convert(const V& value) { return ((A)value); }   };
    48 
    49             template <typename V, bool convertable> struct Compare
    50             {
    51                 static inline bool compare_equal       (const A& value, const V& other) { return false; }
    52                 static inline bool compare_notequal    (const A& value, const V& other) { return true;  }
    53                 static inline bool compare_smaller     (const A& value, const V& other) { return false; }
    54                 static inline bool compare_smallerequal(const A& value, const V& other) { return false; }
    55                 static inline bool compare_greater     (const A& value, const V& other) { return false; }
    56                 static inline bool compare_greaterequal(const A& value, const V& other) { return false; }
    57             };
    58             template <typename V>                   struct Compare<V, true>
    59             {
    60                 static inline bool compare_equal       (const A& value, const V& other) { return (value == other); }
    61                 static inline bool compare_notequal    (const A& value, const V& other) { return (value != other); }
    62                 static inline bool compare_smaller     (const A& value, const V& other) { return (value <  other); }
    63                 static inline bool compare_smallerequal(const A& value, const V& other) { return (value <= other); }
    64                 static inline bool compare_greater     (const A& value, const V& other) { return (value >  other); }
    65                 static inline bool compare_greaterequal(const A& value, const V& other) { return (value >= other); }
    66             };
    67 
    68             class Small { char dummy[1]; };
    69             class Big   { char dummy[1024]; };
    70             static Small Test(A);
    71             static Big   Test(...);
    72             static Btest MakeB();
    73             enum { exists = sizeof(Test(MakeB())) == sizeof(Small) };
    74 
    75         public:
    76             static inline A    convert(const B& value)                              { return Convert<B, exists>::convert(value); }
    77             static inline bool compare_equal       (const B& value, const A& other) { return Compare<B, exists>::compare_equal       (value, other); }
    78             static inline bool compare_notequal    (const B& value, const A& other) { return Compare<B, exists>::compare_notequal    (value, other); }
    79             static inline bool compare_smaller     (const B& value, const A& other) { return Compare<B, exists>::compare_smaller     (value, other); }
    80             static inline bool compare_smallerequal(const B& value, const A& other) { return Compare<B, exists>::compare_smallerequal(value, other); }
    81             static inline bool compare_greater     (const B& value, const A& other) { return Compare<B, exists>::compare_greater     (value, other); }
    82             static inline bool compare_greaterequal(const B& value, const A& other) { return Compare<B, exists>::compare_greaterequal(value, other); }
    83     };
    84 */
    8539    MT_Value() {}
    8640    MT_Value(const T& value) : value_(value) {}
    8741
    8842    inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_); }
    89 /*
    90     inline void setValue(const char& value)                 { this->value_ = StaticConversion<T, char>::convert(value);                 }
    91     inline void setValue(const unsigned char& value)        { this->value_ = StaticConversion<T, unsigned char>::convert(value);        }
    92     inline void setValue(const short& value)                { this->value_ = StaticConversion<T, short>::convert(value);                }
    93     inline void setValue(const unsigned short& value)       { this->value_ = StaticConversion<T, unsigned short>::convert(value);       }
    94     inline void setValue(const int& value)                  { this->value_ = StaticConversion<T, int>::convert(value);                  }
    95     inline void setValue(const unsigned int& value)         { this->value_ = StaticConversion<T, unsigned int>::convert(value);         }
    96     inline void setValue(const long& value)                 { this->value_ = StaticConversion<T, long>::convert(value);                 }
    97     inline void setValue(const unsigned long& value)        { this->value_ = StaticConversion<T, unsigned long>::convert(value);        }
    98     inline void setValue(const long long& value)            { this->value_ = StaticConversion<T, long long>::convert(value);            }
    99     inline void setValue(const unsigned long long& value)   { this->value_ = StaticConversion<T, unsigned long long>::convert(value);   }
    100     inline void setValue(const float& value)                { this->value_ = StaticConversion<T, float, int>::convert(value);           }
    101     inline void setValue(const double& value)               { this->value_ = StaticConversion<T, double, int>::convert(value);          }
    102     inline void setValue(const long double& value)          { this->value_ = StaticConversion<T, long double, int>::convert(value);     }
    103     inline void setValue(const bool& value)                 { this->value_ = StaticConversion<T, bool>::convert(value);                 }
    104     inline void setValue(      void* const& value)          { this->value_ = StaticConversion<T, void*>::convert(value);                }
    105     inline void setValue(const std::string& value)          { this->value_ = StaticConversion<T, std::string>::convert(value);          }
    106     inline void setValue(const orxonox::Vector2& value)     { this->value_ = StaticConversion<T, orxonox::Vector2>::convert(value);     }
    107     inline void setValue(const orxonox::Vector3& value)     { this->value_ = StaticConversion<T, orxonox::Vector3>::convert(value);     }
    108     inline void setValue(const orxonox::Vector4& value)     { this->value_ = StaticConversion<T, orxonox::Vector4>::convert(value);     }
    109     inline void setValue(const orxonox::ColourValue& value) { this->value_ = StaticConversion<T, orxonox::ColourValue>::convert(value); }
    110     inline void setValue(const orxonox::Quaternion& value)  { this->value_ = StaticConversion<T, orxonox::Quaternion>::convert(value);  }
    111     inline void setValue(const orxonox::Radian& value)      { this->value_ = StaticConversion<T, orxonox::Radian>::convert(value);      }
    112     inline void setValue(const orxonox::Degree& value)      { this->value_ = StaticConversion<T, orxonox::Degree>::convert(value);      }
    113 */
     43
    11444    inline void setValue(const char& value)                 { this->value_ = getConvertedValue<char,                 T>(value); }
    11545    inline void setValue(const unsigned char& value)        { this->value_ = getConvertedValue<unsigned char,        T>(value); }
Note: See TracChangeset for help on using the changeset viewer.