26#ifndef SDBUS_CPP_VTABLEITEMS_INL_
27#define SDBUS_CPP_VTABLEITEMS_INL_
42 template <
typename _Function>
45 inputSignature = signature_of_function_input_arguments_v<_Function>;
46 outputSignature = signature_of_function_output_arguments_v<_Function>;
47 callbackHandler = [callback = std::forward<_Function>(callback)](MethodCall call)
51 tuple_of_function_input_arg_types_t<_Function> inputArgs;
56 if constexpr (!is_async_method_v<_Function>)
59 auto ret = sdbus::apply(callback, inputArgs);
62 auto reply = call.createReply();
69 using AsyncResult =
typename function_traits<_Function>::async_result_t;
70 sdbus::apply(callback, AsyncResult{std::move(call)}, std::move(inputArgs));
77 inline MethodVTableItem& MethodVTableItem::withInputParamNames(std::vector<std::string> names)
79 inputParamNames = std::move(names);
84 template <
typename... _String>
85 inline MethodVTableItem& MethodVTableItem::withInputParamNames(_String... names)
87 static_assert(std::conjunction_v<std::is_convertible<_String, std::string>...>,
"Parameter names must be (convertible to) strings");
89 return withInputParamNames({names...});
92 inline MethodVTableItem& MethodVTableItem::withOutputParamNames(std::vector<std::string> names)
94 outputParamNames = std::move(names);
99 template <
typename... _String>
100 inline MethodVTableItem& MethodVTableItem::withOutputParamNames(_String... names)
102 static_assert(std::conjunction_v<std::is_convertible<_String, std::string>...>,
"Parameter names must be (convertible to) strings");
104 return withOutputParamNames({names...});
109 flags.set(Flags::DEPRECATED);
116 flags.set(Flags::PRIVILEGED);
123 flags.set(Flags::METHOD_NO_REPLY);
130 return {std::move(methodName), {}, {}, {}, {}, {}, {}};
135 return registerMethod(MethodName{std::move(methodName)});
142 template <
typename... _Args>
145 signature = signature_of_function_input_arguments_v<void(_Args...)>;
150 template <
typename... _Args>
151 inline SignalVTableItem& SignalVTableItem::withParameters(std::vector<std::string> names)
153 paramNames = std::move(names);
155 return withParameters<_Args...>();
158 template <
typename... _Args,
typename... _String>
161 static_assert(std::conjunction_v<std::is_convertible<_String, std::string>...>,
"Parameter names must be (convertible to) strings");
162 static_assert(
sizeof...(_Args) ==
sizeof...(_String),
"Numbers of signal parameters and their names don't match");
164 return withParameters<_Args...>({names...});
169 flags.set(Flags::DEPRECATED);
176 return {std::move(signalName), {}, {}, {}};
181 return registerSignal(SignalName{std::move(signalName)});
188 template <
typename _Function>
191 static_assert(function_argument_count_v<_Function> == 0,
"Property getter function must not take any arguments");
192 static_assert(!std::is_void<function_result_t<_Function>>::value,
"Property getter function must return property value");
194 if (signature.empty())
195 signature = signature_of_function_output_arguments_v<_Function>;
197 getter = [callback = std::forward<_Function>(callback)](PropertyGetReply& reply)
206 template <
typename _Function>
209 static_assert(function_argument_count_v<_Function> == 1,
"Property setter function must take one parameter - the property value");
210 static_assert(std::is_void<function_result_t<_Function>>::value,
"Property setter function must not return any value");
212 if (signature.empty())
213 signature = signature_of_function_input_arguments_v<_Function>;
215 setter = [callback = std::forward<_Function>(callback)](PropertySetCall call)
218 using property_type = function_argument_t<_Function, 0>;
219 std::decay_t<property_type> property;
233 flags.set(Flags::DEPRECATED);
240 flags.set(Flags::PRIVILEGED);
245 inline PropertyVTableItem& PropertyVTableItem::withUpdateBehavior(Flags::PropertyUpdateBehaviorFlags behavior)
254 return {std::move(propertyName), {}, {}, {}, {}};
259 return registerProperty(PropertyName{std::move(propertyName)});
268 flags.set(Flags::DEPRECATED);
275 flags.set(Flags::PRIVILEGED);
282 flags.set(Flags::METHOD_NO_REPLY);
287 inline InterfaceFlagsVTableItem& InterfaceFlagsVTableItem::withPropertyUpdateBehavior(Flags::PropertyUpdateBehaviorFlags behavior)
Definition VTableItems.h:97
Definition VTableItems.h:40
Definition VTableItems.h:79
Definition VTableItems.h:63