Lumiera  0.pre.03
»edit your freedom«
control.hpp
Go to the documentation of this file.
1 /*
2  CONTROL.hpp - a life time control for feedback and mutation
3 
4  Copyright (C)
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
96 #ifndef LIB_TIME_CONTROL_H
97 #define LIB_TIME_CONTROL_H
98 
99 #include "lib/time/mutation.hpp"
100 #include "lib/time/timevalue.hpp"
101 #include "lib/time/control-impl.hpp"
102 
103 
104 
105 namespace lib {
106 namespace time {
107 
108 
109 
124  template<class TI>
125  class Control
126  : public mutation::Mutator<TI>
127  {
128  mutation::Propagator<TI> notifyListeners_;
129 
130  virtual void change (Duration&) const;
131  virtual void change (TimeSpan&) const;
132  virtual void change (QuTime&) const;
133 
134  public:
135  void operator() (TI const&) const;
136  void operator() (Offset const&) const;
137  void operator() (int) const;
138 
139 
143  template<class SIG>
144  void connectChangeNotification (SIG const& toNotify);
145 
148  void disconnect();
149  };
150 
151 
152 
153 
154  /* === forward to implementation === */
155 
166  template<class TI>
167  void
168  Control<TI>::operator () (TI const& newValue) const
169  {
170  this->ensure_isArmed();
171  notifyListeners_(
172  this->setVal_(newValue));
173  }
174 
180  template<class TI>
181  void
182  Control<TI>::operator () (Offset const& adjustment) const
183  {
184  this->ensure_isArmed();
185  notifyListeners_(
186  this->offset_(adjustment));
187  }
188 
194  template<class TI>
195  void
196  Control<TI>::operator () (int offset_by_steps) const
197  {
198  this->ensure_isArmed();
199  notifyListeners_(
200  this->nudge_(offset_by_steps));
201  }
202 
203 
204  template<class TI>
205  void
207  {
208  notifyListeners_.disconnect();
209  this->unbind();
210  }
211 
212  template<class TI>
213  template<class SIG>
214  void
216  {
217  if (this->offset_)
218  { // we're already connected: thus propagate current value
219  TI currentValue = this->offset_(Offset::ZERO);
220  toNotify (currentValue);
221  }
222  notifyListeners_.attach (toNotify);
223  }
224 
225 
226  /* ==== Implementation of the Mutation interface ==== */
227 
228  template<class TI>
229  void
230  Control<TI>::change (Duration& targetDuration) const
231  {
232  this->bind_to (targetDuration);
233  }
234 
235  template<class TI>
236  void
237  Control<TI>::change (TimeSpan& targetInterval) const
238  {
239  this->bind_to (targetInterval);
240  }
241 
242  template<class TI>
243  void
244  Control<TI>::change (QuTime& targetQuTime) const
245  {
246  this->bind_to (targetQuTime);
247  }
248 
249 }} // lib::time
250 #endif
Implementation building block: propagate changes to listeners.
void connectChangeNotification(SIG const &toNotify)
install a callback functor to be invoked as notification for any changes imposed onto the observed ti...
Definition: control.hpp:215
void operator()(TI const &) const
impose a new value to the connected target.
Definition: control.hpp:168
Modifying time and timecode values.
Frontend/Interface: controller-element to retrieve and change running time values.
Definition: control.hpp:125
Implementation building blocks for time modification and propagation.
Implementation namespace for support and library code.
void disconnect()
disconnect from observed entity and cease any change notification
Definition: control.hpp:206
Offset measures a distance in time.
Definition: timevalue.hpp:358
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:468
A time interval anchored at a specific point in time.
Definition: timevalue.hpp:573
Implementation building block: impose changes to a Time element.
a family of time value like entities and their relationships.
grid aligned time specification, referring to a specific scale.
Definition: timequant.hpp:90