Lumiera  0.pre.03
»edit your freedom«
timecode.hpp
Go to the documentation of this file.
1 /*
2  TIMECODE.hpp - grid aligned and fixed format time specifications
3 
4  Copyright (C) Lumiera.org
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
36 #ifndef LIB_TIME_TIMECODE_H
37 #define LIB_TIME_TIMECODE_H
38 
39 #include "lib/time/timevalue.hpp"
40 #include "lib/time/formats.hpp"
41 #include "lib/time/digxel.hpp"
42 #include "lib/symbol.hpp"
43 
44 #include <boost/operators.hpp>
45 #include <boost/lexical_cast.hpp>
46 #include <string>
47 
48 
49 namespace lib {
50 namespace time {
51 
52  using std::string;
53  using lib::Literal;
54  using boost::lexical_cast;
55 
56 
65  class TCode
66  {
67 
68  public:
69  virtual ~TCode() { }
70 
71  operator string() const { return show(); }
72  string describe() const { return string(tcID()); }
73  Time getTime() const { return Time(value()); }
74 
75  protected:
76  TCode (PQuant const& quant)
77  : quantiser_(quant)
78  { }
79 
80  virtual string show() const =0;
81  virtual Literal tcID() const =0;
82  virtual TimeValue value() const =0;
83 
84  protected:
85  PQuant quantiser_;
86  };
87 
88 
89  class QuTime;
90 
105  class FrameNr
106  : public TCode
107  , public CountVal
108  {
109 
110  string show() const { return string(CountVal::show())+"#"; }
111  Literal tcID() const { return "Framecount"; }
112  TimeValue value() const { return Format::evaluate (*this, *quantiser_); }
113 
114  public:
115  typedef format::Frames Format;
116 
117  FrameNr (QuTime const& quantisedTime);
118 
119  using TCode::operator string;
120  // CountVal implicitly convertible to long ///////////TICKET #882 : outch! should be a 64bit type!
121  };
122 
123 
124 
150  class SmpteTC
151  : public TCode
152  , boost::unit_steppable<SmpteTC>
153  {
154  uint effectiveFramerate_;
155 
156  virtual string show() const ;
157  virtual Literal tcID() const { return "SMPTE"; }
158  virtual TimeValue value() const { return Format::evaluate (*this, *quantiser_); }
159 
160 
161  public:
162  typedef format::Smpte Format;
163 
164  SmpteTC (QuTime const& quantisedTime);
165  SmpteTC (SmpteTC const&);
166  SmpteTC& operator= (SmpteTC const&);
167 
168  uint getFps() const;
169 
170  void clear();
171  void rebuild();
172  void invertOrientation();
173 
174 
175  HourDigit hours;
176  SexaDigit mins;
177  SexaDigit secs;
178  SexaDigit frames;
179  Signum sgn;
180 
181  SmpteTC& operator++();
182  SmpteTC& operator--();
183  };
184 
185 
186 
190  class HmsTC
191  : public TCode
192  {
193  TimeVar tpoint_;
194 
195  virtual string show() const { return string(tpoint_); }
196  virtual Literal tcID() const { return "Timecode"; }
197  virtual TimeValue value() const { return tpoint_; }
198 
199  public:
200  typedef format::Hms Format;
201 
202  HmsTC (QuTime const& quantisedTime);
203 
204  double getMillis () const;
205  int getSecs () const;
206  int getMins () const;
207  int getHours () const;
208  };
209 
210 
211 
215  class Secs
216  : public TCode
217  {
218  FSecs sec_;
219 
220  virtual string show() const { return string(Time(sec_)); }
221  virtual Literal tcID() const { return "Seconds"; }
222  virtual TimeValue value() const { return Time(sec_); }
223 
224  public:
225  typedef format::Seconds Format;
226 
227  Secs (QuTime const& quantisedTime);
228 
229  operator FSecs() const;
230  };
231 
232 
237 }} // lib::time
238 #endif
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
Definition: timevalue.hpp:241
Frame count as timecode format.
Definition: formats.hpp:84
A self-contained numeric element for building structured numeric displays.
Classical Timecode value reminiscent to SMPTE format.
Definition: timecode.hpp:150
The informal hours-minutes-seconds-millisecond timecode.
Definition: formats.hpp:117
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:85
Widely used standard media timecode format.
Definition: formats.hpp:99
Implementation namespace for support and library code.
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
Marker types to indicate a literal string and a Symbol.
A number element for building structured numeric displays.
Definition: digxel.hpp:226
Simple timecode specification as fractional seconds.
Definition: formats.hpp:135
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:229
special Digxel to show a sign.
Definition: digxel.hpp:327
Interface: fixed format timecode specification.
Definition: timecode.hpp:65
Definition of time code formats This header is part of the Lumiera time and timecode handling library...
A frame counting timecode value.
Definition: timecode.hpp:105
a family of time value like entities and their relationships.
basic constant internal time value.
Definition: timevalue.hpp:142
grid aligned time specification, referring to a specific scale.
Definition: timequant.hpp:99