~ubuntu-branches/ubuntu/wily/ecasound/wily-proposed

« back to all changes in this revision

Viewing changes to libecasound/generic-controller.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghedini
  • Date: 2011-05-12 17:58:03 UTC
  • Revision ID: james.westby@ubuntu.com-20110512175803-zy3lodjecabt9r3v
Tags: upstream-2.8.0
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef INCLUDED_GENERIC_CONTROLLER_H
 
2
#define INCLUDED_GENERIC_CONTROLLER_H
 
3
 
 
4
#include "ctrl-source.h"
 
5
#include "eca-operator.h"
 
6
 
 
7
/**
 
8
 * Generic controller class that connects controller sources
 
9
 * to objects supporting dynamic parameter control (classes 
 
10
 * which inherit DYNAMIC_PARAMETERS).
 
11
 * 
 
12
 * Related design patterns:
 
13
 *     - Decorator (GoF175)
 
14
 */
 
15
class GENERIC_CONTROLLER : public CONTROLLER_SOURCE {
 
16
 
 
17
 public:
 
18
 
 
19
  /** @name Constructors and destructors */
 
20
  /*@{*/
 
21
 
 
22
  GENERIC_CONTROLLER(CONTROLLER_SOURCE* source,
 
23
                     OPERATOR* dobj = 0, 
 
24
                     int param_id = 0, 
 
25
                     double range_low = 0.0, 
 
26
                     double range_high = 0.0);
 
27
 
 
28
  GENERIC_CONTROLLER* clone(void) const { return(0); }
 
29
  GENERIC_CONTROLLER* new_expr(void) const { return(new GENERIC_CONTROLLER(0)); }
 
30
 
 
31
  /*@}*/
 
32
 
 
33
  /** @name Public functions reimplemented from CONTROLLER_SOURCE */
 
34
  /*@{*/
 
35
 
 
36
  virtual void init(void);
 
37
 
 
38
  /**
 
39
   * Returns the current value, scale it and
 
40
   * applies it to target objects.
 
41
   *
 
42
   * @pre is_valid() == true
 
43
   */
 
44
  virtual parameter_t value(double pos_secs);
 
45
 
 
46
  virtual void set_initial_value(parameter_t arg) { }
 
47
 
 
48
  /*@}*/
 
49
 
 
50
  /** @name Public functions reimplemented from ECA_OBJECT */
 
51
  /*@{*/
 
52
 
 
53
  virtual std::string name(void) const { return(source == 0 ? string("") : source->name()); }
 
54
 
 
55
  /*@}*/
 
56
 
 
57
  /** @name Public functions reimplemented from DYNAMIC_PARAMETERS */
 
58
  /*@{*/
 
59
 
 
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;
 
64
 
 
65
  /*@}*/
 
66
 
 
67
  /** @name Public functions  */
 
68
  /*@{*/
 
69
 
 
70
  bool is_valid(void) const { return(target != 0 && source != 0); }
 
71
  std::string status(void) const;
 
72
 
 
73
  void assign_target(OPERATOR* obj);
 
74
  void assign_source(CONTROLLER_SOURCE* obj);
 
75
 
 
76
  CONTROLLER_SOURCE* source_pointer(void) const { return(source); }
 
77
  OPERATOR* target_pointer(void) const { return(target); }
 
78
 
 
79
  /*@}*/
 
80
 
 
81
private:
 
82
 
 
83
  OPERATOR* target;
 
84
  CONTROLLER_SOURCE* source;
 
85
 
 
86
  bool init_called_rep;
 
87
  int param_id_rep;
 
88
  double rangelow_rep, rangehigh_rep;
 
89
  double last_value_pos_rep;
 
90
};
 
91
 
 
92
#endif