Changeset 1720
- Timestamp:
- Sep 6, 2008, 6:30:40 PM (16 years ago)
- Location:
- code/branches/core3/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/core/ConfigValueContainer.cc
r1716 r1720 153 153 { 154 154 return this->callFunctionWithIndex(&ConfigValueContainer::tset, input); 155 } 156 else 157 { 158 // MultiType temp = this->value_; 159 // if (temp.assimilate(input)) 160 // { 161 // this->value_ = temp; 162 this->value_ = input; 163 if (this->identifier_) 164 this->identifier_->updateConfigValues(); 165 166 return true; 167 // } 168 } 169 return false; 155 return false; 156 } 157 else 158 { 159 this->value_ = input; 160 161 if (this->identifier_) 162 this->identifier_->updateConfigValues(); 163 164 return true; 165 } 170 166 } 171 167 … … 194 190 } 195 191 196 // MultiType temp = this->value_; 197 // if (temp.assimilate(input)) 198 // { 199 // this->valueVector_[index] = temp; 200 this->valueVector_[index] = input; 201 202 if (this->identifier_) 203 this->identifier_->updateConfigValues(); 204 205 return true; 206 // } 192 this->valueVector_[index] = input; 193 194 if (this->identifier_) 195 this->identifier_->updateConfigValues(); 196 197 return true; 207 198 } 208 199 else 209 200 { 210 201 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl; 211 }212 return false;202 return false; 203 } 213 204 } 214 205 -
code/branches/core3/src/core/Functor.h
r1716 r1720 280 280 281 281 282 /* 283 #define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams 284 #define FUNCTOR_EVALUATE_PARAM0 285 #define FUNCTOR_EVALUATE_PARAM1 \ 286 if (index == 0) { P1 temp = param; param = temp; } 287 #define FUNCTOR_EVALUATE_PARAM2 \ 288 if (index == 0) { P1 temp = param; param = temp; } \ 289 else if (index == 1) { P2 temp = param; param = temp; } 290 #define FUNCTOR_EVALUATE_PARAM3 \ 291 if (index == 0) { P1 temp = param; param = temp; } \ 292 else if (index == 1) { P2 temp = param; param = temp; } \ 293 else if (index == 2) { P3 temp = param; param = temp; } 294 #define FUNCTOR_EVALUATE_PARAM4 \ 295 if (index == 0) { P1 temp = param; param = temp; } \ 296 else if (index == 1) { P2 temp = param; param = temp; } \ 297 else if (index == 2) { P3 temp = param; param = temp; } \ 298 else if (index == 3) { P4 temp = param; param = temp; } 299 #define FUNCTOR_EVALUATE_PARAM5 \ 300 if (index == 0) { P1 temp = param; param = temp; } \ 301 else if (index == 1) { P2 temp = param; param = temp; } \ 302 else if (index == 2) { P3 temp = param; param = temp; } \ 303 else if (index == 3) { P4 temp = param; param = temp; } \ 304 else if (index == 4) { P5 temp = param; param = temp; } 305 */ 282 306 283 #define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams 307 284 #define FUNCTOR_EVALUATE_PARAM0 … … 330 307 331 308 309 332 310 #define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \ 333 311 FUNCTOR_TEMPLATE(0, returnvalue, numparams) \ -
code/branches/core3/src/util/Convert.h
r1716 r1720 43 43 #include "Debug.h" 44 44 #include "SubString.h" 45 //#include "MultiTypeMath.h"46 45 47 46 // disable annoying warning about forcing value to boolean … … 320 319 321 320 322 ////////////////323 // MULTITYPES //324 ////////////////325 /*326 // convert from MultiTypePrimitive327 template <class ToType>328 struct ConverterSpecialized<MultiTypePrimitive, ToType, _FromType_>329 {330 enum { specialized = true };331 static bool convert(ToType* output, const MultiTypePrimitive& input)332 {333 if (input.getType() == MT_void)334 return ConvertValue(output, input.getVoid());335 else if (input.getType() == MT_int)336 return ConvertValue(output, input.getInt());337 else if (input.getType() == MT_uint)338 return ConvertValue(output, input.getUnsignedInt());339 else if (input.getType() == MT_char)340 return ConvertValue(output, input.getChar());341 else if (input.getType() == MT_uchar)342 return ConvertValue(output, input.getUnsignedChar());343 else if (input.getType() == MT_short)344 return ConvertValue(output, input.getShort());345 else if (input.getType() == MT_ushort)346 return ConvertValue(output, input.getUnsignedShort());347 else if (input.getType() == MT_long)348 return ConvertValue(output, input.getLong());349 else if (input.getType() == MT_ulong)350 return ConvertValue(output, input.getUnsignedLong());351 else if (input.getType() == MT_float)352 return ConvertValue(output, input.getFloat());353 else if (input.getType() == MT_double)354 return ConvertValue(output, input.getDouble());355 else if (input.getType() == MT_longdouble)356 return ConvertValue(output, input.getLongDouble());357 else if (input.getType() == MT_bool)358 return ConvertValue(output, input.getBool());359 else360 return false;361 }362 };363 364 // convert from MultiTypeString365 template <class ToType>366 struct ConverterSpecialized<MultiTypeString, ToType, _FromType_>367 {368 enum { specialized = true };369 static bool convert(ToType* output, const MultiTypeString& input)370 {371 if (input.getType() == MT_constchar)372 return ConvertValue(output, input.getConstChar());373 else if (input.getType() == MT_string)374 return ConvertValue(output, input.getString());375 else376 return ConvertValue(output, (MultiTypePrimitive)input);377 }378 };379 380 // convert from MultiTypeMath381 template <class ToType>382 struct ConverterSpecialized<MultiTypeMath, ToType, _FromType_>383 {384 enum { specialized = true };385 static bool convert(ToType* output, const MultiTypeMath& input)386 {387 if (input.getType() == MT_vector2)388 return ConvertValue(output, input.getVector2());389 else if (input.getType() == MT_vector3)390 return ConvertValue(output, input.getVector3());391 else if (input.getType() == MT_vector4)392 return ConvertValue(output, input.getVector4());393 else if (input.getType() == MT_quaternion)394 return ConvertValue(output, input.getQuaternion());395 else if (input.getType() == MT_colourvalue)396 return ConvertValue(output, input.getColourValue());397 else if (input.getType() == MT_radian)398 return ConvertValue(output, input.getRadian());399 else if (input.getType() == MT_degree)400 return ConvertValue(output, input.getDegree());401 else402 return ConvertValue(output, (MultiTypeString)input);403 }404 };405 */406 321 407 322 //////////////////// -
code/branches/core3/src/util/MultiType.cc
r1716 r1720 29 29 #include "MultiType.h" 30 30 #include "MultiTypeValue.h" 31 /*32 int test()33 {34 MultiType test1(10);35 31 36 // test1.setValue(true);37 // test1.setValue(10);38 // test1.setValue<float>(10);39 40 // orxonox::Vector3 test2;41 // test1 = test2;42 43 return 0;44 }45 46 int temp = test();47 */48 32 void MultiType::setType(MT_Type type) 49 33 { -
code/branches/core3/src/util/MultiType.h
r1718 r1720 73 73 { 74 74 _UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt); 75 template <typename T> 76 friend struct MT_Value; 75 template <typename T> friend struct MT_Value; 77 76 78 77 struct _UtilExport MT_ValueBase … … 135 134 public: 136 135 inline MultiType() : value_(0), type_(MT_null) {} 137 // template <typename V> inline MultiType(const V& value) : value_(0), type_(MT_null) { this->assignValue(value); }138 136 inline MultiType(const char& value) : value_(0), type_(MT_null) { this->assignValue(value); } 139 137 inline MultiType(const unsigned char& value) : value_(0), type_(MT_null) { this->assignValue(value); } … … 150 148 inline MultiType(const long double& value) : value_(0), type_(MT_null) { this->assignValue(value); } 151 149 inline MultiType(const bool& value) : value_(0), type_(MT_null) { this->assignValue(value); } 150 inline MultiType( void* const& value) : value_(0), type_(MT_null) { this->assignValue(value); } 152 151 inline MultiType(const std::string& value) : value_(0), type_(MT_null) { this->assignValue(value); } 153 152 inline MultiType(const orxonox::Vector2& value) : value_(0), type_(MT_null) { this->assignValue(value); } … … 180 179 inline void setValue(const long double& value); 181 180 inline void setValue(const bool& value); 181 inline void setValue( void* const& value); 182 182 inline void setValue(const std::string& value); 183 183 inline void setValue(const orxonox::Vector2& value); … … 281 281 inline void assignValue(const orxonox::Radian& value) { if (this->value_ && this->type_ == MT_radian) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); this->type_ = MT_radian; } } 282 282 inline void assignValue(const orxonox::Degree& value) { if (this->value_ && this->type_ == MT_degree) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); this->type_ = MT_degree; } } 283 283 284 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 284 285 template <typename T> void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } … … 380 381 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } } 381 382 382 /*383 384 (*) = funktion 2x:385 function(...) : bezieht sich auf aktuellen type386 function<T>(...) : bezieht sich auf type T387 388 constructor(V value) : zuweisung389 (*) operator=(V value) : zuweisung390 (*) setValue(V value) : zuweisung391 392 (*) == != > < <= >= : template393 394 (*) reset() : zurück auf 0 (bzw "")395 setType<T>() : setzt type und macht reset396 convert<T>() : setzt type und konvertiert397 398 (T) : return konvertiert399 400 isType<T>() : return bool401 getType() : return MT_Type402 getTypename() : return string403 404 toString() : return string405 (*) fromString(string value) : konvertiert string406 operator<< : toString()407 408 */409 383 410 384 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC -
code/branches/core3/src/util/MultiTypeValue.h
r1718 r1720 37 37 struct MT_Value : public MultiType::MT_ValueBase 38 38 { 39 /*40 template <class A, class B, class Btest = B>41 class StaticConversion42 {43 private:44 template <class V, bool convertable> struct Convert45 { 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 Compare50 {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 */85 39 MT_Value() {} 86 40 MT_Value(const T& value) : value_(value) {} 87 41 88 42 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 114 44 inline void setValue(const char& value) { this->value_ = getConvertedValue<char, T>(value); } 115 45 inline void setValue(const unsigned char& value) { this->value_ = getConvertedValue<unsigned char, T>(value); }
Note: See TracChangeset
for help on using the changeset viewer.