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;
63 GenTime & operator+=(GenTime op) {
68 GenTime & operator-=(GenTime op) {
73 /** @brief Adds two GenTimes. */
74 GenTime operator+(GenTime op) const {
75 return GenTime(m_time + op.m_time);
78 /** @brief Subtracts one genTime from another. */
79 GenTime operator-(GenTime op) const {
80 return GenTime(m_time - op.m_time);
83 /** @brief Multiplies one GenTime by a double value, returning a GenTime. */
84 GenTime operator*(double op) const {
85 return GenTime(m_time * op);
88 /** @brief Divides one GenTime by a double value, returning a GenTime. */
89 GenTime operator/(double op) const {
90 return GenTime(m_time / op);
93 bool operator<(GenTime op) const {
94 return m_time + s_delta < op.m_time;
97 bool operator>(GenTime op) const {
98 return m_time > op.m_time + s_delta;
101 bool operator>=(GenTime op) const {
102 return m_time + s_delta >= op.m_time;
105 bool operator<=(GenTime op) const {
106 return m_time <= op.m_time + s_delta;
109 bool operator==(GenTime op) const {
110 return fabs(m_time - op.m_time) < s_delta;
113 bool operator!=(GenTime op) const {
114 return fabs(m_time - op.m_time) >= s_delta;
118 /** Holds the time for this object. */
121 /** A delta value that is used to get around floating point rounding issues. */
122 static double s_delta;