Lumiera  0.pre.03
»edit your freedom«
timequant.hpp
Go to the documentation of this file.
1 /*
2  TIMEQUANT.hpp - quantised (grid aligned) time values
3 
4  Copyright (C)
5  2010, 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 
57 #ifndef LIB_TIME_TIMEQUANT_H
58 #define LIB_TIME_TIMEQUANT_H
59 
60 #include "lib/time/timevalue.hpp"
61 #include "lib/time/quantiser.hpp"
62 #include "lib/time/timecode.hpp"
63 #include "lib/symbol.hpp"
64 
65 //#include <boost/operators.hpp>
66 #include <string>
67 
68 
69 namespace lib {
70 namespace time {
71 
72  using lib::Symbol;
73 
74 
90  class QuTime
91  : public Time
92  {
93  PQuant quantiser_;
94 
95  public:
96  QuTime (TimeValue raw, Symbol gridID);
97  QuTime (TimeValue raw, PQuant quantisation_to_use);
98 
99  operator PQuant() const;
100 
101  template<class FMT>
102  bool supports() const;
103 
104  template<class FMT>
106  formatAs() const;
107 
108  template<class TC>
109  void
110  castInto (TC& timecode) const;
111 
114  void accept (Mutation const&);
115  };
116 
117 
118 
119  /* == implementation == */
120 
121  inline
122  QuTime::operator PQuant() const
123  {
124  ASSERT (quantiser_);
125  return quantiser_;
126  }
127 
128  template<class FMT>
129  inline bool
131  {
132  return quantiser_->supports<FMT>();
133  }
134 
135 
136  template<class FMT>
137  inline typename format::Traits<FMT>::TimeCode
139  {
140  using TC = typename format::Traits<FMT>::TimeCode;
141  return TC(*this);
142  }
143 
144 
154  template<class TC>
155  inline void
156  QuTime::castInto (TC& timecode) const
157  {
158  using Format = typename TC::Format;
159  REQUIRE (supports<Format>());
160 
161  Format::rebuild (timecode, *quantiser_, TimeValue(*this));
162  }
163 
164 
165 }} // lib::time
166 #endif
Interface: an opaque change imposed onto some time value.
Definition: mutation.hpp:91
void accept(Mutation const &)
receive change message, which might cause re-quantisation
Implementation namespace for support and library code.
QuTime(TimeValue raw, Symbol gridID)
build a quantised time value, referring the time grid by-name.
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
format::Traits< FMT >::TimeCode formatAs() const
create new time code instance, then castInto
Definition: timequant.hpp:138
Token or Atom with distinct identity.
Definition: symbol.hpp:117
void castInto(TC &timecode) const
quantise into implicit grid, then rebuild the timecode
Definition: timequant.hpp:156
Timecode handling library This header defines the foundation interface TCode to represent a grid alig...
Marker types to indicate a literal string and a Symbol.
TimeValue(TimeValue const &origin, TimeValue const &target)
Definition: timevalue.hpp:161
Library functions to support the formation of grid-aligned time values.
bool supports() const
does our implicit time grid support building that timecode format?
Definition: timequant.hpp:130
a family of time value like entities and their relationships.
basic constant internal time value.
Definition: timevalue.hpp:133
grid aligned time specification, referring to a specific scale.
Definition: timequant.hpp:90