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)
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 
27 #ifndef LIB_TIME_TIMECODE_H
28 #define LIB_TIME_TIMECODE_H
29 
30 #include "lib/time/timevalue.hpp"
31 #include "lib/time/formats.hpp"
32 #include "lib/time/digxel.hpp"
33 #include "lib/symbol.hpp"
34 
35 #include <boost/operators.hpp>
36 #include <boost/lexical_cast.hpp>
37 #include <string>
38 
39 
40 namespace lib {
41 namespace time {
42 
43  using std::string;
44  using lib::Literal;
45  using boost::lexical_cast;
46 
47 
56  class TCode
57  {
58 
59  public:
60  virtual ~TCode() { }
61 
62  operator string() const { return show(); }
63  string describe() const { return string(tcID()); }
64  Time getTime() const { return Time(value()); }
65 
66  protected:
67  TCode (PQuant const& quant)
68  : quantiser_(quant)
69  { }
70 
71  virtual string show() const =0;
72  virtual Literal tcID() const =0;
73  virtual TimeValue value() const =0;
74 
75  protected:
76  PQuant quantiser_;
77  };
78 
79 
80  class QuTime;
81 
96  class FrameNr
97  : public TCode
98  , public CountVal
99  {
100 
101  string show() const { return string(CountVal::show())+"#"; }
102  Literal tcID() const { return "Framecount"; }
103  TimeValue value() const { return Format::evaluate (*this, *quantiser_); }
104 
105  public:
106  typedef format::Frames Format;
107 
108  FrameNr (QuTime const& quantisedTime);
109 
110  using TCode::operator string;
111  // CountVal implicitly convertible to long ///////////TICKET #882 : outch! should be a 64bit type!
112  };
113 
114 
115 
141  class SmpteTC
142  : public TCode
143  , boost::unit_steppable<SmpteTC>
144  {
145  uint effectiveFramerate_;
146 
147  virtual string show() const ;
148  virtual Literal tcID() const { return "SMPTE"; }
149  virtual TimeValue value() const { return Format::evaluate (*this, *quantiser_); }
150 
151 
152  public:
153  typedef format::Smpte Format;
154 
155  SmpteTC (QuTime const& quantisedTime);
156  SmpteTC (SmpteTC const&);
157  SmpteTC& operator= (SmpteTC const&);
158 
159  uint getFps() const;
160 
161  void clear();
162  void rebuild();
163  void invertOrientation();
164 
165 
166  HourDigit hours;
167  SexaDigit mins;
168  SexaDigit secs;
169  SexaDigit frames;
170  Signum sgn;
171 
172  SmpteTC& operator++();
173  SmpteTC& operator--();
174  };
175 
176 
177 
181  class HmsTC
182  : public TCode
183  {
184  TimeVar tpoint_;
185 
186  virtual string show() const { return string(tpoint_); }
187  virtual Literal tcID() const { return "Timecode"; }
188  virtual TimeValue value() const { return tpoint_; }
189 
190  public:
191  typedef format::Hms Format;
192 
193  HmsTC (QuTime const& quantisedTime);
194 
195  double getMillis () const;
196  int getSecs () const;
197  int getMins () const;
198  int getHours () const;
199  };
200 
201 
202 
206  class Secs
207  : public TCode
208  {
209  FSecs sec_;
210 
211  virtual string show() const { return string(Time(sec_)); }
212  virtual Literal tcID() const { return "Seconds"; }
213  virtual TimeValue value() const { return Time(sec_); }
214 
215  public:
216  typedef format::Seconds Format;
217 
218  Secs (QuTime const& quantisedTime);
219 
220  operator FSecs() const;
221  };
222 
223 
228 }} // lib::time
229 #endif
a mutable time value, behaving like a plain number, allowing copy and re-accessing ...
Definition: timevalue.hpp:232
Frame count as timecode format.
Definition: formats.hpp:75
A self-contained numeric element for building structured numeric displays.
Classical Timecode value reminiscent to SMPTE format.
Definition: timecode.hpp:141
The informal hours-minutes-seconds-millisecond timecode.
Definition: formats.hpp:108
inline string literal This is a marker type to indicate that
Definition: symbol.hpp:76
Widely used standard media timecode format.
Definition: formats.hpp:90
Implementation namespace for support and library code.
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
Marker types to indicate a literal string and a Symbol.
A number element for building structured numeric displays.
Definition: digxel.hpp:217
Simple timecode specification as fractional seconds.
Definition: formats.hpp:126
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:220
special Digxel to show a sign.
Definition: digxel.hpp:318
Interface: fixed format timecode specification.
Definition: timecode.hpp:56
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:96
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