1
#ifndef INCLUDED_GENERIC_CONTROLLER_H
2
#define INCLUDED_GENERIC_CONTROLLER_H
4
#include "ctrl-source.h"
5
#include "eca-operator.h"
8
* Generic controller class that connects controller sources
9
* to objects supporting dynamic parameter control (classes
10
* which inherit DYNAMIC_PARAMETERS).
12
* Related design patterns:
13
* - Decorator (GoF175)
15
class GENERIC_CONTROLLER : public CONTROLLER_SOURCE {
19
/** @name Constructors and destructors */
22
GENERIC_CONTROLLER(CONTROLLER_SOURCE* source,
25
double range_low = 0.0,
26
double range_high = 0.0);
28
GENERIC_CONTROLLER* clone(void) const { return(0); }
29
GENERIC_CONTROLLER* new_expr(void) const { return(new GENERIC_CONTROLLER(0)); }
33
/** @name Public functions reimplemented from CONTROLLER_SOURCE */
36
virtual void init(void);
39
* Returns the current value, scale it and
40
* applies it to target objects.
42
* @pre is_valid() == true
44
virtual parameter_t value(double pos_secs);
46
virtual void set_initial_value(parameter_t arg) { }
50
/** @name Public functions reimplemented from ECA_OBJECT */
53
virtual std::string name(void) const { return(source == 0 ? string("") : source->name()); }
57
/** @name Public functions reimplemented from DYNAMIC_PARAMETERS */
60
virtual bool variable_params(void) const { return true; }
61
virtual std::string parameter_names(void) const { return("param-id,range-low,range-high," + source->parameter_names()); }
62
virtual void set_parameter(int param, parameter_t value);
63
virtual parameter_t get_parameter(int param) const;
67
/** @name Public functions */
70
bool is_valid(void) const { return(target != 0 && source != 0); }
71
std::string status(void) const;
73
void assign_target(OPERATOR* obj);
74
void assign_source(CONTROLLER_SOURCE* obj);
76
CONTROLLER_SOURCE* source_pointer(void) const { return(source); }
77
OPERATOR* target_pointer(void) const { return(target); }
84
CONTROLLER_SOURCE* source;
88
double rangelow_rep, rangehigh_rep;
89
double last_value_pos_rep;