enforce generally imutable time values

This commit is contained in:
Fischlurch 2011-01-22 23:20:12 +01:00
parent dea026cfd9
commit faf579c4c5
3 changed files with 19 additions and 5 deletions

View file

@ -169,7 +169,14 @@ namespace time {
class Offset
: public TimeValue
{
protected:
Offset&
operator= (Offset const& o) ///< derived classes allow mutation
{
TimeValue::operator= (o);
return *this;
}
public:
explicit
Offset (TimeValue const& distance)
@ -246,6 +253,9 @@ namespace time {
class Time
: public TimeValue
{
/// direct assignment prohibited
Time& operator= (Time const);
public:
static const Time MAX ;
static const Time MIN ;
@ -291,6 +301,9 @@ namespace time {
class Duration
: public Offset
{
/// direct assignment prohibited
Duration& operator= (Duration const&);
public:
Duration (Offset const& distance)
: Offset(distance.abs())

View file

@ -59,6 +59,7 @@ namespace meta {
using lib::Symbol;
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::TimeValue;
using lib::time::FrameRate;
using lib::time::FSecs;
@ -102,7 +103,7 @@ namespace meta {
string id_;
FrameRate fps_;
Time origin_;
TimeVar origin_;
/** when building a compound or variable grid,
* the predecessor is the grid active \em before

View file

@ -142,7 +142,7 @@ namespace test{
CHECK (--smpte.mins == 38);
CHECK (" 5:38:00:01" == string(smpte));
Time tx = smpte.getTime();
TimeVar tx = smpte.getTime();
CHECK (tx == Time(0,0,38,5) + Time(FSecs(1,25)));
// Extended SMPTE: extension of the axis beyond origin towards negative values
@ -157,7 +157,7 @@ namespace test{
tx = smpte.getTime();
++smpte.frames; // now *increasing* the frame value
CHECK ("- 0:22:00:00"== string(smpte)); // means decreasing the resulting time
CHECK (tx - Time(1000/25,0,0,0) == smpte.getTime());
CHECK (smpte.getTime() == tx - Time(1000/25,0,0,0));
++smpte; // but the orientation of the increment on the *whole* TC values is unaltered
CHECK ("- 0:21:59:24"== string(smpte)); // so this actually *advanced* time by one frame
CHECK (tx == smpte.getTime());
@ -204,7 +204,7 @@ namespace test{
CHECK (tx == smpte.getTime()); // applying invertOrientation() doesn't change the value
smpte.frames.setValueRaw(-1);
tx = tx - Time(FSecs(2,25));
tx -= Time(FSecs(2,25));
CHECK (tx == smpte.getTime());
CHECK (" 1:00:00:-1"== string(smpte));
smpte.invertOrientation(); // invoking on positive should create double negated representation