Changeset 1717 for code/branches/core3
- Timestamp:
- Sep 6, 2008, 5:45:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/util/MultiType.h
r1716 r1717 42 42 #endif 43 43 44 enum _UtilExportMT_Type44 enum MT_Type 45 45 { 46 46 MT_null, … … 132 132 133 133 public: 134 inline MultiType() : value_(0), type_(MT_null) {} 135 template <typename V> inline MultiType(const V& value) : value_(0), type_(MT_null) { this->assignValue(value); } 136 inline MultiType(const MultiType& other) : value_(0), type_(MT_null) { this->setValue(other); } 137 inline MultiType(MT_Type type) : value_(0), type_(MT_null) { this->setType(type); } 134 inline MultiType() : value_(0), type_(MT_null) {} 135 // template <typename V> inline MultiType(const V& value) : value_(0), type_(MT_null) { this->assignValue(value); } 136 inline MultiType(const char& value) : value_(0), type_(MT_null) { this->assignValue(value); } 137 inline MultiType(const unsigned char& value) : value_(0), type_(MT_null) { this->assignValue(value); } 138 inline MultiType(const short& value) : value_(0), type_(MT_null) { this->assignValue(value); } 139 inline MultiType(const unsigned short& value) : value_(0), type_(MT_null) { this->assignValue(value); } 140 inline MultiType(const int& value) : value_(0), type_(MT_null) { this->assignValue(value); } 141 inline MultiType(const unsigned int& value) : value_(0), type_(MT_null) { this->assignValue(value); } 142 inline MultiType(const long& value) : value_(0), type_(MT_null) { this->assignValue(value); } 143 inline MultiType(const unsigned long& value) : value_(0), type_(MT_null) { this->assignValue(value); } 144 inline MultiType(const long long& value) : value_(0), type_(MT_null) { this->assignValue(value); } 145 inline MultiType(const unsigned long long& value) : value_(0), type_(MT_null) { this->assignValue(value); } 146 inline MultiType(const float& value) : value_(0), type_(MT_null) { this->assignValue(value); } 147 inline MultiType(const double& value) : value_(0), type_(MT_null) { this->assignValue(value); } 148 inline MultiType(const long double& value) : value_(0), type_(MT_null) { this->assignValue(value); } 149 inline MultiType(const bool& value) : value_(0), type_(MT_null) { this->assignValue(value); } 150 inline MultiType(const std::string& value) : value_(0), type_(MT_null) { this->assignValue(value); } 151 inline MultiType(const orxonox::Vector2& value) : value_(0), type_(MT_null) { this->assignValue(value); } 152 inline MultiType(const orxonox::Vector3& value) : value_(0), type_(MT_null) { this->assignValue(value); } 153 inline MultiType(const orxonox::Vector4& value) : value_(0), type_(MT_null) { this->assignValue(value); } 154 inline MultiType(const orxonox::ColourValue& value) : value_(0), type_(MT_null) { this->assignValue(value); } 155 inline MultiType(const orxonox::Quaternion& value) : value_(0), type_(MT_null) { this->assignValue(value); } 156 inline MultiType(const orxonox::Radian& value) : value_(0), type_(MT_null) { this->assignValue(value); } 157 inline MultiType(const orxonox::Degree& value) : value_(0), type_(MT_null) { this->assignValue(value); } 158 inline MultiType(const MultiType& other) : value_(0), type_(MT_null) { this->setValue(other); } 159 inline MultiType(MT_Type type) : value_(0), type_(MT_null) { this->setType(type); } 138 160 ~MultiType() { if (this->value_) { delete this->value_; } } 139 161 140 162 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } 141 template <typename T, typename V> inline MultiType& operator=(const V& value) { this->assignValue((T)value); return (*this); }142 163 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } 143 164 inline MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } 144 165 145 template <typename V> inline void setValue(const V& value) { if (this->value_) { this->value_->setValue(value); } else { this->createNewValueContainer(value); } } 146 template <typename V> inline void setValue(V* value) { if (this->value_) { this->value_->setValue((void*)value); } else { this->createNewValueContainer((void*)value); } } 166 inline void setValue(const char& value); 167 inline void setValue(const unsigned char& value); 168 inline void setValue(const short& value); 169 inline void setValue(const unsigned short& value); 170 inline void setValue(const int& value); 171 inline void setValue(const unsigned int& value); 172 inline void setValue(const long& value); 173 inline void setValue(const unsigned long& value); 174 inline void setValue(const long long& value); 175 inline void setValue(const unsigned long long& value); 176 inline void setValue(const float& value); 177 inline void setValue(const double& value); 178 inline void setValue(const long double& value); 179 inline void setValue(const bool& value); 180 inline void setValue(const std::string& value); 181 inline void setValue(const orxonox::Vector2& value); 182 inline void setValue(const orxonox::Vector3& value); 183 inline void setValue(const orxonox::Vector4& value); 184 inline void setValue(const orxonox::ColourValue& value); 185 inline void setValue(const orxonox::Quaternion& value); 186 inline void setValue(const orxonox::Radian& value); 187 inline void setValue(const orxonox::Degree& value); 188 template <typename V> inline void setValue(V* value) { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } } 147 189 inline void setValue(const char* value); 148 inline void setValue(const MultiType& other) { this->type_ = other.type_; this->value_ = (other.value_) ? other.value_->clone() : 0; }149 template <typename T, typename V> inline void setValue(const V& value) { this->assignValue((T)value); }150 151 template <typename T> inline void convert() { this->setValue<T>( this->operator T()); }190 inline void setValue(const MultiType& other) { this->type_ = other.type_; this->value_ = (other.value_) ? other.value_->clone() : 0; } 191 template <typename T, typename V> inline void setValue(const V& value) { this->assignValue((T)value); } 192 193 template <typename T> inline void convert() { this->setValue<T>((T)(*this)); } 152 194 153 195 inline void reset() { if (this->value_) { delete this->value_; this->value_ = 0; } this->type_ = MT_null; } … … 270 312 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->type_ == MT_degree); } 271 313 314 template <> inline void MultiType::convert<std::string>() { this->setValue<std::string> (this->operator std::string()); } 315 template <> inline void MultiType::convert<orxonox::Vector2>() { this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } 316 template <> inline void MultiType::convert<orxonox::Vector3>() { this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } 317 template <> inline void MultiType::convert<orxonox::Vector4>() { this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } 318 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } 319 template <> inline void MultiType::convert<orxonox::Quaternion>() { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } 320 template <> inline void MultiType::convert<orxonox::Radian>() { this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } 321 template <> inline void MultiType::convert<orxonox::Degree>() { this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } 322 272 323 template <> inline void MultiType::convert<const std::string&>() { this->convert<std::string>(); } 273 324 template <> inline void MultiType::convert<const orxonox::Vector2&>() { this->convert<orxonox::Vector2>(); } … … 303 354 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value); 304 355 305 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->createNewValueContainer(std::string(value)); } } 356 inline void MultiType::setValue(const char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 357 inline void MultiType::setValue(const unsigned char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 358 inline void MultiType::setValue(const short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 359 inline void MultiType::setValue(const unsigned short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 360 inline void MultiType::setValue(const int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 361 inline void MultiType::setValue(const unsigned int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 362 inline void MultiType::setValue(const long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 363 inline void MultiType::setValue(const unsigned long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 364 inline void MultiType::setValue(const long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 365 inline void MultiType::setValue(const unsigned long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 366 inline void MultiType::setValue(const float& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 367 inline void MultiType::setValue(const double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 368 inline void MultiType::setValue(const long double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 369 inline void MultiType::setValue(const bool& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 370 inline void MultiType::setValue(const std::string& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 371 inline void MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 372 inline void MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 373 inline void MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 374 inline void MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 375 inline void MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 376 inline void MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 377 inline void MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 378 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } } 306 379 307 380 /*
Note: See TracChangeset
for help on using the changeset viewer.