VSM C++ SDK
Vehicle Specific Modules SDK
param_setter.h
Go to the documentation of this file.
1 // Copyright (c) 2014, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
11 #ifndef PARAM_SETTER_H_
12 #define PARAM_SETTER_H_
13 
14 #include <ugcs/vsm/callback.h>
15 
16 namespace ugcs {
17 namespace vsm {
18 
19 namespace param_setter_internal {
20 
22 template <typename... Params>
23 class Param_setter {
24 public:
31  Param_setter(Params &... params):
32  params(params...)
33  {}
34 
40  void
41  operator ()(Params... values)
42  {
43  params = std::tuple<Params...>(values...);
44  }
45 private:
47  std::tuple<typename std::add_lvalue_reference<Params>::type...> params;
48 };
49 
50 } /* namespace param_setter_internal */
51 
59 template <typename... Params>
60 typename Callback<param_setter_internal::Param_setter<Params...>, void, Params...>::Ptr
61 Make_setter(Params &... params)
62 {
64  Params()...);
65 }
66 
67 } /* namespace vsm */
68 } /* namespace ugcs */
69 
70 #endif /* PARAM_SETTER_H_ */
UGCS root namespace.
Definition: android-linux/ugcs/vsm/platform_sockets.h:27
Generic callback which can be used to define and create an instance of an abstract callable operation...
Callable setter object.
Definition: param_setter.h:23
void operator()(Params...values)
Set values to the linked variables.
Definition: param_setter.h:41
Callback< Callable, void, Args... >::Ptr Make_callback(Callable &&callable, Args &&...args)
Create a callback.
Definition: callback.h:389
Callback< param_setter_internal::Param_setter< Params... >, void, Params... >::Ptr Make_setter(Params &...params)
Make setter callback for provided parameters.
Definition: param_setter.h:61
Param_setter(Params &...params)
Construct the setter.
Definition: param_setter.h:31
Generic callback.
Definition: callback.h:213