Bump libdcp for build fixes.
[libsub.git] / src / sub_time.h
index 5596970fac2aaad2c0dbf11c255a16c8bfc891ad..93088cb2fbf596c7cb53be6e680fede074255f38 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 */
 
-#ifndef LIBSUB_TIME_H
-#define LIBSUB_TIME_H
+#ifndef LIBSUB_SUB_TIME_H
+#define LIBSUB_SUB_TIME_H
 
-#include <iostream>
+#include "rational.h"
+#include <boost/optional.hpp>
 
 namespace sub {
 
@@ -28,34 +29,49 @@ class Time
 {
 public:
        Time ()
-               : _hours (0)
-               , _minutes (0)
-               , _seconds (0)
+               : _seconds (0)
                , _frames (0)
        {}
-                         
-       Time (int h, int m, int s, int f)
-               : _hours (h)
-               , _minutes (m)
-               , _seconds (s)
-               , _frames (f)
-       {}
 
-       std::string timecode () const;
+       int hours () const;
+       int minutes () const;
+       int seconds () const;
+
+       int frames_at (Rational rate) const;
+       int milliseconds () const;
+
+       double all_as_seconds () const;
+
+       void add (Time t);
+       void scale (float f);
+
+       static Time from_hmsf (int h, int m, int s, int f, boost::optional<Rational> rate = boost::optional<Rational> ());
+       static Time from_hms (int h, int m, int s, int ms);
+       static Time from_frames (int frames, Rational rate);
 
 private:
+       friend bool operator< (Time const & a, Time const & b);
+       friend bool operator> (Time const & a, Time const & b);
        friend bool operator== (Time const & a, Time const & b);
        friend std::ostream& operator<< (std::ostream& s, Time const & t);
-       
-       int _hours;
-       int _minutes;
+
+       Time (int seconds, int frames, boost::optional<Rational> rate)
+               : _seconds (seconds)
+               , _frames (frames)
+               , _rate (rate)
+       {}
+
        int _seconds;
        int _frames;
+       boost::optional<Rational> _rate;
 };
 
+bool operator< (Time const & a, Time const & b);
+bool operator> (Time const & a, Time const & b);
 bool operator== (Time const & a, Time const & b);
-std::ostream& operator<< (std::ostream&, Time const & t);
-       
+bool operator!= (Time const & a, Time const & b);
+std::ostream& operator<< (std::ostream& s, Time const & t);
+
 }
 
 #endif