Time.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef CPP3DS_TIME_HPP
26 #define CPP3DS_TIME_HPP
27 
28 #include <cpp3ds/Config.hpp>
29 
30 
31 namespace cpp3ds
32 {
37 class Time
38 {
39 public :
40 
47  Time();
48 
57  float asSeconds() const;
58 
67  Int32 asMilliseconds() const;
68 
77  Int64 asMicroseconds() const;
78 
80  // Static member data
82  static const Time Zero;
83 
84 private :
85 
86  friend Time seconds(float);
87  friend Time milliseconds(Int32);
88  friend Time microseconds(Int64);
89 
99  explicit Time(Int64 microseconds);
100 
101 private :
102 
104  // Member data
106  Int64 m_microseconds;
107 };
108 
120 Time seconds(float amount);
121 
133 Time milliseconds(Int32 amount);
134 
146 Time microseconds(Int64 amount);
147 
158 bool operator ==(Time left, Time right);
159 
170 bool operator !=(Time left, Time right);
171 
182 bool operator <(Time left, Time right);
183 
194 bool operator >(Time left, Time right);
195 
206 bool operator <=(Time left, Time right);
207 
218 bool operator >=(Time left, Time right);
219 
229 Time operator -(Time right);
230 
241 Time operator +(Time left, Time right);
242 
253 Time& operator +=(Time& left, Time right);
254 
265 Time operator -(Time left, Time right);
266 
277 Time& operator -=(Time& left, Time right);
278 
289 Time operator *(Time left, float right);
290 
301 Time operator *(Time left, Int64 right);
302 
313 Time operator *(float left, Time right);
314 
325 Time operator *(Int64 left, Time right);
326 
337 Time& operator *=(Time& left, float right);
338 
349 Time& operator *=(Time& left, Int64 right);
350 
361 Time operator /(Time left, float right);
362 
373 Time operator /(Time left, Int64 right);
374 
385 Time& operator /=(Time& left, float right);
386 
397 Time& operator /=(Time& left, Int64 right);
398 
409 float operator /(Time left, Time right);
410 
421 Time operator %(Time left, Time right);
422 
433 Time& operator %=(Time& left, Time right);
434 
435 } // namespace cpp3ds
436 
437 
438 #endif
439 
440 
Int32 asMilliseconds() const
Return the time value as a number of milliseconds.
Time()
Default constructor.
Represents a time value.
Definition: Time.hpp:37
Int64 asMicroseconds() const
Return the time value as a number of microseconds.
float asSeconds() const
Return the time value as a number of seconds.
static const Time Zero
Predefined "zero" time value.
Definition: Time.hpp:82