16 #ifndef ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_DBUSOBJECT_H_ 17 #define ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_DBUSOBJECT_H_ 21 #include <unordered_map> 26 namespace bluetoothImplementations {
50 using commandHandler_t = void (T::*)(GVariant* parameters, GDBusMethodInvocation* invocation);
63 std::shared_ptr<DBusConnection> connection,
66 std::unordered_map<std::string, commandHandler_t> methodMap) :
67 DBusObjectBase(connection, xmlInterfaceIntrospection, objectPath, &onMethodCallStatic),
68 m_commands{methodMap} {
86 static void onMethodCallStatic(
87 GDBusConnection* conn,
88 const gchar* sender_name,
89 const gchar* object_path,
90 const gchar* interface_name,
91 const gchar* method_name,
93 GDBusMethodInvocation* invocation,
95 auto thisPtr =
static_cast<T*
>(data);
96 thisPtr->onMethodCall(method_name, parameters, invocation);
108 void onMethodCall(
const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation);
111 std::unordered_map<std::string, commandHandler_t> m_commands;
118 auto iter = m_commands.find(method_name);
119 if (iter != m_commands.end()) {
121 (
static_cast<T*
>(
this)->*handler)(parameters, invocation);
123 g_dbus_method_invocation_return_error(
124 invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD,
"Unknown method: ");
132 #endif // ALEXA_CLIENT_SDK_BLUETOOTHIMPLEMENTATIONS_BLUEZ_INCLUDE_BLUEZ_DBUSOBJECT_H_ void onMethodCalledInternal(const char *methodName)
DBusObject(std::shared_ptr< DBusConnection > connection, std::string xmlInterfaceIntrospection, std::string objectPath, std::unordered_map< std::string, commandHandler_t > methodMap)
Definition: DBusObject.h:62
virtual ~DBusObject()=default
::std::string string
Definition: gtest-port.h:1097
Definition: DBusObject.h:41
Definition: DBusObjectBase.h:31
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void(MediaEndpoint ::*)(GVariant *parameters, GDBusMethodInvocation *invocation) commandHandler_t
Definition: DBusObject.h:50