]>
Commit | Line | Data |
---|---|---|
29ddb38f LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #ifndef foosdbusvtablehfoo | |
4 | #define foosdbusvtablehfoo | |
5 | ||
6 | /*** | |
7 | This file is part of systemd. | |
8 | ||
9 | Copyright 2013 Lennart Poettering | |
10 | ||
11 | systemd is free software; you can redistribute it and/or modify it | |
12 | under the terms of the GNU Lesser General Public License as published by | |
13 | the Free Software Foundation; either version 2.1 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | systemd is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | Lesser General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU Lesser General Public License | |
22 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
23 | ***/ | |
24 | ||
0095c454 LP |
25 | #include "_sd-common.h" |
26 | ||
27 | _SD_BEGIN_DECLARATIONS; | |
6695ed7a | 28 | |
29ddb38f LP |
29 | typedef struct sd_bus_vtable sd_bus_vtable; |
30 | ||
31 | #include "sd-bus.h" | |
32 | ||
33 | enum { | |
34 | _SD_BUS_VTABLE_START = '<', | |
35 | _SD_BUS_VTABLE_END = '>', | |
36 | _SD_BUS_VTABLE_METHOD = 'M', | |
37 | _SD_BUS_VTABLE_SIGNAL = 'S', | |
38 | _SD_BUS_VTABLE_PROPERTY = 'P', | |
39 | _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W', | |
40 | _SD_BUS_VTABLE_CHILDREN = 'C' | |
41 | }; | |
42 | ||
43 | enum { | |
44 | SD_BUS_VTABLE_DEPRECATED = 1, | |
45 | SD_BUS_VTABLE_METHOD_NO_REPLY = 2, | |
46 | SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE = 4, | |
47 | SD_BUS_VTABLE_PROPERTY_INVALIDATE_ONLY = 8, | |
48 | }; | |
49 | ||
50 | struct sd_bus_vtable { | |
51 | /* Please do not initialize this structure directly, use the | |
52 | * macros below instead */ | |
53 | ||
54 | int type; | |
55 | int flags; | |
56 | union { | |
57 | struct { | |
58 | size_t element_size; | |
59 | } start; | |
60 | struct { | |
61 | const char *member; | |
62 | const char *signature; | |
63 | const char *result; | |
64 | sd_bus_message_handler_t handler; | |
65 | } method; | |
66 | struct { | |
67 | const char *member; | |
68 | const char *signature; | |
69 | } signal; | |
70 | struct { | |
71 | const char *member; | |
72 | const char *signature; | |
73 | sd_bus_property_get_t get; | |
74 | sd_bus_property_set_t set; | |
75 | size_t offset; | |
76 | } property; | |
77a874a3 | 77 | } x; |
29ddb38f LP |
78 | }; |
79 | ||
80 | #define SD_BUS_VTABLE_START(_flags) \ | |
81 | { \ | |
82 | .type = _SD_BUS_VTABLE_START, \ | |
83 | .flags = _flags, \ | |
77a874a3 | 84 | .x.start.element_size = sizeof(sd_bus_vtable), \ |
29ddb38f LP |
85 | } |
86 | ||
adcdb374 | 87 | #define SD_BUS_METHOD(_member, _signature, _result, _handler, _flags) \ |
29ddb38f LP |
88 | { \ |
89 | .type = _SD_BUS_VTABLE_METHOD, \ | |
90 | .flags = _flags, \ | |
77a874a3 LP |
91 | .x.method.member = _member, \ |
92 | .x.method.signature = _signature, \ | |
93 | .x.method.result = _result, \ | |
94 | .x.method.handler = _handler, \ | |
29ddb38f LP |
95 | } |
96 | ||
97 | #define SD_BUS_SIGNAL(_member, _signature, _flags) \ | |
98 | { \ | |
99 | .type = _SD_BUS_VTABLE_SIGNAL, \ | |
100 | .flags = _flags, \ | |
77a874a3 LP |
101 | .x.signal.member = _member, \ |
102 | .x.signal.signature = _signature, \ | |
29ddb38f LP |
103 | } |
104 | ||
77a874a3 | 105 | #define SD_BUS_PROPERTY(_member, _signature, _get, _offset, _flags) \ |
29ddb38f LP |
106 | { \ |
107 | .type = _SD_BUS_VTABLE_PROPERTY, \ | |
108 | .flags = _flags, \ | |
77a874a3 LP |
109 | .x.property.member = _member, \ |
110 | .x.property.signature = _signature, \ | |
111 | .x.property.get = _get, \ | |
112 | .x.property.offset = _offset, \ | |
29ddb38f LP |
113 | } |
114 | ||
115 | #define SD_BUS_WRITABLE_PROPERTY(_member, _signature, _get, _set, _offset, _flags) \ | |
116 | { \ | |
117 | .type = _SD_BUS_VTABLE_WRITABLE_PROPERTY, \ | |
118 | .flags = _flags, \ | |
77a874a3 LP |
119 | .x.property.member = _member, \ |
120 | .x.property.signature = _signature, \ | |
121 | .x.property.get = _get, \ | |
122 | .x.property.set = _set, \ | |
123 | .x.property.offset = _offset, \ | |
29ddb38f LP |
124 | } |
125 | ||
126 | #define SD_BUS_VTABLE_END \ | |
127 | { \ | |
128 | .type = _SD_BUS_VTABLE_END, \ | |
129 | } | |
130 | ||
0095c454 | 131 | _SD_END_DECLARATIONS; |
6695ed7a | 132 | |
29ddb38f | 133 | #endif |