From: Philip Rauwolf Date: Tue, 15 Jan 2013 13:06:59 +0000 (+0100) Subject: Resolved more conflicts X-Git-Tag: genivi_release_2~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ac207b211ab3d6c93dcedc9c777820f57e35e6a;p=profile%2Fivi%2Fcommon-api-dbus-runtime.git Resolved more conflicts --- diff --git a/src/test/DBusVariantTest.cpp b/src/test/DBusVariantTest.cpp index c8510d7..24caf10 100644 --- a/src/test/DBusVariantTest.cpp +++ b/src/test/DBusVariantTest.cpp @@ -10,46 +10,42 @@ template struct assign_visitor; -<<<<<<< variant_dev_new template struct complete_equals_visitor; template struct partial_equals_visitor; -======= ->>>>>>> a8c63f3 Tests for Variant serialization template struct apply_void_visitor; template struct apply_void_visitor { - static const unsigned int index = 0; - - static - void visit(Visitor&, Variant&) { - //won't be called - assert(false); - throw ""; - } + static const unsigned int index = 0; + + static + void visit(Visitor&, Variant&) { + //won't be called + assert(false); + throw ""; + } }; template struct apply_void_visitor { - static const unsigned int index = apply_void_visitor::index + 1; - - static - void visit(Visitor& visitor, Variant& var) { - if (var.getValueType() == index) { - bool b; - visitor(var.template get(b)); - } else { - apply_void_visitor::visit(visitor, var); - } - } + static const unsigned int index = apply_void_visitor::index + 1; + + static + void visit(Visitor& visitor, Variant& var) { + if (var.getValueType() == index) { + bool b; + visitor(var.template get(b)); + } else { + apply_void_visitor::visit(visitor, var); + } + } }; -<<<<<<< variant_dev_new template struct apply_return_visitor @@ -57,46 +53,44 @@ struct apply_return_visitor template struct apply_return_visitor { - static const unsigned int index = 0; + static const unsigned int index = 0; - static bool visit(Visitor&, Variant&) { - //won't be called - assert(false); - } + static bool visit(Visitor&, Variant&) { + //won't be called + assert(false); + } }; template struct apply_return_visitor { - static const unsigned int index = apply_return_visitor::index + 1; - - static bool visit(Visitor& visitor, Variant& var) { - if (var.getValueType() == index) { - bool b; - return visitor(var.template get(b)); - } else { - return apply_return_visitor::visit(visitor, - var); - } - } + static const unsigned int index = apply_return_visitor::index + 1; + + static bool visit(Visitor& visitor, Variant& var) { + if (var.getValueType() == index) { + bool b; + return visitor(var.template get(b)); + } else { + return apply_return_visitor::visit(visitor, + var); + } + } }; -======= ->>>>>>> a8c63f3 Tests for Variant serialization template struct clear_visitor { public: - clear_visitor(typename std::aligned_storage::type& storage) : - storage_(storage) { - } + clear_visitor(typename std::aligned_storage::type& storage) : + storage_(storage) { + } - template - void operator()(const _Type&) const { - (reinterpret_cast(&storage_))->~_Type(); - } + template + void operator()(const _Type&) const { + (reinterpret_cast(&storage_))->~_Type(); + } - private: - typename std::aligned_storage::type& storage_; + private: + typename std::aligned_storage::type& storage_; }; template @@ -109,51 +103,51 @@ struct select_type { //U == T template struct select_type { - typedef T type; + typedef T type; }; //U& == T template struct select_type { - typedef T& type; + typedef T& type; }; //U == T& template struct select_type { - typedef T type; + typedef T type; }; //const U& == T template struct select_type { - typedef const T& type; + typedef const T& type; }; //U == const T& template struct select_type { - typedef T type; + typedef T type; }; //U == X* //T == const X* template struct select_type { - typedef const T* type; + typedef const T* type; }; //U == X& //T == const X& template struct select_type { - typedef const T& type; + typedef const T& type; }; //U != T, let's try to find U among Ts template struct select_type { - typedef typename select_type::type type; + typedef typename select_type::type type; }; template @@ -161,31 +155,31 @@ struct type_index_getter; template<> struct type_index_getter<> { - static const unsigned int index = 0; + static const unsigned int index = 0; - template - static - unsigned int get() { - return 0; - } + template + static + unsigned int get() { + return 0; + } }; template struct type_index_getter { - static const unsigned int index = type_index_getter::index + 1; - - template - static - unsigned int get( - typename std::enable_if::value >::type* = 0) { - return index; - } - - template - static - unsigned int get(typename std::enable_if::value >::type* = 0) { - return type_index_getter::template get(); - } + static const unsigned int index = type_index_getter::index + 1; + + template + static + unsigned int get( + typename std::enable_if::value >::type* = 0) { + return index; + } + + template + static + unsigned int get(typename std::enable_if::value >::type* = 0) { + return type_index_getter::template get(); + } }; template @@ -193,16 +187,16 @@ struct max_size; template<> struct max_size<> { - static const unsigned int value = 0; + static const unsigned int value = 0; }; template struct max_size { - static const unsigned int current_type_size = sizeof(T); - static const unsigned int next_type_size = max_size::value; - static const unsigned int value = - current_type_size > next_type_size ? - current_type_size : next_type_size; + static const unsigned int current_type_size = sizeof(T); + static const unsigned int next_type_size = max_size::value; + static const unsigned int value = + current_type_size > next_type_size ? + current_type_size : next_type_size; }; template @@ -247,125 +241,98 @@ class Variant { Variant& operator=(const Variant& rhs) { - assign_visitor<_Types...> visitor(*this); - apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, rhs); - return *this; -<<<<<<< variant_dev_new -======= - } - - /*Variant& operator=(const Variant& fromVariant) { - // TODO + assign_visitor<_Types...> visitor(*this); + apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, rhs); return *this; ->>>>>>> a8c63f3 Tests for Variant serialization } -<<<<<<< variant_dev_new Variant& operator=(Variant&& rhs) { - assign_visitor<_Types...> visitor(*this); - apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, rhs); - return *this; + assign_visitor<_Types...> visitor(*this); + apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, rhs); + return *this; } template typename std::enable_if>::value, Variant<_Types...>&>::type operator=(const _Type& value) { - set::type>(value); - return *this; -======= -*/ - Variant& operator=(Variant&& fromVariant) { - // TODO + set::type>(value); return *this; ->>>>>>> a8c63f3 Tests for Variant serialization } template - const bool isType() const { - typedef typename select_type<_Type, _Types...>::type selected_type_t; - unsigned int cType = type_index_getter<_Types...>::template get(); - if(cType == valueType_) { - return true; - } else { - return false; - } - } + const bool isType() const { + typedef typename select_type<_Type, _Types...>::type selected_type_t; + unsigned int cType = type_index_getter<_Types...>::template get(); + if(cType == valueType_) { + return true; + } else { + return false; + } + } template Variant(const _Type& value, - typename std::enable_if::value>::type* = 0, - typename std::enable_if::value>::type* = 0, - typename std::enable_if::value>::type* = 0) { -<<<<<<< variant_dev_new -======= - /*typedef typename select_type<_Type, _Types...>::type selected_type_t; - valueType_ = type_index_getter<_Types...>::template get(); - new (&valueStorage_) _Type(value);*/ ->>>>>>> a8c63f3 Tests for Variant serialization - set::type>(value, false); + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0) { + set::type>(value, false); } template Variant(_Type && value, - typename std::enable_if::value>::type* = 0, - typename std::enable_if::value>::type* = 0, - typename std::enable_if::value>::type* = 0) { -<<<<<<< variant_dev_new -======= - /*typedef typename select_type<_Type, _Types...>::type selected_type_t; - valueType_ = type_index_getter<_Types...>::template get(); - new (&valueStorage_) typename std::remove_reference<_Type>::type(std::move(value));*/ ->>>>>>> a8c63f3 Tests for Variant serialization - set2::type>(std::move(value), false); + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0, + typename std::enable_if::value>::type* = 0) { + set2::type>(std::move(value), false); } //TODO: Return type??? - template - const typename VariantTypeSelector<_Type, _Types...>::type & get(bool& success) const { - typedef typename select_type<_Type, _Types...>::type selected_type_t; - unsigned int cType = type_index_getter<_Types...>::template get(); - if(cType == valueType_) { - success = true; - return *(reinterpret_cast(&valueStorage_)); - } else { - success = false; - return *(reinterpret_cast(&valueStorage_)); - } - } - - inline size_t getValueType() const { - return valueType_; - } - - template - void set( const U& value, const bool clear) { - typedef typename select_type::type selected_type_t; - - const selected_type_t& type_value = value; - if(clear) { - clear_visitor visitor(valueStorage_); - apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, *this); - } - new (&valueStorage_) selected_type_t(std::move(value)); - valueType_ = type_index_getter<_Types...>::template get(); - } - - template - void set2( U&& value, const bool clear) { - typedef typename select_type::type selected_type_t; - - selected_type_t&& any_container_value = std::move(value); - if(clear) - { - clear_visitor visitor(valueStorage_); - apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, *this); - } else { - new (&valueStorage_) selected_type_t(std::move(any_container_value)); - } - - valueType_ = type_index_getter<_Types...>::template get(); - } + template + const typename VariantTypeSelector<_Type, _Types...>::type & get(bool& success) const { + typedef typename select_type<_Type, _Types...>::type selected_type_t; + unsigned int cType = type_index_getter<_Types...>::template get(); + if(cType == valueType_) { + success = true; + return *(reinterpret_cast(&valueStorage_)); + } else { + success = false; + return *(reinterpret_cast(&valueStorage_)); + } + } + + inline size_t getValueType() const { + return valueType_; + } + + template + void set( const U& value, const bool clear) { + typedef typename select_type::type selected_type_t; + + const selected_type_t& type_value = value; + if(clear) { + clear_visitor visitor(valueStorage_); + apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, *this); + } + new (&valueStorage_) selected_type_t(std::move(value)); + valueType_ = type_index_getter<_Types...>::template get(); + } + + template + void set2( U&& value, const bool clear) { + typedef typename select_type::type selected_type_t; + + selected_type_t&& any_container_value = std::move(value); + if(clear) + { + clear_visitor visitor(valueStorage_); + apply_void_visitor, Variant<_Types...>, _Types...>::visit(visitor, *this); + } else { + new (&valueStorage_) selected_type_t(std::move(any_container_value)); + } + + valueType_ = type_index_getter<_Types...>::template get(); + } private: inline bool hasValue() const { @@ -380,83 +347,83 @@ class Variant { template bool operator==(const Variant<_Types...>& lhs, const Variant<_Types...>& rhs) { - partial_equals_visitor<_Types...> visitor(lhs); - return apply_return_visitor, const Variant<_Types...>, _Types...>::visit(visitor, rhs); + partial_equals_visitor<_Types...> visitor(lhs); + return apply_return_visitor, const Variant<_Types...>, _Types...>::visit(visitor, rhs); } template bool operator!=(const Variant<_Types...>& lhs, const Variant<_Types...>& rhs) { - return !(lhs == rhs); + return !(lhs == rhs); } template struct complete_equals_visitor { - public: - complete_equals_visitor(const T& rhs): - rhs_(rhs) - { - } - - bool - operator()(const T& lhs) const - { - return lhs == rhs_; - } - - template - bool - operator()(const U&) const - { - return false; - } - - private: - const T& rhs_; + public: + complete_equals_visitor(const T& rhs): + rhs_(rhs) + { + } + + bool + operator()(const T& lhs) const + { + return lhs == rhs_; + } + + template + bool + operator()(const U&) const + { + return false; + } + + private: + const T& rhs_; }; template struct partial_equals_visitor { - public: - partial_equals_visitor(const Variant& lhs): - lhs_(lhs) - { - } - - template - bool - operator()(const T& rhs) const - { - complete_equals_visitor visitor(rhs); - return apply_return_visitor, const Variant, Ts...>::visit(visitor, lhs_); - } - - private: - const Variant& lhs_; + public: + partial_equals_visitor(const Variant& lhs): + lhs_(lhs) + { + } + + template + bool + operator()(const T& rhs) const + { + complete_equals_visitor visitor(rhs); + return apply_return_visitor, const Variant, Ts...>::visit(visitor, lhs_); + } + + private: + const Variant& lhs_; }; template struct assign_visitor { public: - assign_visitor(Variant& lhs, const bool clear = true) : - lhs_(lhs), clear_(clear) { - } + assign_visitor(Variant& lhs, const bool clear = true) : + lhs_(lhs), clear_(clear) { + } - template - void operator()(const T& value) const { - lhs_.template set(value, clear_); - } + template + void operator()(const T& value) const { + lhs_.template set(value, clear_); + } - template - void operator()(T& value) const { - lhs_.template set(value, clear_); - } + template + void operator()(T& value) const { + lhs_.template set(value, clear_); + } private: - Variant& lhs_; - const bool clear_; + Variant& lhs_; + const bool clear_; }; @@ -477,7 +444,6 @@ int main(int argc, char** argv) { Variant myVariant2 = myVariant; const int& myInt2 = myVariant2.get(success); std::cout << "myInt2 = " << myInt2 << " (" << std::boolalpha << success << ")\n"; -<<<<<<< variant_dev_new Variant myVariant3 = fromInt; const int& myInt3 = myVariant3.get(success); @@ -488,8 +454,6 @@ int main(int argc, char** argv) { std::cout << "myIntCopy = " << myIntCopy << " (" << std::boolalpha << success << ")\n"; std::cout << "myIntCopy equals myInt= " << "(" << std::boolalpha << (myVariant == myVariantCopy) << ")\n"; -======= ->>>>>>> a8c63f3 Tests for Variant serialization const int& myFake = myVariant.get(success); std::cout << "myFake = " << myFake << " (" << std::boolalpha << success << ")\n"; @@ -508,28 +472,4 @@ int main(int argc, char** argv) { return 0; } -<<<<<<< variant_dev_new - -======= -template -struct assign_visitor { -public: - assign_visitor(Variant& lhs, const bool clear = true): - lhs_(lhs), clear_(clear) { - } - - template - void operator()(const T& value) const { - lhs_.template set(value, clear_); - } - template - void operator()(T& value) const { - lhs_.template set(value, clear_); - } - -private: - Variant& lhs_; - const bool clear_; -}; ->>>>>>> a8c63f3 Tests for Variant serialization