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
2014-07-03 00:28:22 -07:00
|
|
|
#ifndef EFL_EINA_EINA_TUPLE_HH_
|
|
|
|
#define EFL_EINA_EINA_TUPLE_HH_
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
|
2014-09-01 11:08:49 -07:00
|
|
|
#include <eina_integer_sequence.hh>
|
|
|
|
#include <eina_logical.hh>
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
|
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
2014-07-03 00:28:22 -07:00
|
|
|
namespace efl { namespace eina { namespace _mpl {
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
|
|
|
|
template <typename A, typename... Args>
|
|
|
|
struct push_back;
|
|
|
|
|
|
|
|
template <template <typename... Args> class C, typename... Args, typename... AArgs>
|
|
|
|
struct push_back<C<Args...>, AArgs...>
|
|
|
|
{
|
|
|
|
typedef C<Args..., AArgs...> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename A, typename... Args>
|
|
|
|
struct push_front;
|
|
|
|
|
|
|
|
template <template <typename... Args> class C, typename... Args, typename... AArgs>
|
|
|
|
struct push_front<C<Args...>, AArgs...>
|
|
|
|
{
|
|
|
|
typedef C<Args..., AArgs...> type;
|
|
|
|
};
|
|
|
|
|
2014-09-01 11:08:49 -07:00
|
|
|
template <typename A, std::size_t N = 1>
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
struct pop_front;
|
2014-09-01 11:08:49 -07:00
|
|
|
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
template <template <typename...> class C, typename T, typename... Args>
|
2014-09-01 11:08:49 -07:00
|
|
|
struct pop_front<C<T, Args...>, 1>
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
{
|
|
|
|
typedef C<Args...> type;
|
|
|
|
};
|
|
|
|
|
2014-09-01 11:08:49 -07:00
|
|
|
template <typename A, std::size_t N>
|
|
|
|
struct pop_front : pop_front<typename pop_front<A, 1>::type, N-1>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename F, std::size_t... I>
|
|
|
|
void for_each_impl(T&& t, F&& f, eina::index_sequence<I...>)
|
|
|
|
{
|
|
|
|
std::initializer_list<int> l = { (f(std::get<I>(t)), 0)...};
|
|
|
|
static_cast<void>(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename F>
|
|
|
|
void for_each(T&& t, F&& f)
|
|
|
|
{
|
|
|
|
_mpl::for_each_impl(t, f, eina::make_index_sequence
|
|
|
|
<std::tuple_size<typename std::remove_reference<T>::type>::value>());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename Transform>
|
|
|
|
struct tuple_transform;
|
|
|
|
|
|
|
|
template <typename...T, typename Transform>
|
|
|
|
struct tuple_transform<std::tuple<T...>, Transform>
|
|
|
|
{
|
|
|
|
typedef std::tuple<typename Transform::template apply<T>::type...> type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename Tuple>
|
|
|
|
struct tuple_contains;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T, typename...Ts>
|
|
|
|
struct tuple_contains<T, std::tuple<Ts...> >
|
|
|
|
: _mpl::or_<std::is_same<T, Ts>::value...>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename Tuple>
|
|
|
|
struct tuple_find : std::integral_constant<int, -1> {};
|
|
|
|
|
|
|
|
template <typename T, typename... Ts>
|
|
|
|
struct tuple_find<T, std::tuple<T, Ts...> > : std::integral_constant<std::size_t, 0> {};
|
|
|
|
|
|
|
|
template <typename T, typename T1, typename... Ts>
|
|
|
|
struct tuple_find<T, std::tuple<T1, Ts...> > : std::integral_constant
|
|
|
|
<std::size_t, 1 + tuple_find<T, std::tuple<Ts...> >::value> {};
|
|
|
|
|
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
2014-07-03 00:28:22 -07:00
|
|
|
} } }
|
eet-cxx: add implementation for eet C++.
Usage example:
struct type
{
int foo;
float bar;
};
type t0;
auto descriptor = make_descriptor("type", &type::ofo, &type::bar);
eet_data_write(file, descriptor.native_handle(), "type", &t0, false);
std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor);
type t = read(file, "type", descriptor);
@feature
Reviewers: cedric, smohanty
Reviewed By: cedric
CC: savio, cedric
Differential Revision: https://phab.enlightenment.org/D659
Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
2014-04-01 03:08:07 -07:00
|
|
|
|
|
|
|
#endif
|