1 /***************************************************************************
4 begin : Sat Sep 14 2002
5 copyright : (C) 2002 by Jason Wood
6 email : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
26 * @brief Encapsulates a time, which can be set in various forms and outputted in various forms.
33 /** @brief Creates a GenTime object, with a time of 0 seconds. */
36 /** @brief Creates a GenTime object, with time given in seconds. */
37 explicit GenTime(double seconds);
39 /** @brief Creates a GenTime object, by passing number of frames and how many frames per second. */
40 GenTime(int frames, double framesPerSecond);
42 /** @brief Gets the time, in seconds. */
43 double seconds() const;
45 /** @brief Gets the time, in milliseconds */
48 /** @brief Gets the time in frames.
49 * @param framesPerSecond Number of frames per second */
50 double frames(double framesPerSecond) const;
52 /** @brief Rounds the GenTime's value to the nearest frame.
53 * @param framesPerSecond Number of frames per second */
54 GenTime & roundNearestFrame(double framesPerSecond);
56 QString toString() const;
64 GenTime operator -() {
65 return GenTime(-m_time);
69 GenTime & operator+=(GenTime op) {
75 GenTime & operator-=(GenTime op) {
80 /** @brief Adds two GenTimes. */
81 GenTime operator+(GenTime op) const {
82 return GenTime(m_time + op.m_time);
85 /** @brief Subtracts one genTime from another. */
86 GenTime operator-(GenTime op) const {
87 return GenTime(m_time - op.m_time);
90 /** @brief Multiplies one GenTime by a double value, returning a GenTime. */
91 GenTime operator*(double op) const {
92 return GenTime(m_time * op);
95 /** @brief Divides one GenTime by a double value, returning a GenTime. */
96 GenTime operator/(double op) const {
97 return GenTime(m_time / op);
100 bool operator<(GenTime op) const {
101 return m_time + s_delta < op.m_time;
104 bool operator>(GenTime op) const {
105 return m_time > op.m_time + s_delta;
108 bool operator>=(GenTime op) const {
109 return m_time + s_delta >= op.m_time;
112 bool operator<=(GenTime op) const {
113 return m_time <= op.m_time + s_delta;
116 bool operator==(GenTime op) const {
117 return fabs(m_time - op.m_time) < s_delta;
120 bool operator!=(GenTime op) const {
121 return fabs(m_time - op.m_time) >= s_delta;
125 /** Holds the time in seconds for this object. */
128 /** A delta value that is used to get around floating point rounding issues. */
129 static double s_delta;