diff options
Diffstat (limited to 'src/CommonAPI/SerializableVariant.h')
-rw-r--r-- | src/CommonAPI/SerializableVariant.h | 94 |
1 files changed, 93 insertions, 1 deletions
diff --git a/src/CommonAPI/SerializableVariant.h b/src/CommonAPI/SerializableVariant.h index b7524ed..51f8224 100644 --- a/src/CommonAPI/SerializableVariant.h +++ b/src/CommonAPI/SerializableVariant.h @@ -25,6 +25,11 @@ class TypeOutputStream; template<typename _Type> struct TypeWriter; +/** + * \brief A variant class which can be serialised by bindings. + * + * A variant class which can be serialised by bindings. + */ class SerializableVariant { public: virtual ~SerializableVariant() { @@ -63,6 +68,11 @@ struct VariantTypeSelector<_SearchType, _SearchType, _RestTypes...> { typedef _SearchType type; }; +/** + * \brief A templated generic variant class which provides type safe access and operators + * + * A templated generic variant class which provides type safe access and operators + */ template<typename ... _Types> class Variant: public SerializableVariant { private: @@ -72,10 +82,30 @@ public: static const unsigned int maxSize = MaxSize<_Types...>::value; + /** + * \brief Construct an empty variant + * + * Construct an empty variant + */ Variant(); + + /** + * \brief Copy constructor. Must have identical templates. + * + * Copy constructor. Must have identical templates. + * + * @param fromVariant Variant to copy + */ Variant(const Variant& fromVariant); + /** + * \brief Copy constructor. Must have identical templates. + * + * Copy constructor. Must have identical templates. + * + * @param fromVariant Variant to copy + */ Variant(Variant&& fromVariant); ~Variant(); @@ -86,27 +116,82 @@ public: virtual void writeToTypeOutputStream(TypeOutputStream& typeOutputStream) const; + /** + * \brief Assignment of another variant. Must have identical templates. + * + * Assignment of another variant. Must have identical templates. + * + * @param rhs Variant to assign + */ Variant& operator=(const Variant& rhs); - + /** + * \brief Assignment of another variant. Must have identical templates. + * + * Assignment of another variant. Must have identical templates. + * + * @param rhs Variant to assign + */ Variant& operator=(Variant&& rhs); + /** + * \brief Assignment of a contained type. Must be one of the valid templated types. + * + * Assignment of a contained type. Must be one of the valid templated types. + * + * @param value Value to assign + */ template<typename _Type> typename std::enable_if<!std::is_same<_Type, Variant<_Types...>>::value, Variant<_Types...>&>::type operator=(const _Type& value); + /** + * \brief Equality of another variant. Must have identical template list and content. + * + * Equality of another variant. Must have identical template list and content. + * + * @param rhs Variant to compare + */ bool operator==(const Variant<_Types...>& rhs) const; + /** + * \brief Not-Equality of another variant. Must have identical template list and content. + * + * Not-Equality of another variant. Must have identical template list and content. + * + * @param rhs Variant to compare + */ bool operator!=(const Variant<_Types...>& rhs) const; + /** + * \brief Testif the contained type is the same as the template on this method. + * + * Testif the contained type is the same as the template on this method. + * + * @return Is same type + */ template <typename _Type> const bool isType() const; + /** + * \brief Construct variant with content type set to value. + * + * Construct variant with content type set to value. + * + * @param value Value to place + */ template <typename _Type> Variant(const _Type& value, typename std::enable_if<!std::is_const<_Type>::value>::type* = 0, typename std::enable_if<!std::is_reference<_Type>::value>::type* = 0, typename std::enable_if<!std::is_same<_Type, Variant>::value>::type* = 0); + /** + * \brief Construct variant with content type set to value. + * + * Construct variant with content type set to value. + * + * @param value Value to place + */ template <typename _Type> Variant(_Type && value, typename std::enable_if<!std::is_const<_Type>::value>::type* = 0, @@ -116,6 +201,13 @@ public: template <typename _Type> const _Type& get() const; + /** + * \brief Get index in template list of type actually contained + * + * Get index in template list of type actually contained + * + * @return Index of contained type + */ inline uint8_t getValueType() const { return valueType_; } |