Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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
62#include "lib/time/timecode.hpp"
63#include "lib/symbol.hpp"
64
65#include <string>
66
67
68namespace lib {
69namespace time {
70
71 using lib::Symbol;
72
73
89 class QuTime
90 : public Time
91 {
93
94 public:
95 QuTime (TimeValue raw, Symbol gridID);
96 QuTime (TimeValue raw, PQuant quantisation_to_use);
97
98 operator PQuant() const;
99
100 template<class FMT>
101 bool supports() const;
102
103 template<class FMT>
105 formatAs() const;
106
107 template<class TC>
108 void
109 castInto (TC& timecode) const;
110
113 void accept (Mutation const&);
114 };
115
116
117
118 /* == implementation == */
119
120 inline
121 QuTime::operator PQuant() const
122 {
123 ASSERT (quantiser_);
124 return quantiser_;
125 }
126
127 template<class FMT>
128 inline bool
130 {
131 return quantiser_->supports<FMT>();
132 }
133
134
135 template<class FMT>
138 {
140 return TC(*this);
141 }
142
143
153 template<class TC>
154 inline void
155 QuTime::castInto (TC& timecode) const
156 {
157 using Format = TC::Format;
158 REQUIRE (supports<Format>());
159
160 Format::rebuild (timecode, *quantiser_, TimeValue(*this));
161 }
162
163
164}} // lib::time
165#endif
Token or Atom with distinct identity.
Definition symbol.hpp:120
Interface: an opaque change imposed onto some time value.
Definition mutation.hpp:92
grid aligned time specification, referring to a specific scale.
Definition timequant.hpp:91
void castInto(TC &timecode) const
quantise into implicit grid, then rebuild the timecode
bool supports() const
does our implicit time grid support building that timecode format?
void accept(Mutation const &)
receive change message, which might cause re-quantisation
format::Traits< FMT >::TimeCode formatAs() const
create new time code instance, then castInto
basic constant internal time value.
Lumiera's internal time value datatype.
std::shared_ptr< const Quantiser > PQuant
Definition formats.hpp:58
Implementation namespace for support and library code.
Library functions to support the formation of grid-aligned time values.
Marker types to indicate a literal string and a Symbol.
Timecode handling library This header defines the foundation interface TCode to represent a grid alig...
a family of time value like entities and their relationships.