37 template<
class ControlDataType>
45 template<
class ControlDataType>
58 , _callback(new NullCallback)
62 template <
typename ProcessingType,
typename ParameterType>
63 InControl(
const std::string &name, ProcessingType * proc,
void (ProcessingType::*callback)(
const ParameterType&))
65 , _callback(new MethodCallback<ProcessingType,ParameterType>(proc, callback))
69 template <
typename ProcessingType,
typename ParameterType>
70 InControl(
unsigned id,
const std::string &name, ProcessingType * proc,
void (ProcessingType::*callback)(
unsigned,
const ParameterType&))
72 , _callback(new MethodCallbackWithId<ProcessingType,ParameterType>(proc, callback, id))
76 template <
typename ProcessingType,
typename ParameterType>
77 InControl(
const std::string &name, ProcessingType * proc,
void (ProcessingType::*callback)(ParameterType))
79 , _callback(new MethodCallbackByCopy<ProcessingType,ParameterType>(proc, callback))
83 template <
typename ProcessingType,
typename ParameterType>
84 InControl(
unsigned id,
const std::string &name, ProcessingType * proc,
void (ProcessingType::*callback)(
unsigned, ParameterType))
86 , _callback(new MethodCallbackByCopyWithId<ProcessingType,ParameterType>(proc, callback, id))
104 _callback->DoControl(val);
121 virtual const std::type_info&
GetTypeId()
const {
return typeid(ControlDataType); };
125 return "Not printable";
130 std::ostringstream valueStream;
132 return valueStream.str();
139 typedef typename TypeInfo<ControlDataType>::StorableAsLeaf TokenIsStorableAsLeaf;
143 virtual ~Callback() {}
144 virtual void DoControl(
const ControlDataType & val) =0;
148 class NullCallback :
public Callback
151 virtual void DoControl(
const ControlDataType & val) {}
156 template <
typename ProcessingType,
typename ValueParameterType>
157 class MethodCallback :
public Callback
160 ProcessingType * _processing;
161 void (ProcessingType::*_method)(
const ValueParameterType& );
163 MethodCallback(ProcessingType * processing,
void (ProcessingType::*method)(
const ValueParameterType &) )
164 : _processing(processing)
168 virtual void DoControl(
const ControlDataType & value)
170 (_processing->*_method)(value);
178 template <
typename ProcessingType,
typename ValueParameterType>
179 class MethodCallbackWithId :
public Callback
181 ProcessingType * _processing;
182 void (ProcessingType::*_method)(
unsigned,
const ValueParameterType &);
185 MethodCallbackWithId(ProcessingType * processing,
void (ProcessingType::*method)(
unsigned,
const ValueParameterType &),
unsigned id )
186 : _processing(processing)
191 virtual void DoControl(
const ControlDataType & value)
193 (_processing->*_method)(_id, value);
200 template <
typename ProcessingType,
typename ValueParameterType>
201 class MethodCallbackByCopy :
public Callback
204 ProcessingType * _processing;
205 void (ProcessingType::*_method)(ValueParameterType);
207 MethodCallbackByCopy(ProcessingType * processing,
void (ProcessingType::*method)(ValueParameterType) )
208 : _processing(processing)
212 virtual void DoControl(
const ControlDataType & value)
214 (_processing->*_method)(value);
223 template <
typename ProcessingType,
typename ValueParameterType>
224 class MethodCallbackByCopyWithId :
public Callback
226 ProcessingType * _processing;
227 void (ProcessingType::*_method)(
unsigned, ValueParameterType);
230 MethodCallbackByCopyWithId(ProcessingType * processing,
void (ProcessingType::*method)(
unsigned,ValueParameterType),
unsigned id )
231 : _processing(processing)
236 virtual void DoControl(
const ControlDataType & value)
238 (_processing->*_method)(_id, value);