Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2012, 11:35:32 AM (12 years ago)
Author:
landauf
Message:

renamed setType<T>() to reset<T>()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/MultiType.h

    r9222 r9223  
    5858    If you want to change the type, there are three possibilities:
    5959     - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
    60      - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
     60     - @ref orxonox::MultiType::reset "reset<T>()" sets the type to T and resets the value to zero using zeroise<T>()
    6161     - setValue<T>(value) assigns a new value and changes the type to T.
    6262
     
    339339                    return this->assignValue     (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
    340340            }
     341            /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
     342            template <typename T, typename V> inline bool setValue(const V& value) { this->reset<T>(); return this->setValue(value); }
    341343            /// Assigns the value of the other MultiType and converts it to the current type.
    342344            bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
    343             /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
    344             template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
    345 
    346345
    347346            /// Copies the other MultiType by assigning value and type.
     
    353352            /// Resets value and type. Type will be void afterwards and null() returns true.
    354353            inline void                       reset()                      { if (this->value_) delete this->value_; this->value_ = 0; }
    355             /// Current content gets overridden with default zero value
     354            /// Resets the value and changes the internal type to T.
     355            template <typename T> inline void reset()                      { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
     356            /// Current value gets overridden with default zero value
    356357            inline void                       resetValue()                 { if (this->value_) this->value_->reset(); }
    357 
    358             /// Resets the value and changes the internal type to T.
    359             template <typename T> inline void setType()                    { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
    360358
    361359            /// Returns true if the current type is T.
     
    377375
    378376            /// Checks if the MT contains no value.
    379             bool                              null() const { return (!this->value_); }
     377            bool                              null() const { return !this->value_; }
    380378
    381379            operator char()                  const;
     
    497495    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    498496
    499     template <> inline bool MultiType::isType<void>()                 const { return this->null();                                                       } ///< Returns true if the current type equals the given type.
     497    template <> inline bool MultiType::isType<void>()                 const { return this->null();                                                    } ///< Returns true if the current type equals the given type.
    500498    template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == Type::Char);             } ///< Returns true if the current type equals the given type.
    501499    template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == Type::UnsignedChar);     } ///< Returns true if the current type equals the given type.
Note: See TracChangeset for help on using the changeset viewer.