VSM C++ SDK
Vehicle Specific Modules SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
param_setter.h
Go to the documentation of this file.
1 // Copyright (c) 2018, Smart Projects Holdings Ltd
2 // All rights reserved.
3 // See LICENSE file for license details.
4 
11 #ifndef _UGCS_VSM_PARAM_SETTER_H_
12 #define _UGCS_VSM_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 
46 private:
48  std::tuple<typename std::add_lvalue_reference<Params>::type...> params;
49 };
50 
51 } /* namespace param_setter_internal */
52 
60 template <typename... Params>
61 typename Callback<param_setter_internal::Param_setter<Params...>, void, Params...>::Ptr
62 Make_setter(Params &... params)
63 {
65  Params()...);
66 }
67 
68 } /* namespace vsm */
69 } /* namespace ugcs */
70 
71 #endif /* _UGCS_VSM_PARAM_SETTER_H_ */
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:62
Param_setter(Params &...params)
Construct the setter.
Definition: param_setter.h:31