BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
mixin.hpp
1#ifndef BLUETOE_MIXIN_HPP
2#define BLUETOE_MIXIN_HPP
3
5
6namespace bluetoe {
7 template < typename ... T >
8 struct mixin;
9
10 template < typename ... Options >
11 class server;
12
13 namespace details {
14 struct mixin_meta_type {};
15
16 template < typename MixinList >
17 struct sum_mixins;
18
19 template <>
20 struct sum_mixins< std::tuple<> >
21 {
22 typedef std::tuple<> type;
23 };
24
25 template < typename ... Ts, typename ... Ms >
26 struct sum_mixins< std::tuple< mixin< Ts... >, Ms... > >{
27 typedef typename add_type<
28 std::tuple< Ts... >,
29 typename sum_mixins< std::tuple< Ms... > >::type >::type type;
30 };
31
32 template < typename List, typename Element >
33 struct extract_service_mixins;
34
35 template < typename ... Ms, typename ... Options >
36 struct extract_service_mixins< std::tuple< Ms... >, bluetoe::service< Options... > >
37 {
38 typedef typename find_all_by_meta_type< mixin_meta_type, Options... >::type mixins;
39 typedef typename add_type< mixins, std::tuple< Ms... > >::type type;
40 };
41
42 template < typename ... Ms, typename T >
43 struct extract_service_mixins< std::tuple< Ms... >, T >
44 {
45 typedef std::tuple< Ms... > type;
46 };
47
48 template < typename ... Options >
49 struct collect_mixins
50 {
51 typedef typename find_all_by_meta_type< mixin_meta_type, Options... >::type server_mixins;
52 typedef typename fold< std::tuple< Options ... >, extract_service_mixins >::type service_mixins;
53 typedef typename add_type< server_mixins, service_mixins >::type mixins;
54 typedef typename sum_mixins< mixins >::type type;
55 };
56
57 }
58
77 template < typename ... T >
78 struct mixin {
80 struct meta_type :
81 details::mixin_meta_type,
82 details::valid_service_option_meta_type,
83 details::valid_server_option_meta_type {};
84
86 };
87
88
89}
90#endif
a service with zero or more characteristics
Definition: service.hpp:150
class to be mixed into the server instance
Definition: mixin.hpp:78