summaryrefslogtreecommitdiff
path: root/src/lib/eldbus/eldbus_service.h
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-03 16:28:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-07-03 16:28:23 +0900
commit30df128be5dd3d2cea4c976ed5d5c9b85a15aa77 (patch)
tree8fe7a9c6c61677f46e82199075856a45717b4e98 /src/lib/eldbus/eldbus_service.h
parentddac21534f9eaa8bc01f8c72c1bff5926de27bd6 (diff)
eldbus-cxx: Implementation of eldbus C++ API
Summary: Applications can: void method_callback(void* data, const Eldbus_Service_Interface* iface, const Eldbus_Message* message); struct { ... } data_struct; Eldbus_Method methods[] = { "method1", ELDBUS_ARGS("b", "bool"), ELDBUS_ARGS("b", "bool"), ELDBUS_METHOD_FLAG_HAS_DATA , (Eldbus_Method_Cb)&method_callback, &data_struct }; And method_callback will be called with data parameter pointing to data_struct global object. Also, Eldbus-cxx supports registering an interface passing a lambda or function object as method. For example: edb::service_interface iface = edb::service_interface_register (c, path, interface , es::method("SendStringAndBool" , [expected_string, expected_bool] (std::string const& n, bool b , bool* out) { std::cout << "Running SendStringAndBool" << std::endl; ck_assert(n == expected_string); ck_assert(b == expected_bool); *out = b; return n; } , es::ins<std::string, bool>("string", "bool") , es::outs<std::string, bool>("string", "bool") ) ); When a request for "SendStringAndBool" with the proper signature is called, executes the lambda and replies with the return value and its bool* out parameter value. Reviewers: cedric, woohyun, raster CC: savio, cedric Differential Revision: https://phab.enlightenment.org/D1052
Diffstat (limited to 'src/lib/eldbus/eldbus_service.h')
-rw-r--r--src/lib/eldbus/eldbus_service.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/eldbus/eldbus_service.h b/src/lib/eldbus/eldbus_service.h
index e5915dc..fdf272e 100644
--- a/src/lib/eldbus/eldbus_service.h
+++ b/src/lib/eldbus/eldbus_service.h
@@ -9,6 +9,7 @@
9 */ 9 */
10#define ELDBUS_METHOD_FLAG_DEPRECATED 1 10#define ELDBUS_METHOD_FLAG_DEPRECATED 1
11#define ELDBUS_METHOD_FLAG_NOREPLY (1 << 1) 11#define ELDBUS_METHOD_FLAG_NOREPLY (1 << 1)
12#define ELDBUS_METHOD_FLAG_HAS_DATA (1 << 2) // @since 1.1
12 13
13#define ELDBUS_SIGNAL_FLAG_DEPRECATED 1 14#define ELDBUS_SIGNAL_FLAG_DEPRECATED 1
14 15
@@ -32,6 +33,8 @@ typedef struct _Eldbus_Arg_Info
32typedef struct _Eldbus_Service_Interface Eldbus_Service_Interface; 33typedef struct _Eldbus_Service_Interface Eldbus_Service_Interface;
33typedef Eldbus_Message * (*Eldbus_Method_Cb)(const Eldbus_Service_Interface *iface, const Eldbus_Message *message); 34typedef Eldbus_Message * (*Eldbus_Method_Cb)(const Eldbus_Service_Interface *iface, const Eldbus_Message *message);
34 35
36typedef Eldbus_Message * (*Eldbus_Method_Data_Cb)(void* data, const Eldbus_Service_Interface *iface, const Eldbus_Message *message); // @since 1.11
37
35/** 38/**
36 * Callback function to append property value to message. 39 * Callback function to append property value to message.
37 * 40 *
@@ -69,6 +72,7 @@ typedef struct _Eldbus_Method
69 const Eldbus_Arg_Info *out; 72 const Eldbus_Arg_Info *out;
70 Eldbus_Method_Cb cb; 73 Eldbus_Method_Cb cb;
71 unsigned int flags; 74 unsigned int flags;
75 void* data; // @since 1.11
72} Eldbus_Method; 76} Eldbus_Method;
73 77
74typedef struct _Eldbus_Signal 78typedef struct _Eldbus_Signal