3 * Provides a class for managing a timestamp (seconds & milliseconds.)
6 // Written by Curtis Olson, started December 1998.
8 // Copyright (C) 1998 Curtis L. Olson - http://www.flightgear.org/~curt
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #ifndef _TIMESTAMP_HXX
28 #define _TIMESTAMP_HXX
32 # error This library requires C++
36 #include <simgear/compiler.h>
39 // MSVC++ 6.0 kuldge - Need forward declaration of friends.
41 SGTimeStamp operator + (const SGTimeStamp& t, const long& m);
42 long operator - (const SGTimeStamp& a, const SGTimeStamp& b);
45 * The SGTimeStamp class allows you to mark and compare time stamps
46 * with microsecond accuracy (if your system has support for this
49 * The SGTimeStamp is useful for tracking the elapsed time of various
50 * events in your program. You can also use it to keep constistant
51 * motion across varying frame rates.
63 /** Default constructor */
67 * This creates an instance of the SGTimeStamp object. When
68 * calling the constructor you may provide initial seconds an
69 * microseconds values.
70 * @param s initial seconds value
71 * @param m initial microseconds value
73 SGTimeStamp( const long s, const long m );
75 /** Update stored time to current time (seconds and microseconds) */
79 * Increment the saved time by the specified number of microseconds
81 * @param m microseconds increment
82 * @return new time stamp
84 friend SGTimeStamp operator + (const SGTimeStamp& t, const long& m);
87 * Subtract two time stamps returning the difference in microseconds.
88 * @param a timestamp 1
89 * @param b timestame 2
90 * @return difference in microseconds
92 friend long operator - (const SGTimeStamp& a, const SGTimeStamp& b);
94 /** @return the saved seconds of this time stamp */
95 inline long get_seconds() const { return seconds; }
97 /** @return the saved microseconds of this time stamp */
98 inline long get_usec() const { return usec; }
101 inline SGTimeStamp::SGTimeStamp() :
107 inline SGTimeStamp::SGTimeStamp( const long s, const long u ) {
112 #endif // _TIMESTAMP_HXX