From: Youngsun Suh Date: Tue, 15 Oct 2024 07:54:44 +0000 (+0900) Subject: [Tizen] Re-enable a11y refactor + includeHidden X-Git-Tag: accepted/tizen/7.0/unified/20241017.161241~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F03%2F319103%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Re-enable a11y refactor + includeHidden Revert "Revert "[Tizen] Add UTC for includeHidden flag"" This reverts commit ac7ab87d75d6606636883425dfea7ca793d8c411. Change-Id: I6e56297ae4e3465545d07c1b9c1d83dcd8597423 --- diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp index 98c29513b9..c2c03bf86d 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.cpp @@ -305,6 +305,19 @@ std::string TestGetActionDescription(const Address& adr, size_t index) return std::move(std::get<0>(chs)); } +bool TestGetIncludeHidden(const Address& adr) +{ + auto dbus = static_cast(DBusWrapper::Installed()); + auto result = dbus->fromTestCall(adr.GetPath(), "org.a11y.atspi.Application", "GetIncludeHidden", std::tuple<>()); + return std::move(std::get<0>(result)); +} + +void TestSetIncludeHidden(const Address& adr, bool includeHidden) +{ + auto dbus = static_cast(DBusWrapper::Installed()); + dbus->voidTestCall(adr.GetPath(), "org.a11y.atspi.Application", "SetIncludeHidden", std::tuple(includeHidden)); +} + void TestResetMoveOutedCalled() { gMoveOutedCalled = false; diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.h b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.h index c00ec49b4f..ebbcbeb7d7 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.h +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/accessibility-test-utils.h @@ -43,6 +43,8 @@ bool T bool TestStateChangedCalled(); bool TestStateChangedResult(const std::string_view& expectedState, int expectedValue); void TestResetStateChangedResult(); +bool TestGetIncludeHidden(const Address& adr); +void TestSetIncludeHidden(const Address& adr, bool includeHidden); } // namespace Accessibility } // namespace Dali diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h index d3f4e255c6..0349dcd263 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h @@ -18,13 +18,14 @@ */ // EXTERNAL INCLUDES -#include #include #include #include #include -#include +#include #include +#include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include #include -#include // INTERNAL INCLUDES //#include @@ -43,9 +43,11 @@ #define ATSPI_PREFIX_PATH "/org/a11y/atspi/accessible/" #define ATSPI_NULL_PATH "/org/a11y/atspi/null" - //// BART QUICK HACK -#define bart_assert(x) do{}while(0) +#define bart_assert(x) \ + do \ + { \ + } while(0) struct _Eina_Value; @@ -66,569 +68,864 @@ struct DBusWrapper }; #define DEFINE_TYPE(name, eldbus_name, unref_call) \ - struct name { virtual ~name() = default; }; \ - using name ## Ptr = std::shared_ptr; \ - using name ## WeakPtr = std::weak_ptr; \ + struct name \ + { \ + virtual ~name() = default; \ + }; \ + using name##Ptr = std::shared_ptr; \ + using name##WeakPtr = std::weak_ptr; DEFINE_TYPE(Connection, Eldbus_Connection, ) - DEFINE_TYPE(MessageIter, Eldbus_Message_Iter, eldbus_message_iter_container_close( Value )) - DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref( Value )) - DEFINE_TYPE(Proxy, Eldbus_Proxy, eldbus_proxy_unref( Value )) - DEFINE_TYPE(Object, Eldbus_Object, eldbus_object_unref( Value )) + DEFINE_TYPE(MessageIter, Eldbus_Message_Iter, eldbus_message_iter_container_close(Value)) + DEFINE_TYPE(Message, Eldbus_Message, eldbus_message_unref(Value)) + DEFINE_TYPE(Proxy, Eldbus_Proxy, eldbus_proxy_unref(Value)) + DEFINE_TYPE(Object, Eldbus_Object, eldbus_object_unref(Value)) DEFINE_TYPE(Pending, Eldbus_Pending, ) DEFINE_TYPE(EventPropertyChanged, Eldbus_Proxy_Event_Property_Changed, ) #undef DEFINE_TYPE - virtual ConnectionPtr eldbus_address_connection_get_impl(const std::string &addr) = 0; + virtual ConnectionPtr eldbus_address_connection_get_impl(const std::string& addr) = 0; -#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \ - virtual void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, type_set src) = 0; \ - virtual bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, type_get &dst) = 0; +#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \ + virtual void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, type_set src) = 0; \ + virtual bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, type_get& dst) = 0; #define eldbus_message_iter_arguments_append_impl_basic(type, sig) \ eldbus_message_iter_arguments_append_impl_basic_impl(type, type, sig) eldbus_message_iter_arguments_append_impl_basic(uint8_t, y) - eldbus_message_iter_arguments_append_impl_basic(uint16_t, q) - eldbus_message_iter_arguments_append_impl_basic(uint32_t, u) - eldbus_message_iter_arguments_append_impl_basic(uint64_t, t) - eldbus_message_iter_arguments_append_impl_basic(int16_t, n) - eldbus_message_iter_arguments_append_impl_basic(int32_t, i) - eldbus_message_iter_arguments_append_impl_basic(int64_t, x) - eldbus_message_iter_arguments_append_impl_basic(double, d) - eldbus_message_iter_arguments_append_impl_basic(bool, b) - eldbus_message_iter_arguments_append_impl_basic_impl(const std::string &, std::string, s) - eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath &, ObjectPath, o) + eldbus_message_iter_arguments_append_impl_basic(uint16_t, q) + eldbus_message_iter_arguments_append_impl_basic(uint32_t, u) + eldbus_message_iter_arguments_append_impl_basic(uint64_t, t) + eldbus_message_iter_arguments_append_impl_basic(int16_t, n) + eldbus_message_iter_arguments_append_impl_basic(int32_t, i) + eldbus_message_iter_arguments_append_impl_basic(int64_t, x) + eldbus_message_iter_arguments_append_impl_basic(double, d) + eldbus_message_iter_arguments_append_impl_basic(bool, b) + eldbus_message_iter_arguments_append_impl_basic_impl(const std::string&, std::string, s) + eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath&, ObjectPath, o) #undef eldbus_message_iter_arguments_append_impl_basic #undef eldbus_message_iter_arguments_append_impl_basic_impl - virtual MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr &it, int type, const std::string &sig) = 0; - virtual MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr &it, int type) = 0; - virtual MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr &it, bool write) = 0; - virtual MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr &proxy, const std::string &funcName) = 0; - virtual MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr &proxy, const MessagePtr &msg) = 0; - virtual bool eldbus_message_error_get_impl(const MessagePtr &msg, std::string &name, std::string &text) = 0; - virtual std::string eldbus_message_signature_get_impl(const MessagePtr &msg) = 0; - - using SendCallback = std::function; - virtual PendingPtr eldbus_proxy_send_impl(const ProxyPtr &proxy, const MessagePtr &msg, const SendCallback &callback) = 0; - virtual std::string eldbus_proxy_interface_get_impl(const ProxyPtr &) = 0; - virtual void eldbus_proxy_signal_handler_add_impl(const ProxyPtr &proxy, const std::string &member, const std::function &cb) = 0; - virtual std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr &iter) = 0; - virtual MessagePtr eldbus_message_method_return_new_impl( const MessagePtr &msg) = 0; - virtual MessagePtr eldbus_message_error_new_impl( const MessagePtr &msg, const std::string &err, const std::string &txt ) = 0; - virtual PendingPtr eldbus_connection_send_impl(const ConnectionPtr &conn, const MessagePtr &msg) = 0; - virtual MessagePtr eldbus_message_signal_new_impl(const std::string &path, const std::string &iface, const std::string &name) = 0; - virtual MessagePtr eldbus_message_ref_impl(const MessagePtr &msg) = 0; - virtual ConnectionPtr eldbus_connection_get_impl(ConnectionType type) = 0; - virtual std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr &conn) = 0; - virtual ObjectPtr eldbus_object_get_impl( const ConnectionPtr &conn, const std::string &bus, const std::string &path ) = 0; - virtual ProxyPtr eldbus_proxy_get_impl( const ObjectPtr &obj, const std::string &interface ) = 0; - virtual ProxyPtr eldbus_proxy_copy_impl( const ProxyPtr &ptr) = 0; - virtual void eldbus_name_request_impl(const ConnectionPtr&, const std::string&) {} // no-op - virtual void eldbus_name_release_impl(const ConnectionPtr&, const std::string&) {} // no-op + virtual MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr& it, int type, const std::string& sig) = 0; + virtual MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr& it, int type) = 0; + virtual MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr& it, bool write) = 0; + virtual MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr& proxy, const std::string& funcName) = 0; + virtual MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr& proxy, const MessagePtr& msg) = 0; + virtual bool eldbus_message_error_get_impl(const MessagePtr& msg, std::string& name, std::string& text) = 0; + virtual std::string eldbus_message_signature_get_impl(const MessagePtr& msg) = 0; + + using SendCallback = std::function; + virtual PendingPtr eldbus_proxy_send_impl(const ProxyPtr& proxy, const MessagePtr& msg, const SendCallback& callback) = 0; + virtual std::string eldbus_proxy_interface_get_impl(const ProxyPtr&) = 0; + virtual void eldbus_proxy_signal_handler_add_impl(const ProxyPtr& proxy, const std::string& member, const std::function& cb) = 0; + virtual std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr& iter) = 0; + virtual MessagePtr eldbus_message_method_return_new_impl(const MessagePtr& msg) = 0; + virtual MessagePtr eldbus_message_error_new_impl(const MessagePtr& msg, const std::string& err, const std::string& txt) = 0; + virtual PendingPtr eldbus_connection_send_impl(const ConnectionPtr& conn, const MessagePtr& msg) = 0; + virtual MessagePtr eldbus_message_signal_new_impl(const std::string& path, const std::string& iface, const std::string& name) = 0; + virtual MessagePtr eldbus_message_ref_impl(const MessagePtr& msg) = 0; + virtual ConnectionPtr eldbus_connection_get_impl(ConnectionType type) = 0; + virtual std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr& conn) = 0; + virtual ObjectPtr eldbus_object_get_impl(const ConnectionPtr& conn, const std::string& bus, const std::string& path) = 0; + virtual ProxyPtr eldbus_proxy_get_impl(const ObjectPtr& obj, const std::string& interface) = 0; + virtual ProxyPtr eldbus_proxy_copy_impl(const ProxyPtr& ptr) = 0; + virtual void eldbus_name_request_impl(const ConnectionPtr&, const std::string&) + { + } // no-op + virtual void eldbus_name_release_impl(const ConnectionPtr&, const std::string&) + { + } // no-op class StringStorage { public: struct char_ptr_deleter { - void operator()( char* p ) + void operator()(char* p) { - free( p ); + free(p); } }; - std::vector< std::unique_ptr< char, char_ptr_deleter > > storage; + std::vector> storage; - const char* add( const char* txt ) + const char* add(const char* txt) { - auto ptr = strdup( txt ); - storage.push_back( std::unique_ptr< char, char_ptr_deleter >( ptr ) ); + auto ptr = strdup(txt); + storage.push_back(std::unique_ptr(ptr)); return storage.back().get(); } - const char* add( const std::string& txt ) + const char* add(const std::string& txt) { - return add( txt.c_str() ); + return add(txt.c_str()); } }; struct CallId { - static std::atomic< unsigned int > LastId; - unsigned int id = ++LastId; + static std::atomic LastId; + unsigned int id = ++LastId; }; struct MethodInfo { - CallId id; - std::string memberName; - std::vector< std::pair > in, out; // _Eldbus_Arg_Info - std::function< DBusWrapper::MessagePtr( const DBusWrapper::MessagePtr &msg ) > callback; + CallId id; + std::string memberName; + std::vector> in, out; // _Eldbus_Arg_Info + std::function callback; }; struct SignalInfo { - CallId id; - std::string memberName; - std::vector< std::pair > args; - unsigned int uniqueId; + CallId id; + std::string memberName; + std::vector> args; + unsigned int uniqueId; }; struct PropertyInfo { - CallId setterId, getterId; - std::string memberName, typeSignature; - std::function< std::string( const DBusWrapper::MessagePtr &src, const DBusWrapper::MessageIterPtr &dst ) > getCallback, setCallback; + CallId setterId, getterId; + std::string memberName, typeSignature; + std::function getCallback, setCallback; }; struct SignalId { CallId id; SignalId() = default; - SignalId( CallId id ) : id( id ) {} + SignalId(CallId id) + : id(id) + { + } }; - virtual void add_interface_impl( bool fallback, const std::string& pathName, - const ConnectionPtr &connection, - std::vector> &destructors, - const std::string& interfaceName, - std::vector< MethodInfo >& dscrMethods, - std::vector< PropertyInfo >& dscrProperties, - std::vector< SignalInfo >& dscrSignals ) = 0; - virtual void add_property_changed_event_listener_impl( const ProxyPtr &proxy, const std::string &interface, const std::string &name, std::function< void( const _Eina_Value * ) > cb) = 0; - static DBusWrapper *Installed(); - static void Install(std::unique_ptr); + virtual void add_interface_impl(bool fallback, const std::string& pathName, const ConnectionPtr& connection, std::vector>& destructors, const std::string& interfaceName, std::vector& dscrMethods, std::vector& dscrProperties, std::vector& dscrSignals) = 0; + virtual void add_property_changed_event_listener_impl(const ProxyPtr& proxy, const std::string& interface, const std::string& name, std::function cb) = 0; + static DBusWrapper* Installed(); + static void Install(std::unique_ptr); StringStorage Strings; }; -namespace detail { - enum class MethodType { - Method, Getter, Setter - }; +namespace detail +{ +enum class MethodType +{ + Method, + Getter, + Setter +}; } -namespace std { - template <> struct hash> { - size_t operator () (const std::tuple &a) const { - auto a1 = std::hash()(std::get<0>(a)); - auto a2 = std::hash()(std::get<1>(a)); - auto a3 = std::hash()(std::get<2>(a)); - size_t v = a1; - v = (v * 11400714819323198485llu) + a2; - v = (v * 11400714819323198485llu) + a3; - return v; - } +namespace std +{ +template<> +struct hash> +{ + size_t operator()(const std::tuple& a) const + { + auto a1 = std::hash()(std::get<0>(a)); + auto a2 = std::hash()(std::get<1>(a)); + auto a3 = std::hash()(std::get<2>(a)); + size_t v = a1; + v = (v * 11400714819323198485llu) + a2; + v = (v * 11400714819323198485llu) + a3; + return v; + } +}; +template<> +struct hash> +{ + size_t operator()(const std::tuple& a) const + { + auto a1 = std::hash()(std::get<0>(a)); + auto a2 = std::hash()(std::get<1>(a)); + auto a3 = std::hash()(std::get<2>(a)); + auto a4 = static_cast(std::get<3>(a)); + size_t v = a1; + v = (v * 11400714819323198485llu) + a2; + v = (v * 11400714819323198485llu) + a3; + v = (v * 11400714819323198485llu) + a4; + return v; + } +}; +template<> +struct hash> +{ + size_t operator()(const std::tuple& a) const + { + auto a1 = std::hash()(std::get<0>(a)); + auto a2 = std::hash()(std::get<1>(a)); + auto a3 = std::get<2>(a); + size_t v = a1; + v = (v * 11400714819323198485llu) + a2; + v = (v * 11400714819323198485llu) + a3; + return v; + } +}; +} // namespace std +namespace detail +{ +template +struct DBusSigImpl +{ + enum + { + value = 0, + end = 0 }; - template <> struct hash> { - size_t operator () (const std::tuple &a) const { - auto a1 = std::hash()(std::get<0>(a)); - auto a2 = std::hash()(std::get<1>(a)); - auto a3 = std::hash()(std::get<2>(a)); - auto a4 = static_cast(std::get<3>(a)); - size_t v = a1; - v = (v * 11400714819323198485llu) + a2; - v = (v * 11400714819323198485llu) + a3; - v = (v * 11400714819323198485llu) + a4; - return v; - } +}; +template +struct DBusSig +{ + enum + { + value = DBusSigImpl::type>::value, + end = DBusSigImpl::type>::end }; - template <> struct hash> { - size_t operator () (const std::tuple &a) const { - auto a1 = std::hash()(std::get<0>(a)); - auto a2 = std::hash()(std::get<1>(a)); - auto a3 = std::get<2>(a); - size_t v = a1; - v = (v * 11400714819323198485llu) + a2; - v = (v * 11400714819323198485llu) + a3; - return v; - } +}; +template +struct IndexFromTypeTupleImpl +{ + enum + { + value = std::is_same::type>::type, Q>::value ? I : IndexFromTypeTupleImpl::value }; -} -namespace detail { - template struct DBusSigImpl { enum { value = 0, end = 0 }; }; - template struct DBusSig { enum { value = DBusSigImpl::type>::value, end = DBusSigImpl::type>::end }; }; - template struct IndexFromTypeTupleImpl { - enum { value = std::is_same::type>::type, Q>::value ? I : IndexFromTypeTupleImpl::value }; +}; +template +struct IndexFromTypeTupleImpl +{ + enum + { + value = S }; - template struct IndexFromTypeTupleImpl { enum { value = S }; }; - template struct IndexFromTypeTuple { - enum { value = IndexFromTypeTupleImpl::type, 0, std::tuple_size::value>::value }; +}; +template +struct IndexFromTypeTuple +{ + enum + { + value = IndexFromTypeTupleImpl::type, 0, std::tuple_size::value>::value }; - template struct Encoder; - template struct EncoderTuple; -} +}; +template +struct Encoder; +template +struct EncoderTuple; +} // namespace detail struct TestDBusWrapper : public DBusWrapper { using MethodType = detail::MethodType; - ConnectionPtr connection; + ConnectionPtr connection; std::unordered_map, std::function> testMethods; std::unordered_map, std::function> daliMethods; - std::unordered_map, std::string> daliSignalsMap; - std::unordered_map, std::function> daliSignals; - std::unordered_map, std::function> propertyChangeListeners; + std::unordered_map, std::string> daliSignalsMap; + std::unordered_map, std::function> daliSignals; + std::unordered_map, std::function> propertyChangeListeners; std::vector> asyncCalls; - template struct Variant { + template + struct Variant + { T value; Variant() = default; - Variant(T t) : value(std::move(t)) { } + Variant(T t) + : value(std::move(t)) + { + } }; - template void Encode(const MessagePtr &m, const std::tuple &args) { + template + void Encode(const MessagePtr& m, const std::tuple& args) + { auto iter = eldbus_message_iter_get_impl(m, true); detail::EncoderTuple<0, sizeof...(ARGS), ARGS...>::encode(*this, iter, args); } - template void Decode(const MessagePtr &m, std::tuple &args) { + template + void Decode(const MessagePtr& m, std::tuple& args) + { auto iter = eldbus_message_iter_get_impl(m, false); detail::EncoderTuple<0, sizeof...(ARGS), ARGS...>::decode(*this, args, iter); } - MessagePtr newMessage(const std::string &path, const std::string &interface, const std::string &name, bool reply); - MessagePtr newReplyMessage(const MessagePtr &m); + MessagePtr newMessage(const std::string& path, const std::string& interface, const std::string& name, bool reply); + MessagePtr newReplyMessage(const MessagePtr& m); - template void fromTestEmitSignal(std::string path, const std::string &interface, const std::string &name, const std::tuple &args) { - if (path.empty()) throw error{}; - if (path[0] != '/') path = "/org/a11y/atspi/accessible/" + path; + template + void fromTestEmitSignal(std::string path, const std::string& interface, const std::string& name, const std::tuple& args) + { + if(path.empty()) throw error{}; + if(path[0] != '/') path = "/org/a11y/atspi/accessible/" + path; auto msg = newMessage(path, interface, name, false); Encode(msg, args); - auto it = daliSignals.find(std::tuple{ path, interface, name }); - if (it == daliSignals.end()) throw error{}; + auto it = daliSignals.find(std::tuple{path, interface, name}); + if(it == daliSignals.end()) throw error{}; it->second(msg); } static std::shared_ptr<_Eina_Value> createEinaValue(bool); - template void fromTestChangeProperty(std::string path, const std::string &interface, const std::string &name, T new_value) { + template + void fromTestChangeProperty(std::string path, const std::string& interface, const std::string& name, T new_value) + { auto v = createEinaValue(new_value); - if (path.empty()) throw error{}; - if (path[0] != '/') path = "/org/a11y/atspi/accessible/" + path; - auto it = propertyChangeListeners.find(std::tuple{ path, interface, name }); - if (it == propertyChangeListeners.end()) throw error{}; + if(path.empty()) throw error{}; + if(path[0] != '/') path = "/org/a11y/atspi/accessible/" + path; + auto it = propertyChangeListeners.find(std::tuple{path, interface, name}); + if(it == propertyChangeListeners.end()) throw error{}; it->second(v.get()); } - template std::tuple fromTestCall(const std::string &path, const std::string &interface, const std::string &name, const std::tuple &args) { + template + std::tuple fromTestCall(const std::string& path, const std::string& interface, const std::string& name, const std::tuple& args) + { auto msg = newMessage(path, interface, name, false); Encode(msg, args); - auto res = call(daliMethods, "daliMethods", msg, MethodType::Method); + auto res = call(daliMethods, "daliMethods", msg, MethodType::Method); std::string a, b; - if (eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; + if(eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; std::tuple tmp; Decode(res, tmp); return tmp; } - template T fromTestGet(const std::string &path, const std::string &interface, const std::string &name) { - auto msg = newMessage(path, interface, name, false); - auto res = call(daliMethods, "daliMethods", msg, MethodType::Getter); + template + T fromTestGet(const std::string& path, const std::string& interface, const std::string& name) + { + auto msg = newMessage(path, interface, name, false); + auto res = call(daliMethods, "daliMethods", msg, MethodType::Getter); std::string a, b; - if (eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; + if(eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; std::tuple tmp; Decode(res, tmp); return std::move(std::get<0>(tmp)); } - template std::tuple fromTestSet(const std::string &path, const std::string &interface, const std::string &name, const T &arg) { + template + std::tuple fromTestSet(const std::string& path, const std::string& interface, const std::string& name, const T& arg) + { auto msg = newMessage(path, interface, name, false); - Encode(msg, TestDBusWrapper::Variant{ arg }); - auto res = call(daliMethods, "daliMethods", msg, MethodType::Setter); + Encode(msg, TestDBusWrapper::Variant{arg}); + auto res = call(daliMethods, "daliMethods", msg, MethodType::Setter); std::string a, b; - if (eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; + if(eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; std::tuple tmp; Decode(res, tmp); return tmp; } + template + void voidTestCall(const std::string& path, const std::string& interface, const std::string& name, const std::tuple& args) + { + auto msg = newMessage(path, interface, name, false); + Encode(msg, args); + auto res = call(daliMethods, "daliMethods", msg, MethodType::Method); + std::string a, b; + if(eldbus_message_error_get_impl(res, a, b)) throw error{} << "call to " << path << " " << interface << " " << name << " failed: " << a << ": " << b; + } TestDBusWrapper(); ~TestDBusWrapper(); - class error : public std::exception { + class error : public std::exception + { std::shared_ptr temp = std::make_shared(); - mutable std::string text; + mutable std::string text; + public: error() = default; - template error &operator << (T &&t) { + template + error& operator<<(T&& t) + { *temp << std::forward(t); return *this; } - const char *what() const noexcept override { + const char* what() const noexcept override + { text = temp->str(); return text.c_str(); } }; - #define DEFINE_TYPE(name) struct name ## Impl; static name ## Impl *get(const name ## Ptr &); +#define DEFINE_TYPE(name) \ + struct name##Impl; \ + static name##Impl* get(const name##Ptr&); DEFINE_TYPE(Connection) DEFINE_TYPE(Proxy) DEFINE_TYPE(Object) DEFINE_TYPE(Message) DEFINE_TYPE(MessageIter) - #undef DEFINE_TYPE +#undef DEFINE_TYPE class Element; - using ElementList = std::list; - using ElementMap = std::map; + using ElementList = std::list; + using ElementMap = std::map; using ElementTuple = std::tuple< - uint8_t, uint16_t, uint32_t, uint64_t, int16_t, int32_t, int64_t, double, bool, std::string, ObjectPath, - ElementList - >; - - class Element { + uint8_t, + uint16_t, + uint32_t, + uint64_t, + int16_t, + int32_t, + int64_t, + double, + bool, + std::string, + ObjectPath, + ElementList>; + + class Element + { ElementTuple data; - char signature_ = 0, end_ = 0, index_ = 0; - template void set(T &&t, char signature = detail::DBusSig::value) { + char signature_ = 0, end_ = 0, index_ = 0; + template + void set(T&& t, char signature = detail::DBusSig::value) + { signature_ = signature; - end_ = detail::DBusSig::end; - index_ = static_cast(detail::IndexFromTypeTuple::value); - get() = std::forward(t); + end_ = detail::DBusSig::end; + index_ = static_cast(detail::IndexFromTypeTuple::value); + get() = std::forward(t); } + public: - template Element(T &&t, typename std::enable_if::value != 0>::type* = nullptr) { set(std::forward(t)); } - Element(ElementList t, int signature) { set(std::move(t), static_cast(signature)); } - - char signature() const { return signature_; } - char end() const { return end_; } - char index() const { return index_; } - bool isContainer() const { return index_ == detail::IndexFromTypeTuple::value; } - template ::value != 0>::type> - bool is() const { return index_ == detail::IndexFromTypeTuple::value; } - template ::value != 0>::type> - const T &get() const { if (!is()) throw error{}; return std::get::value>(data); } - template ::value != 0>::type> - T &get() { if (!is()) throw error{}; return std::get::value>(data); } + template + Element(T&& t, typename std::enable_if::value != 0>::type* = nullptr) + { + set(std::forward(t)); + } + Element(ElementList t, int signature) + { + set(std::move(t), static_cast(signature)); + } + + char signature() const + { + return signature_; + } + char end() const + { + return end_; + } + char index() const + { + return index_; + } + bool isContainer() const + { + return index_ == detail::IndexFromTypeTuple::value; + } + template::value != 0>::type> + bool is() const + { + return index_ == detail::IndexFromTypeTuple::value; + } + template::value != 0>::type> + const T& get() const + { + if(!is()) throw error{}; + return std::get::value>(data); + } + template::value != 0>::type> + T& get() + { + if(!is()) throw error{}; + return std::get::value>(data); + } }; - ConnectionPtr eldbus_address_connection_get_impl(const std::string &addr) override; + ConnectionPtr eldbus_address_connection_get_impl(const std::string& addr) override; -#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \ - void eldbus_message_iter_arguments_append_impl(const MessageIterPtr &it, type_set src) override; \ - bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr &it, type_get &dst) override; +#define eldbus_message_iter_arguments_append_impl_basic_impl(type_set, type_get, sig) \ + void eldbus_message_iter_arguments_append_impl(const MessageIterPtr& it, type_set src) override; \ + bool eldbus_message_iter_get_and_next_impl(const MessageIterPtr& it, type_get& dst) override; #define eldbus_message_iter_arguments_append_impl_basic(type, sig) \ eldbus_message_iter_arguments_append_impl_basic_impl(type, type, sig) eldbus_message_iter_arguments_append_impl_basic(uint8_t, y) - eldbus_message_iter_arguments_append_impl_basic(uint16_t, q) - eldbus_message_iter_arguments_append_impl_basic(uint32_t, u) - eldbus_message_iter_arguments_append_impl_basic(uint64_t, t) - eldbus_message_iter_arguments_append_impl_basic(int16_t, n) - eldbus_message_iter_arguments_append_impl_basic(int32_t, i) - eldbus_message_iter_arguments_append_impl_basic(int64_t, x) - eldbus_message_iter_arguments_append_impl_basic(double, d) - eldbus_message_iter_arguments_append_impl_basic(bool, b) - eldbus_message_iter_arguments_append_impl_basic_impl(const std::string &, std::string, s) - eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath &, ObjectPath, o) + eldbus_message_iter_arguments_append_impl_basic(uint16_t, q) + eldbus_message_iter_arguments_append_impl_basic(uint32_t, u) + eldbus_message_iter_arguments_append_impl_basic(uint64_t, t) + eldbus_message_iter_arguments_append_impl_basic(int16_t, n) + eldbus_message_iter_arguments_append_impl_basic(int32_t, i) + eldbus_message_iter_arguments_append_impl_basic(int64_t, x) + eldbus_message_iter_arguments_append_impl_basic(double, d) + eldbus_message_iter_arguments_append_impl_basic(bool, b) + eldbus_message_iter_arguments_append_impl_basic_impl(const std::string&, std::string, s) + eldbus_message_iter_arguments_append_impl_basic_impl(const ObjectPath&, ObjectPath, o) #undef eldbus_message_iter_arguments_append_impl_basic #undef eldbus_message_iter_arguments_append_impl_basic_impl - MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr &it, int type, const std::string &sig) override; - MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr &it, int type) override; - MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr &it, bool write) override; - MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr &proxy, const std::string &funcName) override; - MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr &proxy, const MessagePtr &msg) override; - bool eldbus_message_error_get_impl(const MessagePtr &msg, std::string &name, std::string &text) override; - std::string eldbus_message_signature_get_impl(const MessagePtr &msg) override; - PendingPtr eldbus_proxy_send_impl(const ProxyPtr &proxy, const MessagePtr &msg, const SendCallback &callback) override; - std::string eldbus_proxy_interface_get_impl(const ProxyPtr &) override; - void eldbus_proxy_signal_handler_add_impl(const ProxyPtr &proxy, const std::string &member, const std::function &cb) override; - std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr &iter) override; - MessagePtr eldbus_message_method_return_new_impl( const MessagePtr &msg) override; - MessagePtr eldbus_message_error_new_impl( const MessagePtr &msg, const std::string &err, const std::string &txt ) override; - PendingPtr eldbus_connection_send_impl(const ConnectionPtr &conn, const MessagePtr &msg) override; - MessagePtr eldbus_message_signal_new_impl(const std::string &path, const std::string &iface, const std::string &name) override; - MessagePtr eldbus_message_ref_impl(const MessagePtr &msg) override; - ConnectionPtr eldbus_connection_get_impl(ConnectionType type) override; - std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr &conn) override; - ObjectPtr eldbus_object_get_impl( const ConnectionPtr &conn, const std::string &bus, const std::string &path ) override; - ProxyPtr eldbus_proxy_get_impl( const ObjectPtr &obj, const std::string &interface ) override; - ProxyPtr eldbus_proxy_copy_impl( const ProxyPtr &ptr) override; - void add_property_changed_event_listener_impl( const ProxyPtr &proxy, const std::string &interface, const std::string &name, std::function< void( const _Eina_Value * ) > cb) override; - void add_interface_impl( bool fallback, const std::string& pathName, - const ConnectionPtr &connection, - std::vector> &destructors, - const std::string& interfaceName, - std::vector< MethodInfo >& dscrMethods, - std::vector< PropertyInfo >& dscrProperties, - std::vector< SignalInfo >& dscrSignals ) override; - static bool completed(const MessageIterPtr &iter); + MessageIterPtr eldbus_message_iter_container_new_impl(const MessageIterPtr& it, int type, const std::string& sig) override; + MessageIterPtr eldbus_message_iter_get_and_next_by_type_impl(const MessageIterPtr& it, int type) override; + MessageIterPtr eldbus_message_iter_get_impl(const MessagePtr& it, bool write) override; + MessagePtr eldbus_proxy_method_call_new_impl(const ProxyPtr& proxy, const std::string& funcName) override; + MessagePtr eldbus_proxy_send_and_block_impl(const ProxyPtr& proxy, const MessagePtr& msg) override; + bool eldbus_message_error_get_impl(const MessagePtr& msg, std::string& name, std::string& text) override; + std::string eldbus_message_signature_get_impl(const MessagePtr& msg) override; + PendingPtr eldbus_proxy_send_impl(const ProxyPtr& proxy, const MessagePtr& msg, const SendCallback& callback) override; + std::string eldbus_proxy_interface_get_impl(const ProxyPtr&) override; + void eldbus_proxy_signal_handler_add_impl(const ProxyPtr& proxy, const std::string& member, const std::function& cb) override; + std::string eldbus_message_iter_signature_get_impl(const MessageIterPtr& iter) override; + MessagePtr eldbus_message_method_return_new_impl(const MessagePtr& msg) override; + MessagePtr eldbus_message_error_new_impl(const MessagePtr& msg, const std::string& err, const std::string& txt) override; + PendingPtr eldbus_connection_send_impl(const ConnectionPtr& conn, const MessagePtr& msg) override; + MessagePtr eldbus_message_signal_new_impl(const std::string& path, const std::string& iface, const std::string& name) override; + MessagePtr eldbus_message_ref_impl(const MessagePtr& msg) override; + ConnectionPtr eldbus_connection_get_impl(ConnectionType type) override; + std::string eldbus_connection_unique_name_get_impl(const ConnectionPtr& conn) override; + ObjectPtr eldbus_object_get_impl(const ConnectionPtr& conn, const std::string& bus, const std::string& path) override; + ProxyPtr eldbus_proxy_get_impl(const ObjectPtr& obj, const std::string& interface) override; + ProxyPtr eldbus_proxy_copy_impl(const ProxyPtr& ptr) override; + void add_property_changed_event_listener_impl(const ProxyPtr& proxy, const std::string& interface, const std::string& name, std::function cb) override; + void add_interface_impl(bool fallback, const std::string& pathName, const ConnectionPtr& connection, std::vector>& destructors, const std::string& interfaceName, std::vector& dscrMethods, std::vector& dscrProperties, std::vector& dscrSignals) override; + static bool completed(const MessageIterPtr& iter); + private: - MessagePtr call(std::unordered_map, std::function> &mp, const std::string &name, const MessagePtr &msg, MethodType type); -}; - -namespace detail { - template <> struct DBusSigImpl { enum { value = 'y', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'q', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'u', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 't', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'n', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'i', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'x', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'd', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'b', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 's', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = 'o', end = 0 }; }; - template <> struct DBusSigImpl { enum { value = '(', end = ')' }; }; - template <> struct DBusSigImpl { enum { value = '{', end = '}' }; }; - - template struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const T &src) { - w.eldbus_message_iter_arguments_append_impl(tgt, src); - } - static void decode(TestDBusWrapper &w, T &tgt, const TestDBusWrapper::MessageIterPtr &src) { - if (!w.eldbus_message_iter_get_and_next_impl(src, tgt)) throw TestDBusWrapper::error{}; - } + MessagePtr call(std::unordered_map, std::function>& mp, const std::string& name, const MessagePtr& msg, MethodType type); +}; + +namespace detail +{ +template<> +struct DBusSigImpl +{ + enum + { + value = 'y', + end = 0 }; - template struct Encoder::value>::type> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const T &src) { - Encoder::type>::encode(w, tgt, static_cast::type>(src)); - } - static void decode(TestDBusWrapper &w, T &tgt, const TestDBusWrapper::MessageIterPtr &src) { - typename std::underlying_type::type v = 0; - Encoder::type>::decode(w, v, src); - tgt = static_cast(v); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'q', + end = 0 }; - template struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const T &src) { - Encoder::encode(w, tgt, src); - } - static void decode(TestDBusWrapper &w, T &tgt, const TestDBusWrapper::MessageIterPtr &src) { - Encoder::decode(w, tgt, src); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'u', + end = 0 }; - template struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const T &src) { - Encoder::encode(w, tgt, src); - } - static void decode(TestDBusWrapper &w, T &tgt, const TestDBusWrapper::MessageIterPtr &src) { - Encoder::decode(w, tgt, src); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 't', + end = 0 }; - template struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const T &src) { - Encoder::encode(w, tgt, src); - } - static void decode(TestDBusWrapper &w, T &tgt, const TestDBusWrapper::MessageIterPtr &src) { - Encoder::decode(w, tgt, src); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'n', + end = 0 }; - template struct EncoderTuple { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::tuple &src) { - Encoder>::type>::encode(w, tgt, std::get(src)); - EncoderTuple::encode(w, tgt, src); - } - static void decode(TestDBusWrapper &w, std::tuple &tgt, const TestDBusWrapper::MessageIterPtr &src) { - Encoder>::type>::decode(w, std::get(tgt), src); - EncoderTuple::decode(w, tgt, src); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'i', + end = 0 }; - template struct EncoderTuple { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::tuple &src) { } - static void decode(TestDBusWrapper &w, std::tuple &tgt, const TestDBusWrapper::MessageIterPtr &src) { } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'x', + end = 0 }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::tuple &src) { - auto var = w.eldbus_message_iter_container_new_impl( tgt, 'r', ""); - EncoderTuple<0, sizeof...(ARGS), ARGS...>::encode(w, var, src); - } - static void decode(TestDBusWrapper &w, std::tuple &tgt, const TestDBusWrapper::MessageIterPtr &src) { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, 'r' ); - if( !s ) throw TestDBusWrapper::error{}; - EncoderTuple<0, sizeof...(ARGS), ARGS...>::decode(w, tgt, s); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'd', + end = 0 }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::pair &src, char type = 'r') { - auto var = w.eldbus_message_iter_container_new_impl( tgt, type, ""); - Encoder::encode(w, var, src.first); - Encoder::encode(w, var, src.second); - } - static void decode(TestDBusWrapper &w, std::pair &tgt, const TestDBusWrapper::MessageIterPtr &src, char type = 'r') { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, type ); - if( !s ) throw TestDBusWrapper::error{}; - Encoder::decode(w, tgt.first, s); - Encoder::decode(w, tgt.second, s); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'b', + end = 0 }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const TestDBusWrapper::Variant &src) { - //w.eldbus_message_iter_arguments_append_impl(tgt, src); - auto var = w.eldbus_message_iter_container_new_impl( tgt, 'v', ""); - Encoder::encode(w, var, src.value); - } - static void decode(TestDBusWrapper &w, TestDBusWrapper::Variant &tgt, const TestDBusWrapper::MessageIterPtr &src) { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, 'v' ); - if( !s ) throw TestDBusWrapper::error{}; - Encoder::decode(w, tgt.value, s); - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 's', + end = 0 }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::vector &src) { - auto var = w.eldbus_message_iter_container_new_impl( tgt, 'a', ""); - for(auto &q : src) - Encoder::encode(w, var, q); - } - static void decode(TestDBusWrapper &w, std::vector &tgt, const TestDBusWrapper::MessageIterPtr &src) { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, 'a' ); - if( !s ) throw TestDBusWrapper::error{}; - while(!TestDBusWrapper::completed(s)) { - tgt.push_back({}); - Encoder::decode(w, tgt.back(), s); - } - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = 'o', + end = 0 }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::unordered_map &src) { - auto var = w.eldbus_message_iter_container_new_impl( tgt, 'a', ""); - for(auto &q : src){ - Encoder::value_type>::encode(w, var, q, 'e'); - } - } - static void decode(TestDBusWrapper &w, std::unordered_map &tgt, const TestDBusWrapper::MessageIterPtr &src) { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, 'a' ); - if( !s ) throw TestDBusWrapper::error{}; - while(!TestDBusWrapper::completed(s)) { - std::pair tmp; - Encoder>::decode(w, tmp, s, 'e'); - tgt.insert(std::move(tmp)); - } - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = '(', + end = ')' }; - template struct Encoder> { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const std::array &src) { - auto var = w.eldbus_message_iter_container_new_impl( tgt, 'a', ""); - for(auto &q : src) - Encoder::encode(w, var, q); - } - static void decode(TestDBusWrapper &w, std::array &tgt, const TestDBusWrapper::MessageIterPtr &src) { - auto s = w.eldbus_message_iter_get_and_next_by_type_impl( src, 'a' ); - if( !s ) throw TestDBusWrapper::error{}; - size_t i = 0; - while(!TestDBusWrapper::completed(s)) { - if(i >= tgt.size()) throw TestDBusWrapper::error{}; - Encoder::decode(w, tgt[i], s); - ++i; - } - if( i!=tgt.size()) throw TestDBusWrapper::error{}; - } +}; +template<> +struct DBusSigImpl +{ + enum + { + value = '{', + end = '}' }; - template <> struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const Dali::Accessibility::Address &src) { - Encoder>::encode(w, tgt,std::tuple { - src.GetBus(), ObjectPath{ "/org/a11y/atspi/accessible/" + src.GetPath() } } - ); +}; + +template +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const T& src) + { + w.eldbus_message_iter_arguments_append_impl(tgt, src); + } + static void decode(TestDBusWrapper& w, T& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + if(!w.eldbus_message_iter_get_and_next_impl(src, tgt)) throw TestDBusWrapper::error{}; + } +}; +template +struct Encoder::value>::type> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const T& src) + { + Encoder::type>::encode(w, tgt, static_cast::type>(src)); + } + static void decode(TestDBusWrapper& w, T& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + typename std::underlying_type::type v = 0; + Encoder::type>::decode(w, v, src); + tgt = static_cast(v); + } +}; +template +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const T& src) + { + Encoder::encode(w, tgt, src); + } + static void decode(TestDBusWrapper& w, T& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + Encoder::decode(w, tgt, src); + } +}; +template +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const T& src) + { + Encoder::encode(w, tgt, src); + } + static void decode(TestDBusWrapper& w, T& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + Encoder::decode(w, tgt, src); + } +}; +template +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const T& src) + { + Encoder::encode(w, tgt, src); + } + static void decode(TestDBusWrapper& w, T& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + Encoder::decode(w, tgt, src); + } +}; +template +struct EncoderTuple +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::tuple& src) + { + Encoder>::type>::encode(w, tgt, std::get(src)); + EncoderTuple::encode(w, tgt, src); + } + static void decode(TestDBusWrapper& w, std::tuple& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + Encoder>::type>::decode(w, std::get(tgt), src); + EncoderTuple::decode(w, tgt, src); + } +}; +template +struct EncoderTuple +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::tuple& src) + { + } + static void decode(TestDBusWrapper& w, std::tuple& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::tuple& src) + { + auto var = w.eldbus_message_iter_container_new_impl(tgt, 'r', ""); + EncoderTuple<0, sizeof...(ARGS), ARGS...>::encode(w, var, src); + } + static void decode(TestDBusWrapper& w, std::tuple& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, 'r'); + if(!s) throw TestDBusWrapper::error{}; + EncoderTuple<0, sizeof...(ARGS), ARGS...>::decode(w, tgt, s); + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::pair& src, char type = 'r') + { + auto var = w.eldbus_message_iter_container_new_impl(tgt, type, ""); + Encoder::encode(w, var, src.first); + Encoder::encode(w, var, src.second); + } + static void decode(TestDBusWrapper& w, std::pair& tgt, const TestDBusWrapper::MessageIterPtr& src, char type = 'r') + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, type); + if(!s) throw TestDBusWrapper::error{}; + Encoder::decode(w, tgt.first, s); + Encoder::decode(w, tgt.second, s); + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const TestDBusWrapper::Variant& src) + { + //w.eldbus_message_iter_arguments_append_impl(tgt, src); + auto var = w.eldbus_message_iter_container_new_impl(tgt, 'v', ""); + Encoder::encode(w, var, src.value); + } + static void decode(TestDBusWrapper& w, TestDBusWrapper::Variant& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, 'v'); + if(!s) throw TestDBusWrapper::error{}; + Encoder::decode(w, tgt.value, s); + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::vector& src) + { + auto var = w.eldbus_message_iter_container_new_impl(tgt, 'a', ""); + for(auto& q : src) + Encoder::encode(w, var, q); + } + static void decode(TestDBusWrapper& w, std::vector& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, 'a'); + if(!s) throw TestDBusWrapper::error{}; + while(!TestDBusWrapper::completed(s)) + { + tgt.push_back({}); + Encoder::decode(w, tgt.back(), s); } - static void decode(TestDBusWrapper &w, Dali::Accessibility::Address &tgt, const TestDBusWrapper::MessageIterPtr &src) { - std::tuple tmp; - Encoder>::decode(w, tmp, src); - static const size_t prefixSize = std::string{ "/org/a11y/atspi/accessible/" }.size(); - tgt = { std::move(std::get<0>(tmp)), std::get<1>(tmp).value.substr(prefixSize) }; + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::unordered_map& src) + { + auto var = w.eldbus_message_iter_container_new_impl(tgt, 'a', ""); + for(auto& q : src) + { + Encoder::value_type>::encode(w, var, q, 'e'); } - }; - template <> struct Encoder { - static void encode(TestDBusWrapper &w, const TestDBusWrapper::MessageIterPtr &tgt, const char *src) { - Encoder::encode(w, tgt, src); + } + static void decode(TestDBusWrapper& w, std::unordered_map& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, 'a'); + if(!s) throw TestDBusWrapper::error{}; + while(!TestDBusWrapper::completed(s)) + { + std::pair tmp; + Encoder>::decode(w, tmp, s, 'e'); + tgt.insert(std::move(tmp)); } - }; -} + } +}; +template +struct Encoder> +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const std::array& src) + { + auto var = w.eldbus_message_iter_container_new_impl(tgt, 'a', ""); + for(auto& q : src) + Encoder::encode(w, var, q); + } + static void decode(TestDBusWrapper& w, std::array& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + auto s = w.eldbus_message_iter_get_and_next_by_type_impl(src, 'a'); + if(!s) throw TestDBusWrapper::error{}; + size_t i = 0; + while(!TestDBusWrapper::completed(s)) + { + if(i >= tgt.size()) throw TestDBusWrapper::error{}; + Encoder::decode(w, tgt[i], s); + ++i; + } + if(i != tgt.size()) throw TestDBusWrapper::error{}; + } +}; +template<> +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const Dali::Accessibility::Address& src) + { + Encoder>::encode(w, tgt, std::tuple{src.GetBus(), ObjectPath{"/org/a11y/atspi/accessible/" + src.GetPath()}}); + } + static void decode(TestDBusWrapper& w, Dali::Accessibility::Address& tgt, const TestDBusWrapper::MessageIterPtr& src) + { + std::tuple tmp; + Encoder>::decode(w, tmp, src); + static const size_t prefixSize = std::string{"/org/a11y/atspi/accessible/"}.size(); + tgt = {std::move(std::get<0>(tmp)), std::get<1>(tmp).value.substr(prefixSize)}; + } +}; +template<> +struct Encoder +{ + static void encode(TestDBusWrapper& w, const TestDBusWrapper::MessageIterPtr& tgt, const char* src) + { + Encoder::encode(w, tgt, src); + } +}; +} // namespace detail /// \endcond -#define DBUS_DEBUG( ... ) \ - do \ - { \ - DBus::debugPrint( __FILE__, __LINE__, __VA_ARGS__ ); \ - } while( 0 ) +#define DBUS_DEBUG(...) \ + do \ + { \ + DBus::debugPrint(__FILE__, __LINE__, __VA_ARGS__); \ + } while(0) #define DBUS_W DBusWrapper::Installed() @@ -681,7 +978,7 @@ class DBusInterfaceDescription; /** * @brief Formats debug message and calls debug printer (if any) with it */ -void debugPrint( const char* file, size_t line, const char* format, ... ); +void debugPrint(const char* file, size_t line, const char* format, ...); /** * @brief Sets debug printer callback, which will be called with debug messages @@ -690,16 +987,17 @@ void debugPrint( const char* file, size_t line, const char* format, ... ); * is pointer to text, second it's length. Text is ended with 0 (not counted towards it's size), * user can safely printf it. */ -void setDebugPrinter( std::function< void( const char*, size_t ) > ); +void setDebugPrinter(std::function); struct Error { std::string message; Error() = default; - Error( std::string msg ) : message( std::move( msg ) ) + Error(std::string msg) + : message(std::move(msg)) { - bart_assert( !message.empty() ); + bart_assert(!message.empty()); } }; @@ -722,7 +1020,7 @@ struct Success * Both mean the same - ValueOrError containing no real data and being a marker, * wherever operation successed or failed and containing possible error message. */ -template < typename... ARGS > +template class ValueOrError { public: @@ -736,21 +1034,28 @@ public: * * This will be initialized as success with passed in values. */ - ValueOrError( ARGS... t ) : value( std::move( t )... ) {} + ValueOrError(ARGS... t) + : value(std::move(t)...) + { + } /** * @brief Alternative Value constructor. * * This will be initialized as success with passed in values. */ - ValueOrError( std::tuple< ARGS... > t ) : value( std::move( t ) ) {} + ValueOrError(std::tuple t) + : value(std::move(t)) + { + } /** * @brief Error constructor. This will be initialized as failure with given error message. */ - ValueOrError( Error e ) : error( std::move( e ) ) + ValueOrError(Error e) + : error(std::move(e)) { - bart_assert( !error.message.empty() ); + bart_assert(!error.message.empty()); } /** @@ -782,9 +1087,9 @@ public: * User can modify (or move) data safely. * Only callable, if operation actually successed, otherwise will bart_assert. */ - std::tuple< ARGS... >& getValues() + std::tuple& getValues() { - bart_assert( *this ); + bart_assert(*this); return value; } @@ -794,29 +1099,32 @@ public: * Returns const reference to the internal tuple containing held data. * Only callable, if operation actually successed, otherwise will bart_assert. */ - const std::tuple< ARGS... >& getValues() const + const std::tuple& getValues() const { - bart_assert( *this ); + bart_assert(*this); return value; } protected: /// \cond - std::tuple< ARGS... > value; - Error error; + std::tuple value; + Error error; /// \endcond }; /// \cond -template <> +template<> class ValueOrError<> { public: ValueOrError() = default; - ValueOrError( std::tuple<> t ) {} - ValueOrError( Error e ) : error( std::move( e ) ) + ValueOrError(std::tuple<> t) + { + } + ValueOrError(Error e) + : error(std::move(e)) { - bart_assert( !error.message.empty() ); + bart_assert(!error.message.empty()); } explicit operator bool() const @@ -829,13 +1137,13 @@ public: } std::tuple<>& getValues() { - bart_assert( *this ); + bart_assert(*this); static std::tuple<> t; return t; } std::tuple<> getValues() const { - bart_assert( *this ); + bart_assert(*this); return {}; } @@ -843,15 +1151,18 @@ protected: Error error; }; -template <> -class ValueOrError< void > +template<> +class ValueOrError { public: ValueOrError() = default; - ValueOrError( Success ) {} - ValueOrError( Error e ) : error( std::move( e ) ) + ValueOrError(Success) + { + } + ValueOrError(Error e) + : error(std::move(e)) { - bart_assert( !error.message.empty() ); + bart_assert(!error.message.empty()); } explicit operator bool() const @@ -864,13 +1175,13 @@ public: } std::tuple<>& getValues() { - bart_assert( *this ); + bart_assert(*this); static std::tuple<> t; return t; } std::tuple<> getValues() const { - bart_assert( *this ); + bart_assert(*this); return {}; } @@ -891,7 +1202,7 @@ using ObjectPath = ObjectPath; * as return data in variant. So for example user can't specify method call, which on return * expects DBUS variant holding either string or int. */ -template < typename A > +template struct EldbusVariant { A value; @@ -903,27 +1214,27 @@ struct EldbusVariant namespace detail { /// \cond -template < typename T, typename = void > +template struct signature; -template < typename... ARGS > -struct signature< std::tuple< ARGS... > >; -template < typename A, typename B > -struct signature< std::pair< A, B > >; -template < typename A > -struct signature< std::vector< A > >; -template < typename A, size_t N > -struct signature< std::array< A, N > >; -template < typename A, typename B > -struct signature< std::unordered_map< A, B > >; -template < typename A, typename B > -struct signature< std::map< A, B > >; +template +struct signature>; +template +struct signature>; +template +struct signature>; +template +struct signature>; +template +struct signature>; +template +struct signature>; /// \endcond /** * @brief Signature class for marshalling uint8 type. */ -template <> -struct signature< uint8_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -944,7 +1255,7 @@ struct signature< uint8_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, uint8_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, uint8_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -952,7 +1263,7 @@ struct signature< uint8_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, uint8_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, uint8_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -961,8 +1272,8 @@ struct signature< uint8_t > /** * @brief Signature class for marshalling uint16 type. */ -template <> -struct signature< uint16_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -983,7 +1294,7 @@ struct signature< uint16_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, uint16_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, uint16_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -991,7 +1302,7 @@ struct signature< uint16_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, uint16_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, uint16_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1000,8 +1311,8 @@ struct signature< uint16_t > /** * @brief Signature class for marshalling uint32 type. */ -template <> -struct signature< uint32_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1022,7 +1333,7 @@ struct signature< uint32_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, uint32_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, uint32_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1030,7 +1341,7 @@ struct signature< uint32_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, uint32_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, uint32_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1039,8 +1350,8 @@ struct signature< uint32_t > /** * @brief Signature class for marshalling uint64 type. */ -template <> -struct signature< uint64_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1061,7 +1372,7 @@ struct signature< uint64_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, uint64_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, uint64_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1069,7 +1380,7 @@ struct signature< uint64_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, uint64_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, uint64_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1078,8 +1389,8 @@ struct signature< uint64_t > /** * @brief Signature class for marshalling int16 type. */ -template <> -struct signature< int16_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1100,7 +1411,7 @@ struct signature< int16_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, int16_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, int16_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1108,7 +1419,7 @@ struct signature< int16_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, int16_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, int16_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1117,8 +1428,8 @@ struct signature< int16_t > /** * @brief Signature class for marshalling int32 type. */ -template <> -struct signature< int32_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1139,7 +1450,7 @@ struct signature< int32_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, int32_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, int32_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1147,7 +1458,7 @@ struct signature< int32_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, int32_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, int32_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1156,8 +1467,8 @@ struct signature< int32_t > /** * @brief Signature class for marshalling int64 type. */ -template <> -struct signature< int64_t > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1178,7 +1489,7 @@ struct signature< int64_t > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, int64_t v ) + static void set(const DBusWrapper::MessageIterPtr& iter, int64_t v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1186,7 +1497,7 @@ struct signature< int64_t > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, int64_t& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, int64_t& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1195,8 +1506,8 @@ struct signature< int64_t > /** * @brief Signature class for marshalling double type. */ -template <> -struct signature< double > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1217,7 +1528,7 @@ struct signature< double > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, double v ) + static void set(const DBusWrapper::MessageIterPtr& iter, double v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1225,7 +1536,7 @@ struct signature< double > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, double& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, double& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1233,11 +1544,11 @@ struct signature< double > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, float& v2 ) + static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2) { double v = 0; - auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); - v2 = static_cast< float >( v ); + auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); + v2 = static_cast(v); return r; } }; @@ -1245,8 +1556,8 @@ struct signature< double > /** * @brief Signature class for marshalling float type. */ -template <> -struct signature< float > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1267,7 +1578,7 @@ struct signature< float > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, float v ) + static void set(const DBusWrapper::MessageIterPtr& iter, float v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1275,7 +1586,7 @@ struct signature< float > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, double& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, double& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1283,11 +1594,11 @@ struct signature< float > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, float& v2 ) + static bool get(const DBusWrapper::MessageIterPtr& iter, float& v2) { double v = 0; - auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); - v2 = static_cast< float >( v ); + auto r = DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); + v2 = static_cast(v); return r; } }; @@ -1295,8 +1606,8 @@ struct signature< float > /** * @brief Signature class for marshalling boolean type. */ -template <> -struct signature< bool > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1317,7 +1628,7 @@ struct signature< bool > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, bool v ) + static void set(const DBusWrapper::MessageIterPtr& iter, bool v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1325,14 +1636,14 @@ struct signature< bool > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, bool& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, bool& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } }; -template < typename T > -struct signature< T, typename std::enable_if< std::is_enum< T >::value, void >::type > +template +struct signature::value, void>::type> { /** * @brief Returns name of type marshalled, for informative purposes @@ -1353,21 +1664,21 @@ struct signature< T, typename std::enable_if< std::is_enum< T >::value, void >:: /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, T v ) + static void set(const DBusWrapper::MessageIterPtr& iter, T v) { - signature::type>::set(iter, static_cast< int64_t >( v )); + signature::type>::set(iter, static_cast(v)); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, T& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, T& v) { typename std::underlying_type::type q = 0; - if (!signature::type>::get(iter, q)) + if(!signature::type>::get(iter, q)) return false; - v = static_cast< T >( q ); + v = static_cast(q); return true; } }; @@ -1378,8 +1689,8 @@ struct signature< T, typename std::enable_if< std::is_enum< T >::value, void >:: * Both (const) char * and std::string types are accepted as value to send. * Only std::string is accepted as value to receive. */ -template <> -struct signature< std::string > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1400,30 +1711,30 @@ struct signature< std::string > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::string& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } -// /** -// * @brief Marshals value v as marshalled type into message -// */ -// static void set( const DBusWrapper::MessageIterPtr &iter, const char* v ) -// { -// DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); -// } + // /** + // * @brief Marshals value v as marshalled type into message + // */ + // static void set( const DBusWrapper::MessageIterPtr &iter, const char* v ) + // { + // DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); + // } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::string& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } }; -template <> -struct signature< ObjectPath > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1444,15 +1755,15 @@ struct signature< ObjectPath > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::string& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v) { - DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{ v }); + DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{v}); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const ObjectPath& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const ObjectPath& v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1460,15 +1771,15 @@ struct signature< ObjectPath > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const char* v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const char* v) { - DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{ v }); + DBUS_W->eldbus_message_iter_arguments_append_impl(iter, ObjectPath{v}); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, ObjectPath& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, ObjectPath& v) { return DBUS_W->eldbus_message_iter_get_and_next_impl(iter, v); } @@ -1476,10 +1787,10 @@ struct signature< ObjectPath > /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::string& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::string& v) { ObjectPath q; - if (!DBUS_W->eldbus_message_iter_get_and_next_impl(iter, q)) return false; + if(!DBUS_W->eldbus_message_iter_get_and_next_impl(iter, q)) return false; v = std::move(q.value); return true; } @@ -1491,8 +1802,8 @@ struct signature< ObjectPath > * Both (const) char * and std::string types are accepted as value to send. * You can't use (const) char * variable type to receive value. */ -template <> -struct signature< char* > +template<> +struct signature { /** * @brief Returns name of type marshalled, for informative purposes @@ -1513,7 +1824,7 @@ struct signature< char* > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::string& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::string& v) { DBUS_W->eldbus_message_iter_arguments_append_impl(iter, v); } @@ -1521,21 +1832,21 @@ struct signature< char* > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const char* v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const char* v) { - DBUS_W->eldbus_message_iter_arguments_append_impl(iter, std::string{ v }); + DBUS_W->eldbus_message_iter_arguments_append_impl(iter, std::string{v}); } }; /// \cond -template < size_t INDEX, typename A, typename... ARGS > +template struct signature_tuple_element_type_helper { - using type = typename signature_tuple_element_type_helper< INDEX - 1, ARGS... >::type; + using type = typename signature_tuple_element_type_helper::type; }; -template < typename A, typename... ARGS > -struct signature_tuple_element_type_helper< 0, A, ARGS... > +template +struct signature_tuple_element_type_helper<0, A, ARGS...> { using type = A; }; @@ -1548,19 +1859,19 @@ struct signature_tuple_element_type_helper< 0, A, ARGS... > * and incrementing. This class recursively calls itself with increasing INDEX value * until INDEX is equal to SIZE, where recursive calling ends. */ -template < size_t INDEX, size_t SIZE, typename... ARGS > +template struct signature_tuple_helper { - using current_type = typename signature_tuple_element_type_helper< INDEX, ARGS... >::type; + using current_type = typename signature_tuple_element_type_helper::type; /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - if( INDEX + 1 >= SIZE ) - return signature< current_type >::name(); - return signature< current_type >::name() + ", " + signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::name(); + if(INDEX + 1 >= SIZE) + return signature::name(); + return signature::name() + ", " + signature_tuple_helper::name(); } /** @@ -1568,25 +1879,25 @@ struct signature_tuple_helper */ static std::string sig() { - return signature< current_type >::sig() + signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::sig(); + return signature::sig() + signature_tuple_helper::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::tuple< ARGS... >& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple& args) { - signature< current_type >::set( iter, std::get< INDEX >( args ) ); - signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::set( iter, args ); + signature::set(iter, std::get(args)); + signature_tuple_helper::set(iter, args); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::tuple< ARGS... >& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple& args) { - return signature< current_type >::get( iter, std::get< INDEX >( args ) ) && - signature_tuple_helper< INDEX + 1, SIZE, ARGS... >::get( iter, args ); + return signature::get(iter, std::get(args)) && + signature_tuple_helper::get(iter, args); } }; @@ -1596,8 +1907,8 @@ struct signature_tuple_helper * This class marks end of the tuple marshalling. Members of this class are called * when INDEX value is equal to SIZE. */ -template < size_t SIZE, typename... ARGS > -struct signature_tuple_helper< SIZE, SIZE, ARGS... > +template +struct signature_tuple_helper { /** * @brief Returns name of type marshalled, for informative purposes @@ -1618,14 +1929,14 @@ struct signature_tuple_helper< SIZE, SIZE, ARGS... > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::tuple< ARGS... >& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple& args) { } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::tuple< ARGS... >& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple& args) { return true; } @@ -1637,15 +1948,15 @@ struct signature_tuple_helper< SIZE, SIZE, ARGS... > * This class marshalls tuple of values. This represents * DBUS struct typle, encoded with character 'r' */ -template < typename... ARGS > -struct signature< std::tuple< ARGS... > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "tuple<" + signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::name() + ">"; + return "tuple<" + signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name() + ">"; } /** @@ -1653,26 +1964,26 @@ struct signature< std::tuple< ARGS... > > */ static std::string sig() { - return "(" + signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::sig() + ")"; + return "(" + signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig() + ")"; } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::tuple< ARGS... >& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::tuple& args) { - auto entry = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'r', ""); - signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::set( entry, args ); + auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'r', ""); + signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::set(entry, args); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::tuple< ARGS... >& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::tuple& args) { - auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'r' ); - if (!entry) return false; - return signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::get( entry, args ); + auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r'); + if(!entry) return false; + return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::get(entry, args); } }; @@ -1687,15 +1998,15 @@ struct signature< std::tuple< ARGS... > > * or * \code{.cpp} ValueOrError>> \endcode */ -template < typename... ARGS > -struct signature< ValueOrError< ARGS... > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "ValueOrError<" + signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::name() + ">"; + return "ValueOrError<" + signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name() + ">"; } /** @@ -1703,31 +2014,31 @@ struct signature< ValueOrError< ARGS... > > */ static std::string sig() { - return signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::sig(); + return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const ValueOrError< ARGS... >& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError& args) { - signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::set( iter, args.getValues() ); + signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::set(iter, args.getValues()); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, ValueOrError< ARGS... >& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError& args) { - return signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::get( iter, args.getValues() ); + return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::get(iter, args.getValues()); } }; /** * @brief Signature class for marshalling ValueOrError type */ -template <> -struct signature< ValueOrError< void > > +template<> +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes @@ -1748,14 +2059,14 @@ struct signature< ValueOrError< void > > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const ValueOrError< void >& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError& args) { } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, ValueOrError< void >& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError& args) { return true; } @@ -1764,8 +2075,8 @@ struct signature< ValueOrError< void > > /** * @brief Signature class for marshalling ValueOrError<> type */ -template <> -struct signature< ValueOrError<> > +template<> +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes @@ -1786,14 +2097,14 @@ struct signature< ValueOrError<> > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const ValueOrError<>& args ) + static void set(const DBusWrapper::MessageIterPtr& iter, const ValueOrError<>& args) { } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, ValueOrError<>& args ) + static bool get(const DBusWrapper::MessageIterPtr& iter, ValueOrError<>& args) { return true; } @@ -1802,15 +2113,15 @@ struct signature< ValueOrError<> > /** * @brief Signature class for marshalling pair of types */ -template < typename A, typename B > -struct signature< std::pair< A, B > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "pair<" + signature_tuple_helper< 0, 2, A, B >::name() + ">"; + return "pair<" + signature_tuple_helper<0, 2, A, B>::name() + ">"; } /** @@ -1818,35 +2129,36 @@ struct signature< std::pair< A, B > > */ static std::string sig() { - return "(" + signature_tuple_helper< 0, 2, A, B >::sig() + ")"; + return "(" + signature_tuple_helper<0, 2, A, B>::sig() + ")"; } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::pair< A, B >& ab, bool dictionary = false ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::pair& ab, bool dictionary = false) { - auto entry = DBUS_W->eldbus_message_iter_container_new_impl( iter, dictionary ? 'e' : 'r', ""); - signature_tuple_helper< 0, 2, A, B >::set( entry, ab ); + auto entry = DBUS_W->eldbus_message_iter_container_new_impl(iter, dictionary ? 'e' : 'r', ""); + signature_tuple_helper<0, 2, A, B>::set(entry, ab); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::pair< A, B >& ab ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::pair& ab) { - auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'r' ); - if (!entry) { - entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, '{' ); - if (!entry) return false; + auto entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'r'); + if(!entry) + { + entry = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, '{'); + if(!entry) return false; } - std::tuple< A, B > ab_tmp; - auto z = signature_tuple_helper< 0, 2, A, B >::get( entry, ab_tmp ); - if( z ) + std::tuple ab_tmp; + auto z = signature_tuple_helper<0, 2, A, B>::get(entry, ab_tmp); + if(z) { - ab.first = std::move( std::get< 0 >( ab_tmp ) ); - ab.second = std::move( std::get< 1 >( ab_tmp ) ); + ab.first = std::move(std::get<0>(ab_tmp)); + ab.second = std::move(std::get<1>(ab_tmp)); } return z; } @@ -1857,15 +2169,15 @@ struct signature< std::pair< A, B > > * * This marshals container's content as DBUS a ascii character type code. */ -template < typename A > -struct signature< std::vector< A > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "vector<" + signature< A >::name() + ">"; + return "vector<" + signature::name() + ">"; } /** @@ -1873,33 +2185,33 @@ struct signature< std::vector< A > > */ static std::string sig() { - return "a" + signature< A >::sig(); + return "a" + signature::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::vector< A >& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::vector& v) { - auto lst = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'a', signature< A >::sig()); - bart_assert( lst ); - for( auto& a : v ) + auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', signature::sig()); + bart_assert(lst); + for(auto& a : v) { - signature< A >::set( lst, a ); + signature::set(lst, a); } } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::vector< A >& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::vector& v) { - auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'a' ); - if (!s) return false; + auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a'); + if(!s) return false; v.clear(); A a; - while( signature< A >::get( s, a ) ) - v.push_back( std::move( a ) ); + while(signature::get(s, a)) + v.push_back(std::move(a)); return true; } @@ -1910,15 +2222,15 @@ struct signature< std::vector< A > > * * This marshals container's content as DBUS a ascii character type code. */ -template < typename A, size_t N > -struct signature< std::array< A, N > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "array<" + signature< A >::name() + ", " + std::to_string( N ) + ">"; + return "array<" + signature::name() + ", " + std::to_string(N) + ">"; } /** @@ -1926,33 +2238,33 @@ struct signature< std::array< A, N > > */ static std::string sig() { - return "a" + signature< A >::sig(); + return "a" + signature::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::array< A, N >& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::array& v) { - auto lst = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'a', signature< A >::sig()); - bart_assert( lst ); - for( auto& a : v ) + auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', signature::sig()); + bart_assert(lst); + for(auto& a : v) { - signature< A >::set( lst, a ); + signature::set(lst, a); } } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::array< A, N >& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::array& v) { - auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'a' ); - if ( !s ) + auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a'); + if(!s) return false; - for( auto& a : v ) + for(auto& a : v) { - if( !signature< A >::get( s, a ) ) + if(!signature::get(s, a)) return false; } return true; @@ -1964,15 +2276,15 @@ struct signature< std::array< A, N > > * * This marshals variant's content as DBUS v ascii character type code. */ -template < typename A > -struct signature< EldbusVariant< A > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "variant<" + signature< A >::name() + ">"; + return "variant<" + signature::name() + ">"; } /** @@ -1986,29 +2298,29 @@ struct signature< EldbusVariant< A > > /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const EldbusVariant< A >& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const EldbusVariant& v) { - set( iter, v.value ); + set(iter, v.value); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const A& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const A& v) { - auto var = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'v', signature< A >::sig()); - signature< A >::set( var, v ); + auto var = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'v', signature::sig()); + signature::set(var, v); } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, EldbusVariant< A >& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, EldbusVariant& v) { - auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'v' ); - if( !s ) + auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'v'); + if(!s) return false; - return signature< A >::get( s, v.value ); + return signature::get(s, v.value); } }; @@ -2022,15 +2334,15 @@ struct signature< EldbusVariant< A > > * User can receive such values as std::vector of std::pair values. * Order of such values is unspecified. */ -template < typename A, typename B > -struct signature< std::unordered_map< A, B > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "unordered_map<" + signature< A >::name() + ", " + signature< B >::name() + ">"; + return "unordered_map<" + signature::name() + ", " + signature::name() + ">"; } /** @@ -2038,35 +2350,35 @@ struct signature< std::unordered_map< A, B > > */ static std::string sig() { - return "a{" + signature_tuple_helper< 0, 2, A, B >::sig() + "}"; + return "a{" + signature_tuple_helper<0, 2, A, B>::sig() + "}"; } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::unordered_map< A, B >& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::unordered_map& v) { - auto sig = "{" + signature_tuple_helper< 0, 2, A, B >::sig() + "}"; - auto lst = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'a', sig); - bart_assert( lst ); - for( auto& a : v ) + auto sig = "{" + signature_tuple_helper<0, 2, A, B>::sig() + "}"; + auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig); + bart_assert(lst); + for(auto& a : v) { - signature< std::pair< A, B > >::set( lst, a, true ); + signature>::set(lst, a, true); } } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::unordered_map< A, B >& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::unordered_map& v) { - auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'a' ); + auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a'); v.clear(); - if( !s ) + if(!s) return false; - std::pair< A, B > a; - while( signature< std::pair< A, B > >::get( s, a ) ) - v.insert( std::move( a ) ); + std::pair a; + while(signature>::get(s, a)) + v.insert(std::move(a)); return true; } }; @@ -2081,15 +2393,15 @@ struct signature< std::unordered_map< A, B > > * User can receive such values as std::vector of std::pair values. * Order of such values is unspecified. */ -template < typename A, typename B > -struct signature< std::map< A, B > > +template +struct signature> { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "map<" + signature< A >::name() + ", " + signature< B >::name() + ">"; + return "map<" + signature::name() + ", " + signature::name() + ">"; } /** @@ -2097,34 +2409,34 @@ struct signature< std::map< A, B > > */ static std::string sig() { - return "a{" + signature_tuple_helper< 0, 2, A, B >::sig() + "}"; + return "a{" + signature_tuple_helper<0, 2, A, B>::sig() + "}"; } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const std::map< A, B >& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const std::map& v) { - auto sig = "{" + signature_tuple_helper< 0, 2, A, B >::sig() + "}"; - auto lst = DBUS_W->eldbus_message_iter_container_new_impl( iter, 'a', sig); - bart_assert( lst ); - for( auto& a : v ) + auto sig = "{" + signature_tuple_helper<0, 2, A, B>::sig() + "}"; + auto lst = DBUS_W->eldbus_message_iter_container_new_impl(iter, 'a', sig); + bart_assert(lst); + for(auto& a : v) { - signature< std::pair< A, B > >::set( lst, a, true ); + signature>::set(lst, a, true); } } /** * @brief Marshals value from marshalled type into variable v */ - static bool get( const DBusWrapper::MessageIterPtr &iter, std::map< A, B >& v ) + static bool get(const DBusWrapper::MessageIterPtr& iter, std::map& v) { - auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl( iter, 'a' ); - if( !s ) + auto s = DBUS_W->eldbus_message_iter_get_and_next_by_type_impl(iter, 'a'); + if(!s) return false; - std::pair< A, B > a; - while( signature< std::pair< A, B > >::get( s, a ) ) - v.insert( std::move( a ) ); + std::pair a; + while(signature>::get(s, a)) + v.insert(std::move(a)); return true; } }; @@ -2132,15 +2444,15 @@ struct signature< std::map< A, B > > /** * @brief Signature helper class for marshalling const reference types */ -template < typename A > -struct signature< const A& > +template +struct signature { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "const " + signature< A >::name() + "&"; + return "const " + signature::name() + "&"; } /** @@ -2148,38 +2460,38 @@ struct signature< const A& > */ static std::string sig() { - return signature< A >::sig(); + return signature::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const A& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const A& v) { - signature< A >::set( iter, v ); + signature::set(iter, v); } /** * @brief Marshals value from marshalled type into variable v */ - static void get( const DBusWrapper::MessageIterPtr &iter, A& v ) + static void get(const DBusWrapper::MessageIterPtr& iter, A& v) { - signature< A >::get( iter, v ); + signature::get(iter, v); } }; /** * @brief Signature helper class for marshalling reference types */ -template < typename A > -struct signature< A& > +template +struct signature { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return signature< A >::name() + "&"; + return signature::name() + "&"; } /** @@ -2187,38 +2499,38 @@ struct signature< A& > */ static std::string sig() { - return signature< A >::sig(); + return signature::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const A& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const A& v) { - signature< A >::set( iter, v ); + signature::set(iter, v); } /** * @brief Marshals value from marshalled type into variable v */ - static void get( const DBusWrapper::MessageIterPtr &iter, A& v ) + static void get(const DBusWrapper::MessageIterPtr& iter, A& v) { - signature< A >::get( iter, v ); + signature::get(iter, v); } }; /** * @brief Signature helper class for marshalling const types */ -template < typename A > -struct signature< const A > +template +struct signature { /** * @brief Returns name of type marshalled, for informative purposes */ static std::string name() { - return "const " + signature< A >::name(); + return "const " + signature::name(); } /** @@ -2226,384 +2538,380 @@ struct signature< const A > */ static std::string sig() { - return signature< A >::sig(); + return signature::sig(); } /** * @brief Marshals value v as marshalled type into message */ - static void set( const DBusWrapper::MessageIterPtr &iter, const A& v ) + static void set(const DBusWrapper::MessageIterPtr& iter, const A& v) { - signature< A >::set( iter, v ); + signature::set(iter, v); } /** * @brief Marshals value from marshalled type into variable v */ - static void get( const DBusWrapper::MessageIterPtr &iter, A& v ) + static void get(const DBusWrapper::MessageIterPtr& iter, A& v) { - signature< A >::get( iter, v ); + signature::get(iter, v); } }; /// \cond using CallId = DBusWrapper::CallId; -template < typename ValueType > -ValueType unpackValues( CallId callId, const DBusWrapper::MessagePtr &msg ) +template +ValueType unpackValues(CallId callId, const DBusWrapper::MessagePtr& msg) { - auto iter = DBUS_W->eldbus_message_iter_get_impl( msg, false ); + auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, false); ValueType r; - if( iter ) + if(iter) { - if( !signature< ValueType >::get( iter, r ) ) + if(!signature::get(iter, r)) { - DBUS_DEBUG( "ValueType is %s", signature< ValueType >::name().c_str() ); - r = Error{"call " + std::to_string( callId.id ) + ": failed to unpack values, got signature '" + - DBUS_W->eldbus_message_signature_get_impl( msg ) + "', expected '" + signature< ValueType >::sig() + "'"}; + DBUS_DEBUG("ValueType is %s", signature::name().c_str()); + r = Error{"call " + std::to_string(callId.id) + ": failed to unpack values, got signature '" + + DBUS_W->eldbus_message_signature_get_impl(msg) + "', expected '" + signature::sig() + "'"}; } } else { - r = Error{"call " + std::to_string( callId.id ) + ": failed to get iterator"}; + r = Error{"call " + std::to_string(callId.id) + ": failed to get iterator"}; } return r; } -inline void packValues_helper( const DBusWrapper::MessageIterPtr& ) {} +inline void packValues_helper(const DBusWrapper::MessageIterPtr&) +{ +} -template < typename A, typename... ARGS > -void packValues_helper( const DBusWrapper::MessageIterPtr &iter, A&& a, ARGS&&... r ) +template +void packValues_helper(const DBusWrapper::MessageIterPtr& iter, A&& a, ARGS&&... r) { - signature< A >::set( iter, std::forward< A >( a ) ); - packValues_helper( iter, std::forward< ARGS >( r )... ); + signature::set(iter, std::forward(a)); + packValues_helper(iter, std::forward(r)...); } -template < typename... ARGS > -void packValues( CallId callId, const DBusWrapper::MessagePtr &msg, ARGS&&... r ) +template +void packValues(CallId callId, const DBusWrapper::MessagePtr& msg, ARGS&&... r) { - auto iter = DBUS_W->eldbus_message_iter_get_impl( msg, true ); - packValues_helper( iter, std::forward< ARGS >( r )... ); + auto iter = DBUS_W->eldbus_message_iter_get_impl(msg, true); + packValues_helper(iter, std::forward(r)...); } -template < typename > +template struct ReturnType; -template < typename R, typename... ARGS > -struct ReturnType< R( ARGS... ) > +template +struct ReturnType { using type = R; }; -template < typename R, typename... ARGS > -struct ReturnType< std::function< R( ARGS... ) > > +template +struct ReturnType> { using type = R; }; -template < int... > +template struct sequence { }; -template < int N, int... S > -struct sequence_gen : sequence_gen< N - 1, N - 1, S... > +template +struct sequence_gen : sequence_gen { }; -template < int... S > -struct sequence_gen< 0, S... > +template +struct sequence_gen<0, S...> { - typedef sequence< S... > type; + typedef sequence type; }; -template < typename C, typename... ARGS > +template struct apply_helper { - const std::function< C >& c; - const std::tuple< ARGS... >& args; + const std::function& c; + const std::tuple& args; - template < int... S > - auto apply_2( sequence< S... > ) const -> decltype( c( std::get< S >( args )... ) ) + template + auto apply_2(sequence) const -> decltype(c(std::get(args)...)) { - return c( std::get< S >( args )... ); + return c(std::get(args)...); } - auto apply_1() const -> decltype( apply_2( typename sequence_gen< sizeof...( ARGS ) >::type() ) ) + auto apply_1() const -> decltype(apply_2(typename sequence_gen::type())) { - return apply_2( typename sequence_gen< sizeof...( ARGS ) >::type() ); + return apply_2(typename sequence_gen::type()); } }; -template < typename C, typename A, typename... ARGS > +template struct apply_helper_2 { - const std::function< C >& c; - const A& a; - const std::tuple< ARGS... >& args; + const std::function& c; + const A& a; + const std::tuple& args; - template < int... S > - auto apply_2( sequence< S... > ) const -> decltype( c( a, std::get< S >( args )... ) ) + template + auto apply_2(sequence) const -> decltype(c(a, std::get(args)...)) { - return c( a, std::get< S >( args )... ); + return c(a, std::get(args)...); } - auto apply_1() const -> decltype( apply_2( typename sequence_gen< sizeof...( ARGS ) >::type() ) ) + auto apply_1() const -> decltype(apply_2(typename sequence_gen::type())) { - return apply_2( typename sequence_gen< sizeof...( ARGS ) >::type() ); + return apply_2(typename sequence_gen::type()); } }; -template < typename C, typename... ARGS > -auto apply( const std::function< C >& c, const std::tuple< ARGS... >& args ) -> typename ReturnType< C >::type +template +auto apply(const std::function& c, const std::tuple& args) -> typename ReturnType::type { - apply_helper< C, ARGS... > ah{c, args}; + apply_helper ah{c, args}; return ah.apply_1(); } -template < typename C, typename D, typename... ARGS > -auto apply( const std::function< C >& c, const D& d, const std::tuple< ARGS... >& args ) -> typename ReturnType< C >::type +template +auto apply(const std::function& c, const D& d, const std::tuple& args) -> typename ReturnType::type { - apply_helper_2< C, D, ARGS... > ah{c, d, args}; + apply_helper_2 ah{c, d, args}; return ah.apply_1(); } struct ConnectionState { DBusWrapper::ConnectionPtr connection; - DBusWrapper::ObjectPtr object; - DBusWrapper::ProxyPtr proxy, propertiesProxy; + DBusWrapper::ObjectPtr object; + DBusWrapper::ProxyPtr proxy, propertiesProxy; }; -template < typename RETTYPE, typename... ARGS > -RETTYPE call( CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, const ARGS&... args ) +template +RETTYPE call(CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, const ARGS&... args) { - const auto &proxy = property ? connectionState.propertiesProxy : connectionState.proxy; - if( !proxy ) + const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy; + if(!proxy) { - DBUS_DEBUG( "call %d: not initialized", callId.id ); + DBUS_DEBUG("call %d: not initialized", callId.id); return Error{"not initialized"}; } - DBUS_DEBUG( "call %d: calling '%s'", callId.id, funcName.c_str() ); + DBUS_DEBUG("call %d: calling '%s'", callId.id, funcName.c_str()); auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName); - if( !msg ) + if(!msg) { - DBUS_DEBUG( "call %d: failed", callId.id ); + DBUS_DEBUG("call %d: failed", callId.id); return Error{"failed to create message"}; } - detail::packValues( callId, msg, args... ); - auto reply = DBUS_W->eldbus_proxy_send_and_block_impl( proxy, msg ); - DBUS_DEBUG( "call %d: calling '%s' done", callId.id, funcName.c_str() ); - if( !reply ) + detail::packValues(callId, msg, args...); + auto reply = DBUS_W->eldbus_proxy_send_and_block_impl(proxy, msg); + DBUS_DEBUG("call %d: calling '%s' done", callId.id, funcName.c_str()); + if(!reply) { - DBUS_DEBUG( "call %d: failed", callId.id ); + DBUS_DEBUG("call %d: failed", callId.id); return Error{"eldbus returned null as reply"}; } std::string errname, errmsg; - if( DBUS_W->eldbus_message_error_get_impl( reply, errname, errmsg ) ) + if(DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg)) { - DBUS_DEBUG( "call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str() ); + DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str()); return Error{errname + ": " + errmsg}; } - DBUS_DEBUG( "call %d: got reply with signature '%s'", callId.id, - DBUS_W->eldbus_message_signature_get_impl( reply ).c_str() ); - return detail::unpackValues< RETTYPE >( callId, reply ); + DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(reply).c_str()); + return detail::unpackValues(callId, reply); } -template < typename RETTYPE, typename... ARGS > -void asyncCall( CallId callId, const ConnectionState &connectionState, - bool property, const std::string& funcName, - std::function< void( RETTYPE ) > callback, const ARGS&... args ) +template +void asyncCall(CallId callId, const ConnectionState& connectionState, bool property, const std::string& funcName, std::function callback, const ARGS&... args) { - const auto &proxy = property ? connectionState.propertiesProxy : connectionState.proxy; - if( !proxy ) + const auto& proxy = property ? connectionState.propertiesProxy : connectionState.proxy; + if(!proxy) { - DBUS_DEBUG( "call %d: not initialized", callId.id ); - callback( Error{"not initialized"} ); + DBUS_DEBUG("call %d: not initialized", callId.id); + callback(Error{"not initialized"}); return; } - auto msg = DBUS_W->eldbus_proxy_method_call_new_impl( proxy, funcName ); - if( !msg ) + auto msg = DBUS_W->eldbus_proxy_method_call_new_impl(proxy, funcName); + if(!msg) { - DBUS_DEBUG( "call %d: failed", callId.id ); - callback( Error{"failed to create message"} ); + DBUS_DEBUG("call %d: failed", callId.id); + callback(Error{"failed to create message"}); return; } - detail::packValues( callId, msg, args... ); - auto pending = DBUS_W->eldbus_proxy_send_impl( proxy, msg, [callback, callId, proxy]( const DBusWrapper::MessagePtr &reply ) { - DBUS_DEBUG( "call %d: calling done", callId.id ); - if( !reply ) - { - DBUS_DEBUG( "call %d: failed", callId.id ); - callback( Error{"eldbus returned null as reply"} ); - } - else - { - std::string errname, errmsg; - if( DBUS_W->eldbus_message_error_get_impl( reply, errname, errmsg ) ) - { - DBUS_DEBUG( "call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str() ); - callback( Error{errname + ": " + errmsg} ); - } - else - { - DBUS_DEBUG( "call %d: got reply with signature '%s'", callId.id, - DBUS_W->eldbus_message_signature_get_impl( reply ).c_str() ); - callback( detail::unpackValues< RETTYPE >( callId, reply ) ); - } - } + detail::packValues(callId, msg, args...); + auto pending = DBUS_W->eldbus_proxy_send_impl(proxy, msg, [callback, callId, proxy](const DBusWrapper::MessagePtr& reply) { + DBUS_DEBUG("call %d: calling done", callId.id); + if(!reply) + { + DBUS_DEBUG("call %d: failed", callId.id); + callback(Error{"eldbus returned null as reply"}); + } + else + { + std::string errname, errmsg; + if(DBUS_W->eldbus_message_error_get_impl(reply, errname, errmsg)) + { + DBUS_DEBUG("call %d: %s: %s", callId.id, errname.c_str(), errmsg.c_str()); + callback(Error{errname + ": " + errmsg}); } - ); - if( pending ) + else + { + DBUS_DEBUG("call %d: got reply with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(reply).c_str()); + callback(detail::unpackValues(callId, reply)); + } + } + }); + if(pending) { - DBUS_DEBUG( "call %d: call sent", callId.id ); + DBUS_DEBUG("call %d: call sent", callId.id); } else { - DBUS_DEBUG( "call %d: failed to send call", callId.id ); - callback( Error{"failed to send call"} ); + DBUS_DEBUG("call %d: failed to send call", callId.id); + callback(Error{"failed to send call"}); } } -inline void displayDebugCallInfo( CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName ) +inline void displayDebugCallInfo(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName) { - DBUS_DEBUG( "call %d: %s iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str() ); + DBUS_DEBUG("call %d: %s iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str()); } -inline void displayDebugCallInfoSignal( CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName ) +inline void displayDebugCallInfoSignal(CallId callId, const std::string& funcName, const std::string& info, const std::string& interfaceName) { - DBUS_DEBUG( "call %d: %s signal iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str() ); + DBUS_DEBUG("call %d: %s signal iname = %s fname = %s", callId.id, info.c_str(), interfaceName.c_str(), funcName.c_str()); } -inline void displayDebugCallInfoProperty( CallId callId, const std::string& funcName, std::string info, const std::string& interfaceName, - const std::string& propertyName ) +inline void displayDebugCallInfoProperty(CallId callId, const std::string& funcName, std::string info, const std::string& interfaceName, const std::string& propertyName) { - DBUS_DEBUG( "call %d: %s iname = %s pname = %s", callId.id, info.c_str(), interfaceName.c_str(), propertyName.c_str() ); + DBUS_DEBUG("call %d: %s iname = %s pname = %s", callId.id, info.c_str(), interfaceName.c_str(), propertyName.c_str()); } using StringStorage = DBusWrapper::StringStorage; -template < typename A, typename... ARGS > +template struct EldbusArgGenerator_Helper { - static void add( std::vector< std::pair >& r ) + static void add(std::vector>& r) { - auto s = r.size(); - auto sig = signature< A >::sig(); - bart_assert( !sig.empty() ); - auto name = "p" + std::to_string( s + 1 ); - r.push_back({ std::move(sig), std::move(name) }); - EldbusArgGenerator_Helper::add( r ); + auto s = r.size(); + auto sig = signature::sig(); + bart_assert(!sig.empty()); + auto name = "p" + std::to_string(s + 1); + r.push_back({std::move(sig), std::move(name)}); + EldbusArgGenerator_Helper::add(r); } }; -template <> -struct EldbusArgGenerator_Helper< void > +template<> +struct EldbusArgGenerator_Helper { - static void add( std::vector< std::pair >& ) + static void add(std::vector>&) { } }; -template <> -struct EldbusArgGenerator_Helper< ValueOrError< void >, void > +template<> +struct EldbusArgGenerator_Helper, void> { - static void add( std::vector< std::pair >& ) + static void add(std::vector>&) { } }; -template <> -struct EldbusArgGenerator_Helper< ValueOrError<>, void > +template<> +struct EldbusArgGenerator_Helper, void> { - static void add( std::vector< std::pair >& ) + static void add(std::vector>&) { } }; -template < typename... ARGS > -struct EldbusArgGenerator_Helper< std::tuple< ARGS... > > +template +struct EldbusArgGenerator_Helper> { - static void add( std::vector< std::pair >& r ) + static void add(std::vector>& r) { - EldbusArgGenerator_Helper< ARGS..., void >::add( r ); + EldbusArgGenerator_Helper::add(r); } }; -template < typename RetType > +template struct dbus_interface_return_type_traits { - using type = ValueOrError< RetType >; + using type = ValueOrError; }; -template < typename... ARGS > -struct dbus_interface_return_type_traits< ValueOrError< ARGS... > > +template +struct dbus_interface_return_type_traits> { - using type = ValueOrError< ARGS... >; + using type = ValueOrError; }; -template < typename T > +template struct dbus_interface_traits; -template < typename RetType, typename... ARGS > -struct dbus_interface_traits< RetType( ARGS... ) > +template +struct dbus_interface_traits { - using Ret = typename dbus_interface_return_type_traits< RetType >::type; - using SyncCB = std::function< Ret( ARGS... ) >; - using AsyncCB = std::function< void( std::function< void( Ret ) >, ARGS... ) >; - using VEArgs = ValueOrError< ARGS... >; + using Ret = typename dbus_interface_return_type_traits::type; + using SyncCB = std::function; + using AsyncCB = std::function, ARGS...)>; + using VEArgs = ValueOrError; }; -template < typename T > +template struct EldbusArgGenerator_Args; -template < typename RetType, typename... ARGS > -struct EldbusArgGenerator_Args< RetType( ARGS... ) > +template +struct EldbusArgGenerator_Args { static std::string name() { - return signature_tuple_helper< 0, sizeof...( ARGS ), ARGS... >::name(); + return signature_tuple_helper<0, sizeof...(ARGS), ARGS...>::name(); } - static std::vector< std::pair > get() + static std::vector> get() { - std::vector< std::pair > tmp; - EldbusArgGenerator_Helper< ARGS..., void >::add( tmp ); + std::vector> tmp; + EldbusArgGenerator_Helper::add(tmp); return tmp; } }; -template < typename T > +template struct EldbusArgGenerator_ReturnType; -template < typename RetType, typename... ARGS > -struct EldbusArgGenerator_ReturnType< RetType( ARGS... ) > +template +struct EldbusArgGenerator_ReturnType { static std::string name() { - return signature< RetType >::name(); + return signature::name(); } - static std::vector< std::pair > get( ) + static std::vector> get() { - std::vector< std::pair > tmp; - EldbusArgGenerator_Helper< RetType, void >::add( tmp ); + std::vector> tmp; + EldbusArgGenerator_Helper::add(tmp); return tmp; } }; -template < typename T > +template struct EldbusArgGenerator_ReturnType; -template < typename... ARGS > -struct EldbusArgGenerator_ReturnType< void( ARGS... ) > +template +struct EldbusArgGenerator_ReturnType { static std::string name() { return ""; } - static std::vector< std::pair > get( ) + static std::vector> get() { return {}; } }; /// \endcond -} +} // namespace detail using ConnectionType = DBusWrapper::ConnectionType; @@ -2635,8 +2943,7 @@ public: * @param path_name object's path * @param interface_name interface name */ - DBusClient( std::string busName_, std::string pathName_, std::string interfaceName_, - ConnectionType tp ); + DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_, ConnectionType tp); /** * @brief Connects to dbus using connection conn @@ -2646,8 +2953,7 @@ public: * @param interface_name interface name * @param conn connection object from getDBusConnectionByType call */ - DBusClient( std::string busName_, std::string pathName_, std::string interfaceName_, - const DBusWrapper::ConnectionPtr &conn = {} ); + DBusClient(std::string busName_, std::string pathName_, std::string interfaceName_, const DBusWrapper::ConnectionPtr& conn = {}); /** * @brief Destructor object. @@ -2656,12 +2962,12 @@ public: * All asynchronous calls will be cancelled, their callback's will be called * with failure message. */ - ~DBusClient() = default; - DBusClient( const DBusClient& ) = delete; - DBusClient( DBusClient&& ) = default; + ~DBusClient() = default; + DBusClient(const DBusClient&) = delete; + DBusClient(DBusClient&&) = default; - DBusClient& operator=( DBusClient&& ) = default; - DBusClient& operator=( const DBusClient& ) = delete; + DBusClient& operator=(DBusClient&&) = default; + DBusClient& operator=(const DBusClient&) = delete; /** * @brief bool operator @@ -2670,7 +2976,7 @@ public: */ explicit operator bool() const { - return bool( connectionState->proxy ); + return bool(connectionState->proxy); } /** @@ -2683,15 +2989,15 @@ public: * defines method, which takes two arguments (two floats) and return * single value of type int. */ - template < typename T > + template struct Method { /// \cond - using RetType = typename detail::dbus_interface_traits< T >::Ret; - const detail::ConnectionState &connectionState; - std::string funcName; - std::string info; - std::shared_ptr< ConnectionInfo > connectionInfo; + using RetType = typename detail::dbus_interface_traits::Ret; + const detail::ConnectionState& connectionState; + std::string funcName; + std::string info; + std::shared_ptr connectionInfo; /// \endcond /** @@ -2702,12 +3008,12 @@ public: * * @param args arguments to pass to the method */ - template < typename... ARGS > - RetType call( const ARGS&... args ) + template + RetType call(const ARGS&... args) { detail::CallId callId; - detail::displayDebugCallInfo( callId, funcName, info, connectionInfo->interfaceName ); - return detail::call< RetType >( callId, connectionState, false, funcName, args... ); + detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName); + return detail::call(callId, connectionState, false, funcName, args...); } /** @@ -2718,12 +3024,12 @@ public: * @param callback callback functor, which will be called with return value(s) or error message * @param args arguments to pass to the method */ - template < typename... ARGS > - void asyncCall( std::function< void( RetType ) > callback, const ARGS&... args ) + template + void asyncCall(std::function callback, const ARGS&... args) { detail::CallId callId; - detail::displayDebugCallInfo( callId, funcName, info, connectionInfo->interfaceName ); - detail::asyncCall< RetType >( callId, connectionState, false, funcName, std::move( callback ), args... ); + detail::displayDebugCallInfo(callId, funcName, info, connectionInfo->interfaceName); + detail::asyncCall(callId, connectionState, false, funcName, std::move(callback), args...); } }; @@ -2734,16 +3040,16 @@ public: * Note, that library automatically wraps both sent and received value into * DBUS's wrapper type. */ - template < typename T > + template struct Property { /// \cond - using RetType = typename detail::dbus_interface_return_type_traits< T >::type; - using VariantRetType = typename detail::dbus_interface_return_type_traits< EldbusVariant< T > >::type; - const detail::ConnectionState &connectionState; - std::string propName; - std::string info; - std::shared_ptr< ConnectionInfo > connectionInfo; + using RetType = typename detail::dbus_interface_return_type_traits::type; + using VariantRetType = typename detail::dbus_interface_return_type_traits>::type; + const detail::ConnectionState& connectionState; + std::string propName; + std::string info; + std::shared_ptr connectionInfo; /// \endcond /** @@ -2755,11 +3061,11 @@ public: RetType get() { detail::CallId callId; - detail::displayDebugCallInfoProperty( callId, "Get", info, connectionInfo->interfaceName, propName ); - auto z = detail::call< VariantRetType >( callId, connectionState, true, "Get", connectionInfo->interfaceName, propName ); - if( !z ) + detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName); + auto z = detail::call(callId, connectionState, true, "Get", connectionInfo->interfaceName, propName); + if(!z) return z.getError(); - return {std::get< 0 >( z.getValues() ).value}; + return {std::get<0>(z.getValues()).value}; } /** @@ -2769,17 +3075,17 @@ public: * * @param callback callback functor, which will be called with return value(s) or error message */ - void asyncGet( std::function< void( RetType ) > callback ) + void asyncGet(std::function callback) { detail::CallId callId; - detail::displayDebugCallInfoProperty( callId, "Get", info, connectionInfo->interfaceName, propName ); - auto cc = [callback]( VariantRetType reply ) { - if( reply ) - callback( std::move( std::get< 0 >( reply.getValues() ).value ) ); + detail::displayDebugCallInfoProperty(callId, "Get", info, connectionInfo->interfaceName, propName); + auto cc = [callback](VariantRetType reply) { + if(reply) + callback(std::move(std::get<0>(reply.getValues()).value)); else - callback( reply.getError() ); + callback(reply.getError()); }; - detail::asyncCall< VariantRetType >( callId, connectionState, true, "Get", std::move( cc ), connectionInfo->interfaceName, propName ); + detail::asyncCall(callId, connectionState, true, "Get", std::move(cc), connectionInfo->interfaceName, propName); } /** @@ -2788,12 +3094,12 @@ public: * The function returns ValueOrError object, with * possible error message. */ - ValueOrError< void > set( const T& r ) + ValueOrError set(const T& r) { detail::CallId callId; - detail::displayDebugCallInfoProperty( callId, "Set", info, connectionInfo->interfaceName, propName ); - EldbusVariant< T > variantValue{std::move( r )}; - return detail::call< ValueOrError< void > >( callId, connectionState, true, "Set", connectionInfo->interfaceName, propName, variantValue ); + detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName); + EldbusVariant variantValue{std::move(r)}; + return detail::call>(callId, connectionState, true, "Set", connectionInfo->interfaceName, propName, variantValue); } /** @@ -2803,12 +3109,12 @@ public: * * @param callback callback functor, which will be called with return value(s) or error message */ - void asyncSet( std::function< void( ValueOrError< void > ) > callback, const T& r ) + void asyncSet(std::function)> callback, const T& r) { detail::CallId callId; - detail::displayDebugCallInfoProperty( callId, "Set", info, connectionInfo->interfaceName, propName ); - EldbusVariant< T > variantValue{std::move( r )}; - detail::asyncCall< ValueOrError< void > >( callId, connectionState, true, "Set", std::move( callback ), connectionInfo->interfaceName, propName, variantValue ); + detail::displayDebugCallInfoProperty(callId, "Set", info, connectionInfo->interfaceName, propName); + EldbusVariant variantValue{std::move(r)}; + detail::asyncCall>(callId, connectionState, true, "Set", std::move(callback), connectionInfo->interfaceName, propName, variantValue); } }; @@ -2819,10 +3125,10 @@ public: * * @param propName property name to set and / or query */ - template < typename PropertyType > - Property< PropertyType > property( std::string propName ) + template + Property property(std::string propName) { - return Property< PropertyType >{*connectionState, std::move( propName ), info, connectionInfo}; + return Property{*connectionState, std::move(propName), info, connectionInfo}; } /** @@ -2832,10 +3138,10 @@ public: * * @param funcName function name to call */ - template < typename MethodType > - Method< MethodType > method( std::string funcName ) + template + Method method(std::string funcName) { - return Method< MethodType >{*connectionState, std::move( funcName ), info, connectionInfo}; + return Method{*connectionState, std::move(funcName), info, connectionInfo}; } /** @@ -2845,22 +3151,21 @@ public: * Note, that template type V must match expected type, otherwise undefined behavior will occur, * there's no check for this. */ - template < typename V > - void addPropertyChangedEvent( std::string propertyName, std::function< void( V ) > callback ) + template + void addPropertyChangedEvent(std::string propertyName, std::function callback) { detail::CallId callId; - detail::displayDebugCallInfoSignal( callId, propertyName, info, connectionInfo->interfaceName ); - DBUS_DEBUG( "call %d: adding property", callId.id ); - auto &cI = this->connectionInfo; - DBUS_W->add_property_changed_event_listener_impl(connectionState->proxy, cI->interfaceName, propertyName, - [callback]( const _Eina_Value *newValue ) { + detail::displayDebugCallInfoSignal(callId, propertyName, info, connectionInfo->interfaceName); + DBUS_DEBUG("call %d: adding property", callId.id); + auto& cI = this->connectionInfo; + DBUS_W->add_property_changed_event_listener_impl(connectionState->proxy, cI->interfaceName, propertyName, [callback](const _Eina_Value* newValue) { V val = 0; - if( !getFromEinaValue( newValue, &val ) ) + if(!getFromEinaValue(newValue, &val)) { - DBUS_DEBUG( "unable to get property's value" ); + DBUS_DEBUG("unable to get property's value"); return; } - callback( val ); + callback(val); }); } @@ -2874,46 +3179,45 @@ public: * @param signalName name of the signal to register * @param callback callback to call */ - template < typename SignalType > - void addSignal( std::string signalName, std::function< SignalType > callback ) + template + void addSignal(std::string signalName, std::function callback) { detail::CallId callId; - detail::displayDebugCallInfoSignal( callId, signalName, info, connectionInfo->interfaceName ); - DBUS_W->eldbus_proxy_signal_handler_add_impl( connectionState->proxy, signalName, - [callId, callback, signalName]( const DBusWrapper::MessagePtr &msg ) -> void { - std::string errname, aux; - if( DBUS_W->eldbus_message_error_get_impl( msg, errname, aux ) ) - { - DBUS_DEBUG( "call %d: Eldbus error: %s %s", callId.id, errname.c_str(), aux.c_str() ); - return; - } - DBUS_DEBUG( "call %d: received signal with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl( msg ).c_str() ); - using ParamsType = typename detail::dbus_interface_traits< SignalType >::VEArgs; - auto params = detail::unpackValues< ParamsType >( callId, msg ); - if( !params ) - { - DBUS_DEBUG( "call %d: failed: %s", callId.id, params.getError().message.c_str() ); - return; - } - try - { - detail::apply( callback, params.getValues() ); - } - catch( ... ) - { - DBUS_DEBUG( "unhandled exception" ); - bart_assert( 0 ); - } - }); + detail::displayDebugCallInfoSignal(callId, signalName, info, connectionInfo->interfaceName); + DBUS_W->eldbus_proxy_signal_handler_add_impl(connectionState->proxy, signalName, [callId, callback, signalName](const DBusWrapper::MessagePtr& msg) -> void { + std::string errname, aux; + if(DBUS_W->eldbus_message_error_get_impl(msg, errname, aux)) + { + DBUS_DEBUG("call %d: Eldbus error: %s %s", callId.id, errname.c_str(), aux.c_str()); + return; + } + DBUS_DEBUG("call %d: received signal with signature '%s'", callId.id, DBUS_W->eldbus_message_signature_get_impl(msg).c_str()); + using ParamsType = typename detail::dbus_interface_traits::VEArgs; + auto params = detail::unpackValues(callId, msg); + if(!params) + { + DBUS_DEBUG("call %d: failed: %s", callId.id, params.getError().message.c_str()); + return; + } + try + { + detail::apply(callback, params.getValues()); + } + catch(...) + { + DBUS_DEBUG("unhandled exception"); + bart_assert(0); + } + }); } private: /// \cond - std::unique_ptr connectionState{ new detail::ConnectionState }; - std::string info; - std::shared_ptr< ConnectionInfo > connectionInfo; + std::unique_ptr connectionState{new detail::ConnectionState}; + std::string info; + std::shared_ptr connectionInfo; - static bool getFromEinaValue(const _Eina_Value *v, void *dst); + static bool getFromEinaValue(const _Eina_Value* v, void* dst); /// \endcond }; @@ -2927,10 +3231,10 @@ class DBusInterfaceDescription public: /// \cond - using MethodInfo = DBusWrapper::MethodInfo; - using SignalInfo = DBusWrapper::SignalInfo; + using MethodInfo = DBusWrapper::MethodInfo; + using SignalInfo = DBusWrapper::SignalInfo; using PropertyInfo = DBusWrapper::PropertyInfo; - using SignalId = DBusWrapper::SignalId; + using SignalId = DBusWrapper::SignalId; /// \endcond /** @@ -2938,7 +3242,7 @@ public: * * @param interfaceName name of the interface */ - DBusInterfaceDescription( std::string interfaceName ); + DBusInterfaceDescription(std::string interfaceName); /** * @brief adds new, synchronous method to the interface @@ -2958,21 +3262,19 @@ public: * @param memberName name of the method * @param callback functor, which will be called */ - template < typename T > - void addMethod( const std::string& memberName, typename detail::dbus_interface_traits< T >::SyncCB callback ) + template + void addMethod(const std::string& memberName, typename detail::dbus_interface_traits::SyncCB callback) { detail::CallId callId; - MethodInfo mi; - methods.push_back( std::move( mi ) ); - auto& z = methods.back(); - z.in = detail::EldbusArgGenerator_Args< T >::get( ); - z.out = detail::EldbusArgGenerator_ReturnType< T >::get( ); + MethodInfo mi; + methods.push_back(std::move(mi)); + auto& z = methods.back(); + z.in = detail::EldbusArgGenerator_Args::get(); + z.out = detail::EldbusArgGenerator_ReturnType::get(); z.memberName = memberName; - DBUS_DEBUG( "call %d: method %s, in %s, out %s", callId.id, memberName.c_str(), - detail::EldbusArgGenerator_Args< T >::name().c_str(), - detail::EldbusArgGenerator_ReturnType< T >::name().c_str() ); - z.callback = construct< T >( callId, callback ); - z.id = callId; + DBUS_DEBUG("call %d: method %s, in %s, out %s", callId.id, memberName.c_str(), detail::EldbusArgGenerator_Args::name().c_str(), detail::EldbusArgGenerator_ReturnType::name().c_str()); + z.callback = construct(callId, callback); + z.id = callId; } /** @@ -2991,75 +3293,74 @@ public: * @param getter functor, which will be called when property is being read * @param setter functor, which will be called when property is being set */ - template < typename T > - void addProperty( const std::string& memberName, std::function< ValueOrError< T >() > getter, std::function< ValueOrError< void >( T ) > setter ) + template + void addProperty(const std::string& memberName, std::function()> getter, std::function(T)> setter) { - properties.push_back( {} ); - auto& z = properties.back(); - z.memberName = memberName; - z.typeSignature = detail::signature< T >::sig(); - if( getter ) + properties.push_back({}); + auto& z = properties.back(); + z.memberName = memberName; + z.typeSignature = detail::signature::sig(); + if(getter) { detail::CallId getterId; z.getterId = getterId; - DBUS_DEBUG( "call %d: property %s (get) type %s", getterId.id, memberName.c_str(), detail::signature< T >::name().c_str() ); - z.getCallback = [=]( const DBusWrapper::MessagePtr &src, const DBusWrapper::MessageIterPtr &dst ) -> std::string { + DBUS_DEBUG("call %d: property %s (get) type %s", getterId.id, memberName.c_str(), detail::signature::name().c_str()); + z.getCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& dst) -> std::string { try { - auto v = detail::apply( getter, std::tuple<>{} ); - if( v ) + auto v = detail::apply(getter, std::tuple<>{}); + if(v) { - detail::signature< T >::set( dst, std::get< 0 >( v.getValues() ) ); - DBUS_DEBUG( "call %d: success", getterId.id ); + detail::signature::set(dst, std::get<0>(v.getValues())); + DBUS_DEBUG("call %d: success", getterId.id); return ""; } - DBUS_DEBUG( "call %d: failed: %s", getterId.id, v.getError().message.c_str() ); + DBUS_DEBUG("call %d: failed: %s", getterId.id, v.getError().message.c_str()); return v.getError().message; } - catch( std::exception& e ) + catch(std::exception& e) { - return std::string( "unhandled exception (" ) + e.what() + ")"; + return std::string("unhandled exception (") + e.what() + ")"; } - catch( ... ) + catch(...) { return "unhandled exception"; } }; } - if( setter ) + if(setter) { detail::CallId setterId; z.setterId = setterId; - DBUS_DEBUG( "call %d: property %s (set) type %s", setterId.id, memberName.c_str(), detail::signature< T >::name().c_str() ); - z.setCallback = [=]( const DBusWrapper::MessagePtr &src, const DBusWrapper::MessageIterPtr &src_iter ) -> std::string { - std::tuple< T > value; - auto src_signature = DBUS_W->eldbus_message_iter_signature_get_impl( src_iter ); - if( detail::signature< T >::get( src_iter, std::get< 0 >( value ) ) ) + DBUS_DEBUG("call %d: property %s (set) type %s", setterId.id, memberName.c_str(), detail::signature::name().c_str()); + z.setCallback = [=](const DBusWrapper::MessagePtr& src, const DBusWrapper::MessageIterPtr& src_iter) -> std::string { + std::tuple value; + auto src_signature = DBUS_W->eldbus_message_iter_signature_get_impl(src_iter); + if(detail::signature::get(src_iter, std::get<0>(value))) { try { - auto v = detail::apply( setter, std::move( value ) ); - if( v ) + auto v = detail::apply(setter, std::move(value)); + if(v) { - DBUS_DEBUG( "call %d: success", setterId.id ); + DBUS_DEBUG("call %d: success", setterId.id); return ""; } - DBUS_DEBUG( "call %d: failed: %s", setterId.id, v.getError().message.c_str() ); + DBUS_DEBUG("call %d: failed: %s", setterId.id, v.getError().message.c_str()); return v.getError().message; } - catch( std::exception& e ) + catch(std::exception& e) { - return std::string( "unhandled exception (" ) + e.what() + ")"; + return std::string("unhandled exception (") + e.what() + ")"; } - catch( ... ) + catch(...) { return "unhandled exception"; } } - DBUS_DEBUG( "call %d: failed to unpack values, got signature '%s', expected '%s'", setterId.id, - src_signature.c_str(), detail::signature< T >::sig().c_str() ); - return "call " + std::to_string( setterId.id ) + ": failed to unpack values, got signature '" + - src_signature + "', expected '" + detail::signature< T >::sig() + "'"; + DBUS_DEBUG("call %d: failed to unpack values, got signature '%s', expected '%s'", setterId.id, src_signature.c_str(), detail::signature::sig().c_str()); + return "call " + std::to_string(setterId.id) + ": failed to unpack values, got signature '" + + src_signature + "', expected '" + detail::signature::sig() + "'"; }; } } @@ -3071,71 +3372,71 @@ public: * * @param memberName name of the method */ - template < typename... ARGS > - SignalId addSignal( const std::string& memberName ) + template + SignalId addSignal(const std::string& memberName) { detail::CallId callId; - signals.push_back( {} ); - auto& z = signals.back(); + signals.push_back({}); + auto& z = signals.back(); z.memberName = memberName; - z.args = detail::EldbusArgGenerator_Args< void( ARGS... ) >::get( DBUS_W->Strings ); - z.id = callId; - DBUS_DEBUG( "call %d: signal %s", callId.id, memberName.c_str() ); + z.args = detail::EldbusArgGenerator_Args::get(DBUS_W->Strings); + z.id = callId; + DBUS_DEBUG("call %d: signal %s", callId.id, memberName.c_str()); return SignalId{callId}; } private: /// \cond - std::vector< MethodInfo > methods; - std::vector< PropertyInfo > properties; - std::vector< SignalInfo > signals; - std::string interfaceName; - - template < typename T > - std::function< DBusWrapper::MessagePtr( const DBusWrapper::MessagePtr &msg ) > construct( detail::CallId callId, - typename detail::dbus_interface_traits< T >::SyncCB callback ) - { - using VEArgs = typename detail::dbus_interface_traits< T >::VEArgs; - return [=]( const DBusWrapper::MessagePtr &msg ) -> DBusWrapper::MessagePtr { - DBUS_DEBUG( "call %d: entering", callId.id ); - DBusWrapper::MessagePtr ret = {}; - auto args = detail::unpackValues< VEArgs >( callId, msg ); - if( args ) + std::vector methods; + std::vector properties; + std::vector signals; + std::string interfaceName; + + template + std::function construct(detail::CallId callId, + typename detail::dbus_interface_traits::SyncCB callback) + { + using VEArgs = typename detail::dbus_interface_traits::VEArgs; + return [=](const DBusWrapper::MessagePtr& msg) -> DBusWrapper::MessagePtr { + DBUS_DEBUG("call %d: entering", callId.id); + DBusWrapper::MessagePtr ret = {}; + auto args = detail::unpackValues(callId, msg); + if(args) { try { - auto v = detail::apply( callback, std::move( args.getValues() ) ); - if( v ) + auto v = detail::apply(callback, std::move(args.getValues())); + if(v) { - DBUS_DEBUG( "call %d: success", callId.id ); - ret = DBUS_W->eldbus_message_method_return_new_impl( msg ); - detail::packValues( callId, ret, v ); + DBUS_DEBUG("call %d: success", callId.id); + ret = DBUS_W->eldbus_message_method_return_new_impl(msg); + detail::packValues(callId, ret, v); } else { - DBUS_DEBUG( "call %d: failed: %s", callId.id, v.getError().message.c_str() ); - ret = DBUS_W->eldbus_message_error_new_impl( msg, "org.freedesktop.DBus.Error.Failed", v.getError().message ); + DBUS_DEBUG("call %d: failed: %s", callId.id, v.getError().message.c_str()); + ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", v.getError().message); } } - catch( std::exception& e ) + catch(std::exception& e) { - auto txt = std::string( "unhandled exception (" ) + e.what() + ")"; - DBUS_DEBUG( "call %d: failed: %s", callId.id, txt.c_str() ); - ret = DBUS_W->eldbus_message_error_new_impl( msg, "org.freedesktop.DBus.Error.Failed", txt ); + auto txt = std::string("unhandled exception (") + e.what() + ")"; + DBUS_DEBUG("call %d: failed: %s", callId.id, txt.c_str()); + ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", txt); } - catch( ... ) + catch(...) { - DBUS_DEBUG( "call %d: failed: %s", callId.id, "unhandled exception" ); - ret = DBUS_W->eldbus_message_error_new_impl( msg, "org.freedesktop.DBus.Error.Failed", "unhandled exception" ); + DBUS_DEBUG("call %d: failed: %s", callId.id, "unhandled exception"); + ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.Failed", "unhandled exception"); } } else { std::ostringstream err; - err << "expected signature '" << detail::signature< VEArgs >::sig() << "', got '" << DBUS_W->eldbus_message_signature_get_impl( msg ) << "'"; + err << "expected signature '" << detail::signature::sig() << "', got '" << DBUS_W->eldbus_message_signature_get_impl(msg) << "'"; auto str = err.str(); - DBUS_DEBUG( "call %d: failed: %s", callId.id, str.c_str() ); - ret = DBUS_W->eldbus_message_error_new_impl( msg, "org.freedesktop.DBus.Error.InvalidArgs", str ); + DBUS_DEBUG("call %d: failed: %s", callId.id, str.c_str()); + ret = DBUS_W->eldbus_message_error_new_impl(msg, "org.freedesktop.DBus.Error.InvalidArgs", str); } return ret; }; @@ -3161,12 +3462,12 @@ public: /** * @brief Constructs dbus server on either system or user dbus connection. */ - DBusServer( ConnectionType tp ); + DBusServer(ConnectionType tp); /** * @brief Constructs dbus server on connection from getDBusConnectionByType */ - DBusServer( const DBusWrapper::ConnectionPtr &conn ); + DBusServer(const DBusWrapper::ConnectionPtr& conn); /** * @brief Destructor @@ -3176,11 +3477,11 @@ public: */ ~DBusServer() = default; - DBusServer( const DBusServer& ) = delete; - DBusServer( DBusServer&& ) = default; + DBusServer(const DBusServer&) = delete; + DBusServer(DBusServer&&) = default; - DBusServer& operator=( DBusServer&& ) = default; - DBusServer& operator=( const DBusServer& ) = delete; + DBusServer& operator=(DBusServer&&) = default; + DBusServer& operator=(const DBusServer&) = delete; /** * @brief Registers interface on given path name @@ -3189,7 +3490,7 @@ public: * @param dscr * @param fallback */ - void addInterface( const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback = false ); + void addInterface(const std::string& pathName, DBusInterfaceDescription& dscr, bool fallback = false); /** * @brief Gets bus name of the current connection (must be connected) @@ -3211,14 +3512,13 @@ public: * @param signal identifier of the signal * @param args values to emit */ - template < typename... ARGS > - void emit2( const std::string& path, const std::string& interfaceName, - const std::string& signalName, const ARGS&... args ) + template + void emit2(const std::string& path, const std::string& interfaceName, const std::string& signalName, const ARGS&... args) { - auto msg = DBUS_W->eldbus_message_signal_new_impl( path, interfaceName, signalName ); + auto msg = DBUS_W->eldbus_message_signal_new_impl(path, interfaceName, signalName); detail::CallId id; - detail::packValues( id, msg, args... ); - DBUS_W->eldbus_connection_send_impl( connection, msg ); + detail::packValues(id, msg, args...); + DBUS_W->eldbus_connection_send_impl(connection, msg); } /** @@ -3242,7 +3542,10 @@ public: * }; * \endcode */ - static std::string getCurrentObjectPath() { return currentObjectPath; } + static std::string getCurrentObjectPath() + { + return currentObjectPath; + } /** * @brief Returns current connection object, when handling call to property / method @@ -3265,68 +3568,73 @@ public: * }; * \endcode */ - static const DBusWrapper::ConnectionPtr &getCurrentConnection() { return currentConnection; } + static const DBusWrapper::ConnectionPtr& getCurrentConnection() + { + return currentConnection; + } /// \cond class CurrentObjectSetter { public: - CurrentObjectSetter( DBusWrapper::ConnectionPtr con, std::string path ) + CurrentObjectSetter(DBusWrapper::ConnectionPtr con, std::string path) { currentObjectPath = std::move(path); - currentConnection = std::move( con ); + currentConnection = std::move(con); } ~CurrentObjectSetter() { currentObjectPath = ""; currentConnection = {}; } - CurrentObjectSetter( const CurrentObjectSetter& ) = delete; - CurrentObjectSetter( CurrentObjectSetter&& ) = delete; - void operator=( const CurrentObjectSetter& ) = delete; - void operator=( CurrentObjectSetter&& ) = delete; + CurrentObjectSetter(const CurrentObjectSetter&) = delete; + CurrentObjectSetter(CurrentObjectSetter&&) = delete; + void operator=(const CurrentObjectSetter&) = delete; + void operator=(CurrentObjectSetter&&) = delete; }; /// \endcond private: /// \cond DBusWrapper::ConnectionPtr connection; - struct DestructorObject { + struct DestructorObject + { std::vector> destructors; - ~DestructorObject() { - for(auto &a : destructors) a(); + ~DestructorObject() + { + for(auto& a : destructors) a(); } }; - std::unique_ptr destructorObject { new DestructorObject() }; - static thread_local std::string currentObjectPath; + std::unique_ptr destructorObject{new DestructorObject()}; + static thread_local std::string currentObjectPath; static thread_local DBusWrapper::ConnectionPtr currentConnection; /// \endcond }; /// \cond -DBusWrapper::ConnectionPtr getDBusConnectionByType( ConnectionType tp ); -DBusWrapper::ConnectionPtr getDBusConnectionByName( const std::string& name ); -std::string getConnectionName( const DBusWrapper::ConnectionPtr& ); +DBusWrapper::ConnectionPtr getDBusConnectionByType(ConnectionType tp); +DBusWrapper::ConnectionPtr getDBusConnectionByName(const std::string& name); +std::string getConnectionName(const DBusWrapper::ConnectionPtr&); /// \endcond -} +} // namespace DBus /// \cond namespace std { -template < size_t INDEX, typename... ARGS > -inline auto get( DBus::ValueOrError< ARGS... >& v ) -> decltype( std::get< INDEX >( v.getValues() ) ) & +template +inline auto get(DBus::ValueOrError& v) -> decltype(std::get(v.getValues()))& { - return std::get< INDEX >( v.getValues() ); + return std::get(v.getValues()); } -template < size_t INDEX, typename... ARGS > -inline auto get( const DBus::ValueOrError< ARGS... >& v ) -> decltype( std::get< INDEX >( v.getValues() ) ) +template +inline auto get(const DBus::ValueOrError& v) -> decltype(std::get(v.getValues())) { - return std::get< INDEX >( v.getValues() ); -} + return std::get(v.getValues()); } +} // namespace std /// \endcond #endif // DALI_INTERNAL_ACCESSIBILITY_BRIDGE_DBUS_H diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp index ca03384207..44b66c950b 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Accessibility-Controls-BridgeUp.cpp @@ -1955,5 +1955,82 @@ int UtcDaliEmitAccessibilityStateChanged(void) DALI_TEST_CHECK(Dali::Accessibility::TestStateChangedResult("showing", 1)); DALI_TEST_CHECK(Accessibility::Bridge::GetCurrentBridge()->GetDefaultLabel(rootAccessible) != buttonAccessible); + Dali::Accessibility::TestEnableSC(false); + + END_TEST; +} + +int UtcDaliAccessibleRemovalOnActorDestoyed(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC(true); + + auto layer = Layer::New(); + + auto control = Control::New(); + + std::weak_ptr layerAccessible = Accessibility::Accessible::GetOwningPtr(layer); // AdaptorAccessible + std::weak_ptr controlAccessible = Accessibility::Accessible::GetOwningPtr(control); // ControlAccessible + DALI_TEST_CHECK(layerAccessible.lock()); + DALI_TEST_CHECK(controlAccessible.lock()); + + // Test Getting already added accessible from the map + DALI_TEST_CHECK(!layerAccessible.expired()); + DALI_TEST_CHECK(!controlAccessible.expired()); + DALI_TEST_CHECK(Accessibility::Accessible::Get(layer) == layerAccessible.lock().get()); + DALI_TEST_CHECK(Accessibility::Accessible::Get(control) == controlAccessible.lock().get()); + + // Test ControlAccessible Removal + control.Reset(); + DALI_TEST_CHECK(controlAccessible.expired()); + DALI_TEST_CHECK(Accessibility::Accessible::Get(control) == nullptr); + + // Test AdaptorAccessible Removal + layer.Reset(); + DALI_TEST_CHECK(layerAccessible.expired()); + DALI_TEST_CHECK(Accessibility::Accessible::Get(layer) == nullptr); + + Dali::Accessibility::TestEnableSC(false); + + END_TEST; +} + +int UtcDaliIncludeHidden(void) +{ + ToolkitTestApplication application; + + Dali::Accessibility::TestEnableSC(true); + + auto root = Layer::New(); + auto control = Control::New(); + auto hiddenControl = Control::New(); + hiddenControl.SetProperty(DevelControl::Property::ACCESSIBILITY_HIDDEN, true); + + application.GetScene().Add(root); + root.Add(control); + root.Add(hiddenControl); + + auto appAccessible = Accessibility::Bridge::GetCurrentBridge()->GetApplication(); + DALI_TEST_CHECK(appAccessible); + + auto rootAccessible = Accessibility::Accessible::Get(root); + DALI_TEST_CHECK(rootAccessible); + + auto appAddress = appAccessible->GetAddress(); + + DALI_TEST_CHECK(!TestGetIncludeHidden(appAddress)); + DALI_TEST_CHECK(rootAccessible->GetChildCount() == 1); // hidden control is excluded by default + + TestSetIncludeHidden(appAddress, true); + DALI_TEST_CHECK(TestGetIncludeHidden(appAddress)); + DALI_TEST_CHECK(rootAccessible->GetChildCount() == 2); // hidden control is included after setting includeHidden to true + + TestSetIncludeHidden(appAddress, false); + DALI_TEST_CHECK(!TestGetIncludeHidden(appAddress)); + DALI_TEST_CHECK(rootAccessible->GetChildCount() == 1); // hidden control is excluded after setting includeHidden to false + + Dali::Accessibility::TestEnableSC(false); + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp index 07b1013af9..3d2d040e1d 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-test-application.cpp @@ -52,7 +52,6 @@ ToolkitTestApplication::ToolkitTestApplication(size_t surfaceWidth, size_t surfa // Core needs to be initialized next before we start the adaptor InitializeCore(); - Accessibility::Accessible::SetObjectRegistry(mCore->GetObjectRegistry()); // This will also emit the window created signals AdaptorImpl::GetImpl(*mAdaptor).Start(*mMainWindow); diff --git a/dali-toolkit/devel-api/controls/control-devel.cpp b/dali-toolkit/devel-api/controls/control-devel.cpp index d80f3d95c4..07418d437a 100644 --- a/dali-toolkit/devel-api/controls/control-devel.cpp +++ b/dali-toolkit/devel-api/controls/control-devel.cpp @@ -39,14 +39,14 @@ Dali::Toolkit::Internal::Control::Impl& GetControlImplementation(Dali::Toolkit:: Dali::Toolkit::DevelControl::ControlAccessible* GetControlAccessible(Dali::Toolkit::Control control) { - auto* controlAccessible = GetControlImplementation(control).GetAccessibleObject(); + auto controlAccessible = GetControlImplementation(control).GetAccessibleObject(); if(DALI_UNLIKELY(!controlAccessible)) { DALI_LOG_ERROR("Accessibility API used on Control without an Accessible"); } - return controlAccessible; + return controlAccessible.get(); } } // unnamed namespace @@ -294,7 +294,7 @@ Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType(Toolkit::C bool ClearAccessibilityHighlight(Toolkit::Control control) { - auto* controlAccessible = GetControlAccessible(control); + auto controlAccessible = GetControlImplementation(control).GetAccessibleObject(); if(DALI_LIKELY(controlAccessible)) { return controlAccessible->ClearHighlight(); @@ -304,7 +304,7 @@ bool ClearAccessibilityHighlight(Toolkit::Control control) bool GrabAccessibilityHighlight(Toolkit::Control control) { - auto* controlAccessible = GetControlAccessible(control); + auto controlAccessible = GetControlImplementation(control).GetAccessibleObject(); if(DALI_LIKELY(controlAccessible)) { return controlAccessible->GrabHighlight(); @@ -314,7 +314,7 @@ bool GrabAccessibilityHighlight(Toolkit::Control control) Dali::Accessibility::States GetAccessibilityStates(Toolkit::Control control) { - auto* controlAccessible = GetControlAccessible(control); + auto controlAccessible = GetControlImplementation(control).GetAccessibleObject(); if(DALI_LIKELY(controlAccessible)) { return controlAccessible->GetStates(); @@ -324,7 +324,7 @@ Dali::Accessibility::States GetAccessibilityStates(Toolkit::Control control) void NotifyAccessibilityStateChange(Toolkit::Control control, Dali::Accessibility::States states, bool recurse) { - auto* controlAccessible = GetControlAccessible(control); + auto controlAccessible = GetControlImplementation(control).GetAccessibleObject(); if(DALI_LIKELY(controlAccessible)) { controlAccessible->NotifyAccessibilityStateChange(std::move(states), recurse); @@ -348,7 +348,7 @@ bool IsCreateAccessibleEnabled(Toolkit::Control control) void EmitAccessibilityStateChanged(Dali::Actor actor, Accessibility::State state, int newValue) { - auto accessible = Accessibility::Accessible::Get(actor); + auto accessible = Accessibility::Accessible::GetOwningPtr(actor); if(DALI_LIKELY(accessible)) { auto control = Toolkit::Control::DownCast(actor); diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index 574ef08081..89a0ee0908 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ void CheckBoxButton::OnStateChange(State newState) // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - auto* accessible = GetAccessibleObject(); + auto accessible = GetAccessibleObject(); if(DALI_LIKELY(accessible)) { accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index dea0ee0393..00b45462f4 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -209,7 +209,7 @@ void PushButton::OnStateChange(State newState) // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - auto* accessible = GetAccessibleObject(); + auto accessible = GetAccessibleObject(); if(DALI_LIKELY(accessible)) { accessible->EmitStateChanged(Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0); diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp index 9aace1a7d7..1aef5f0b9b 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp @@ -109,7 +109,7 @@ void RadioButton::OnStateChange(State newState) // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - auto* accessible = GetAccessibleObject(); + auto accessible = GetAccessibleObject(); if(DALI_LIKELY(accessible)) { accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp index de6cbceb4f..3c08e30499 100644 --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp @@ -404,7 +404,7 @@ void ToggleButton::OnStateChange(State newState) // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used if((Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - auto* accessible = GetAccessibleObject(); + auto accessible = GetAccessibleObject(); if(DALI_LIKELY(accessible)) { accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, mCurrentToggleIndex ? 1 : 0, 0); diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index ecb16e25b2..32e5814928 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -507,19 +507,6 @@ static bool IsShowingGeometryOnScreen(Dali::Rect<> rect) return rect.width > 0 && rect.height > 0; } -Dali::Accessibility::Accessible* ExternalAccessibleGetter(Dali::Actor actor) -{ - auto control = Toolkit::Control::DownCast(actor); - if(!control) - { - return nullptr; - } - - auto& controlImpl = Toolkit::Internal::GetImplementation(control); - - return controlImpl.GetAccessibleObject(); -} - } // unnamed namespace // clang-format off @@ -591,7 +578,21 @@ Control::Impl::Impl(Control& controlImpl) mNeedToEmitResourceReady(false), mDispatchKeyEvents(true) { - Dali::Accessibility::Accessible::RegisterExternalAccessibleGetter(&ExternalAccessibleGetter); + Accessibility::Accessible::RegisterExternalAccessibleGetter([](Dali::Actor actor) -> std::pair, bool> { + auto control = Toolkit::Control::DownCast(actor); + if(!control) + { + return {nullptr, true}; + } + + auto& controlImpl = Toolkit::Internal::GetImplementation(control); + if(controlImpl.mImpl->IsCreateAccessibleEnabled()) + { + return {std::shared_ptr(controlImpl.CreateAccessibleObject()), true}; + } + + return {nullptr, false}; + }); mAccessibilityProps.states[DevelControl::AccessibilityState::ENABLED] = true; } @@ -634,7 +635,7 @@ void Control::Impl::CheckHighlightedObjectGeometry() { auto lastPosition = accessible->GetLastPosition(); auto accessibleRect = accessible->GetExtents(Dali::Accessibility::CoordinateType::WINDOW); - auto rect = GetShowingGeometry(accessibleRect, accessible); + auto rect = GetShowingGeometry(accessibleRect, accessible.get()); switch(mAccessibilityLastScreenRelativeMoveType) { @@ -1476,7 +1477,7 @@ void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const { controlImpl.mImpl->mAccessibilityProps.isHidden = hidden; - auto* accessible = controlImpl.GetAccessibleObject(); + auto accessible = controlImpl.GetAccessibleObject(); if(DALI_LIKELY(accessible)) { auto* parent = dynamic_cast(accessible->GetParent()); @@ -2178,19 +2179,14 @@ void Control::Impl::OnIdleCallback() mIdleCallback = nullptr; } -Toolkit::DevelControl::ControlAccessible* Control::Impl::GetAccessibleObject() +std::shared_ptr Control::Impl::GetAccessibleObject() { - if(mAccessibleCreatable && !mAccessibleObject) - { - mAccessibleObject.reset(mControlImpl.CreateAccessibleObject()); - } - - return mAccessibleObject.get(); + return std::dynamic_pointer_cast(Accessibility::Accessible::GetOwningPtr(mControlImpl.Self())); } bool Control::Impl::IsAccessibleCreated() const { - return !!mAccessibleObject; + return !!Accessibility::Bridge::GetCurrentBridge()->GetAccessible(mControlImpl.Self()); } void Control::Impl::EnableCreateAccessible(bool enable) diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index edbd0ddbab..c80d7e0d61 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -413,7 +413,7 @@ public: /** * @copydoc Dali::Toolkit::Internal::Control::GetAccessibleObject() */ - Toolkit::DevelControl::ControlAccessible* GetAccessibleObject(); + std::shared_ptr GetAccessibleObject(); /** * @copydoc Dali::Toolkit::DevelControl::IsAccessibleCreated() @@ -566,8 +566,7 @@ public: bool isModal{false}; } mAccessibilityProps; - bool mAccessibleCreatable = true; - std::unique_ptr mAccessibleObject; + bool mAccessibleCreatable = true; // Gesture Detection PinchGestureDetector mPinchGestureDetector; diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 60aaa289a1..c4a6dbabd4 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -173,7 +173,7 @@ void Control::SetResourceReady(bool relayoutRequest) controlDataImpl.ResourceReady(relayoutRequest); } -Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject() +std::shared_ptr Control::GetAccessibleObject() { return mImpl->GetAccessibleObject(); } @@ -513,7 +513,7 @@ void Control::EmitKeyInputFocusSignal(bool focusGained) auto parent = accessible->GetParent(); if(parent && !accessible->GetStates()[Dali::Accessibility::State::MANAGES_DESCENDANTS]) { - parent->EmitActiveDescendantChanged(accessible); + parent->EmitActiveDescendantChanged(accessible.get()); } } } @@ -596,7 +596,7 @@ void Control::OnPropertySet(Property::Index index, const Property::Value& proper } case Actor::Property::VISIBLE: { - auto* accessible = GetAccessibleObject(); + auto accessible = GetAccessibleObject(); if(DALI_LIKELY(accessible)) { accessible->EmitVisible(Self().GetProperty(Actor::Property::VISIBLE)); @@ -606,7 +606,7 @@ void Control::OnPropertySet(Property::Index index, const Property::Value& proper case DevelActor::Property::USER_INTERACTION_ENABLED: { const bool enabled = propertyValue.Get(); - if (!enabled && Self() == Dali::Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor()) + if(!enabled && Self() == Dali::Toolkit::KeyboardFocusManager::Get().GetCurrentFocusActor()) { Dali::Toolkit::KeyboardFocusManager::Get().ClearFocus(); } @@ -750,8 +750,7 @@ void Control::SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callb mImpl->SignalDisconnected(slotObserver, callback); } -void Control::MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap, - Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex) +void Control::MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap, Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex) { sourcePropertyMap.Clear(); destinationPropertyMap.Clear(); @@ -770,8 +769,7 @@ void Control::MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali: sourceVisual.CreatePropertyMap(sourceMap); destinationVisual.CreatePropertyMap(destinationMap); - static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4 - { + static auto findValueVector4 = [](const Property::Map& map, Property::Index index, const Vector4& defaultValue = Vector4()) -> Vector4 { Property::Value* propertyValue = map.Find(index); if(propertyValue) { @@ -780,8 +778,7 @@ void Control::MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali: return defaultValue; }; - static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float - { + static auto findValueFloat = [](const Property::Map& map, Property::Index index, const float& defaultValue = 0.0f) -> float { Property::Value* propertyValue = map.Find(index); if(propertyValue) { diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index b7d3c2ef68..9e0439e876 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_CONTROL_IMPL_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,6 @@ class ControlAccessible; namespace Internal { - /** * @brief This is the internal base class for all controls. * @@ -132,7 +131,7 @@ public: * * @see CreateAccessibleObject() */ - Toolkit::DevelControl::ControlAccessible* GetAccessibleObject(); + std::shared_ptr GetAccessibleObject(); // Gesture Detection @@ -278,7 +277,6 @@ public: DALI_INTERNAL void KeyboardEnter(); /// @endcond - // Signals /** @@ -407,7 +405,6 @@ protected: // From CustomActorImpl void OnLayoutNegotiated(float size, Dimension::Type dimension) override; public: // Helpers for deriving classes - /** * @brief Flags for the constructor. * @SINCE_1_0.0 @@ -689,8 +686,7 @@ public: // API for derived classes to override * @param[in] destination Destination control of the animation. * @param[in] visualIndex Property::Index to make animation. */ - void MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap, - Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex); + void MakeVisualTransition(Dali::Property::Map& sourcePropertyMap, Dali::Property::Map& destinationPropertyMap, Dali::Toolkit::Control source, Dali::Toolkit::Control destination, Dali::Property::Index visualIndex); /** * @brief Retrieves source and destination visual properties for the Transition of this Control.