-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsr_param_delegate.h
More file actions
36 lines (34 loc) · 1.01 KB
/
sr_param_delegate.h
File metadata and controls
36 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef SR_PARAM_DELEGATE_H_
#define SR_PARAM_DELEGATE_H_
#define SR_PARAM_DELEGATE \
class sr_param_delegate { \
public: \
GC_HAS_CALLBACKS(); \
\
sr_param_delegate(gs::cnf::gs_param_base *orig, std::string name) { \
param = new gs::cnf::gs_param<val_type>(name); \
GC_REGISTER_TYPED_PARAM_CALLBACK(orig, gs::cnf::post_write, sr_param_delegate, callback); \
} \
\
~sr_param_delegate() { \
GC_UNREGISTER_CALLBACKS(); \
delete param; \
} \
\
/* Static power callback */ \
gs::cnf::callback_return_type callback( \
gs::cnf::gs_param_base& changed_param, /* NOLINT(runtime/references) */ \
gs::cnf::callback_type reason) { \
val_type value; \
changed_param.getValue(value); \
param->setValue(value); \
return GC_RETURN_OK; \
} \
\
private: \
gs::cnf::gs_param<val_type> *param; \
}; \
sr_param_delegate *delegate(std::string name) { \
return new sr_param_delegate(this, name); \
}
#endif // SR_PARAM_DELEGATE_H