diff --git a/src/lib/time/lumitime.cpp b/src/lib/time/lumitime.cpp index c1837667b..d2daba3c2 100644 --- a/src/lib/time/lumitime.cpp +++ b/src/lib/time/lumitime.cpp @@ -94,6 +94,11 @@ namespace time { return string (lumiera_tmpbuf_print_time (t_)); } + TimeVar::operator string() const + { + return string (lumiera_tmpbuf_print_time (t_)); + } + }} // namespace lib::Time diff --git a/src/lib/time/quantiser.cpp b/src/lib/time/quantiser.cpp index c4e12b274..cf384822b 100644 --- a/src/lib/time/quantiser.cpp +++ b/src/lib/time/quantiser.cpp @@ -23,6 +23,7 @@ #include "lib/time/quantiser.hpp" #include "lib/time/timevalue.hpp" +#include "lib/time/timequant.hpp" using std::string; @@ -32,6 +33,24 @@ namespace time { /** */ + QuTime::QuTime (TimeValue raw, Symbol gridID) + : Time(raw) /////////////////////////////////////////////////TODO fetch quantiser + { } + + + /** */ + QuTime::QuTime (TimeValue raw, Quantiser const& quantisation_to_use) + : Time(raw) /////////////////////////////////////////////////TODO fetch quantiser + { } + + + + /** */ + FixedFrameQuantiser::FixedFrameQuantiser (FSecs frames_per_second) + : Quantiser() /////////////////////////////////////////////////TODO we ought to do something + { } + + diff --git a/src/lib/time/timecode.cpp b/src/lib/time/timecode.cpp index 24c00de5b..3bb80e697 100644 --- a/src/lib/time/timecode.cpp +++ b/src/lib/time/timecode.cpp @@ -23,9 +23,15 @@ #include "lib/lumitime.hpp" #include "lib/time/timecode.hpp" +#include "lib/time/timevalue.hpp" #include "lib/time/timequant.hpp" #include "lib/time/formats.hpp" +extern "C" { +#include "lib/time.h" +} + + using std::string; @@ -38,6 +44,90 @@ namespace time { /** */ + FrameNr::FrameNr (QuTime const& quantisedTime) + : FACTOR_TODO (1,25) + , nr_(TimeVar(quantisedTime) / (25*GAVL_TIME_SCALE)) + { } /////////////////////////////TODO temporary bullshit (of course that is the job of the quantiser) + + + /** */ + SmpteTC::SmpteTC (QuTime const& quantisedTime) + : tpoint_(quantisedTime) /////////////////////////////TODO eternal bullshit + { } + + + /** */ + HmsTC::HmsTC (QuTime const& quantisedTime) + : tpoint_(quantisedTime) /////////////////////////////TODO bullshit + { } + + + /** */ + Secs::Secs (QuTime const& quantisedTime) + : sec_(TimeVar(quantisedTime) / GAVL_TIME_SCALE) /////////////TODO bullshit + { } + + + + /** */ + int + SmpteTC::getSecs() const + { + return lumiera_time_seconds (tpoint_); + } + + /** */ + int + SmpteTC::getMins() const + { + return lumiera_time_minutes (tpoint_); + } + + /** */ + int + SmpteTC::getHours() const + { + return lumiera_time_hours (tpoint_); + } + + /** */ + int + SmpteTC::getFrames() const + { + UNIMPLEMENTED ("Frame-Quantisation"); + } + + /** */ + int + HmsTC::getSecs() const + { + return lumiera_time_seconds (tpoint_); + } + + /** */ + int + HmsTC::getMins() const + { + return lumiera_time_minutes (tpoint_); + } + + /** */ + int + HmsTC::getHours() const + { + return lumiera_time_hours (tpoint_); + } + + /** */ + double + HmsTC::getMillis() const + { + TODO ("Frame-Quantisation"); + return lumiera_time_millis (tpoint_); + } + + /** */ + diff --git a/src/lib/time/timecode.hpp b/src/lib/time/timecode.hpp index 6cc526d79..05b5fb3ff 100644 --- a/src/lib/time/timecode.hpp +++ b/src/lib/time/timecode.hpp @@ -26,9 +26,11 @@ #include "lib/time/timevalue.hpp" #include "lib/time/formats.hpp" +#include "lib/symbol.hpp" //#include //#include +#include ///////////////TODO #include @@ -36,6 +38,8 @@ namespace lib { namespace time { using std::string; + using lib::Literal; + using boost::lexical_cast; /////////TODO /** @@ -50,13 +54,13 @@ namespace time { virtual ~TCode(); operator string() const { return show(); } - string describe() const { return tcID(); } - Time getTime() const { return Time(calc()); } + string describe() const { return string(tcID()); } + Time getTime() const { return Time(value()); } protected: virtual string show() const =0; - virtual string tcID() const =0; - virtual TimeValue calc() const =0; + virtual Literal tcID() const =0; + virtual TimeValue value() const =0; }; @@ -72,15 +76,19 @@ namespace time { class FrameNr : public TCode { - - virtual string show() const ; - virtual string tcID() const ; - virtual TimeValue calc() const ; + FSecs FACTOR_TODO; /////////////////////////////TODO temporary bullshit (of course that is the job of the quantiser) + + long nr_; + + + string show() const { return lexical_cast(nr_)+"fr"; } + Literal tcID() const { return "Frame-count"; } + TimeValue value() const { return Time(FACTOR_TODO * nr_); } public: - FrameNr (QuTime const& quantisedTime); + FrameNr (QuTime const& quantisedTime); - operator long() const; + operator long() const { return nr_; } }; @@ -91,10 +99,11 @@ namespace time { class SmpteTC : public TCode { - - virtual string show() const ; - virtual string tcID() const ; - virtual TimeValue calc() const ; + TimeVar tpoint_; + + virtual string show() const { return string(tpoint_); } + virtual Literal tcID() const { return "SMPTE"; } + virtual TimeValue value() const { return tpoint_; } public: SmpteTC (QuTime const& quantisedTime); @@ -113,10 +122,11 @@ namespace time { class HmsTC : public TCode { + TimeVar tpoint_; - virtual string show() const ; - virtual string tcID() const ; - virtual TimeValue calc() const ; + virtual string show() const { return string(tpoint_); } + virtual Literal tcID() const { return "Timecode"; } + virtual TimeValue value() const { return tpoint_; } public: HmsTC (QuTime const& quantisedTime); @@ -135,10 +145,11 @@ namespace time { class Secs : public TCode { + FSecs sec_; - virtual string show() const ; - virtual string tcID() const ; - virtual TimeValue calc() const ; + virtual string show() const { return string(Time(sec_)); } + virtual Literal tcID() const { return "Seconds"; } + virtual TimeValue value() const { return Time(sec_); } public: Secs (QuTime const& quantisedTime); diff --git a/src/lib/time/timequant.hpp b/src/lib/time/timequant.hpp index 25cd9b40f..89c5db63f 100644 --- a/src/lib/time/timequant.hpp +++ b/src/lib/time/timequant.hpp @@ -62,5 +62,23 @@ namespace time { + /* == implementation == */ + template + bool + QuTime::supports() const + { + return false; ////////////////TODO; + } + + + template + typename format::Traits::TimeCode + QuTime::formatAs() const + { + typedef typename format::Traits::TimeCode TimeCode; + return TimeCode(*this); + } + + }} // lib::time #endif diff --git a/src/lib/time/timevalue.hpp b/src/lib/time/timevalue.hpp index 674952ace..8fee6aca6 100644 --- a/src/lib/time/timevalue.hpp +++ b/src/lib/time/timevalue.hpp @@ -107,7 +107,7 @@ namespace time { > > { public: - TimeVar (TimeValue time = TimeValue()) + TimeVar (TimeValue const& time = TimeValue()) : TimeValue(time) { } @@ -123,6 +123,8 @@ namespace time { return *this; } + /** @internal diagnostics */ + operator std::string () const; // Supporting mixing with plain long int arithmetics operator gavl_time_t () const { return t_; }