diff --git a/src/lib/time/quantiser.cpp b/src/lib/time/quantiser.cpp index 48b24979c..c4e12b274 100644 --- a/src/lib/time/quantiser.cpp +++ b/src/lib/time/quantiser.cpp @@ -21,7 +21,7 @@ * *****************************************************/ -#include "lib/lumitime.hpp" +#include "lib/time/quantiser.hpp" #include "lib/time/timevalue.hpp" using std::string; @@ -35,5 +35,9 @@ namespace time { + LUMIERA_ERROR_DEFINE (UNKNOWN_GRID, "referring to an undefined grid or scale in value quantisation"); + + + }} // lib::time diff --git a/src/lib/time/quantiser.hpp b/src/lib/time/quantiser.hpp index 1d7ea45e9..61b9e99d0 100644 --- a/src/lib/time/quantiser.hpp +++ b/src/lib/time/quantiser.hpp @@ -24,16 +24,20 @@ #ifndef LIB_TIME_QUANTISER_H #define LIB_TIME_QUANTISER_H +#include "lib/error.hpp" #include "lib/time/timevalue.hpp" #include "lib/time/formats.hpp" +#include "lib/iter-adapter.hpp" //#include +#include #include namespace lib { namespace time { + LUMIERA_ERROR_DECLARE (UNKNOWN_GRID); ///< referring to an undefined grid or scale in value quantisation /** * Facility to create grid-aligned time values. @@ -42,8 +46,17 @@ namespace time { */ class Quantiser { + typedef std::vector _FormatTable; + typedef _FormatTable::const_iterator _SrcIter; + typedef lib::PtrDerefIter<_SrcIter> _Iter; public: + template + bool supports() const; + + typedef _Iter iterator; + iterator getSupportedFormats() const; + }; diff --git a/src/lib/time/timecode.hpp b/src/lib/time/timecode.hpp index 54866dd7f..18d57e52d 100644 --- a/src/lib/time/timecode.hpp +++ b/src/lib/time/timecode.hpp @@ -34,6 +34,8 @@ namespace lib { namespace time { + using std::string; + /** * fixed format time specification. @@ -46,6 +48,10 @@ namespace time { { public: + + string describe() const; + + }; @@ -64,11 +70,31 @@ namespace time { public: FrameNr (QuTime const& quantisedTime); + FrameNr (TCode const&); operator long() const; }; + /** + * + */ + class SmpteTC + : public TCode + { + + public: + SmpteTC (QuTime const& quantisedTime); + SmpteTC (TCode const&); + + int getSecs () const; + int getMins () const; + int getHours () const; + int getFrames () const; + }; + + + }} // lib::time #endif diff --git a/src/lib/time/timequant.hpp b/src/lib/time/timequant.hpp index dff03e8ac..499c5ae43 100644 --- a/src/lib/time/timequant.hpp +++ b/src/lib/time/timequant.hpp @@ -45,11 +45,18 @@ namespace time { * @todo WIP-WIP-WIP */ class QuTime + : public Time { public: QuTime (TimeValue raw, Symbol gridID); QuTime (TimeValue raw, Quantiser const& quantisation_to_use); + + template + bool supports() const; + + template + TCode formatAs() const; }; diff --git a/tests/lib/time/time-quantisation-test.cpp b/tests/lib/time/time-quantisation-test.cpp index 22325c37e..eb5acf171 100644 --- a/tests/lib/time/time-quantisation-test.cpp +++ b/tests/lib/time/time-quantisation-test.cpp @@ -92,8 +92,8 @@ namespace test{ FixedFrameQuantiser fixQ(25); QuTime qVal (org, fixQ); - CHECK (contains (qVal.supportedFormats(), format::FRAMES)); - CHECK (contains (qVal.supportedFormats(), format::SMPTE)); + CHECK ( qVal.supports()); + CHECK ( qVal.supports()); TCode smpteTCode = qVal.formatAs(); showTimeCode (smpteTCode); @@ -102,14 +102,14 @@ namespace test{ showTimeCode (frameTCode); FrameNr count(frameTCode); - CHECK (string(count) == *(frameTCode.components())); +// CHECK (string(count) == frameTCode.part[0])); } template void showTimeCode (TC timecodeValue) { - cout << timecodeValue.describe() << " = " << join (timecodeValue.components(), ":") << endl; +// cout << timecodeValue.describe() << " = " << join (timecodeValue.part(), ":") << endl; } @@ -140,7 +140,8 @@ namespace test{ TimeGrid::build("special_funny_grid", 1); // provide the grid's definition (1 frame per second) - int cnt = funny.formatAs(); // and now performing quantisation is OK + int cnt = 0;//////funny.formatAs().part["count"]; + // and now performing quantisation is OK SmpteTC smpte (funny); // also converting into SMPTE (which implies frame quantisation) CHECK (0 == smpte.getFrames()); // we have 1fps, thus the frame part is always zero! CHECK (cnt % 60 == smpte.getSecs()); // and the seconds part will be in sync with the frame count