PPL  1.2
Time_defs.hh
Go to the documentation of this file.
1 /* Time class declaration.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Time_defs_hh
25 #define PPL_Time_defs_hh 1
26 
27 #include "Time_types.hh"
28 
29 namespace Parma_Polyhedra_Library {
30 
31 namespace Implementation {
32 
33 namespace Watchdog {
34 
36 bool operator==(const Time& x, const Time& y);
37 
39 bool operator!=(const Time& x, const Time& y);
40 
42 bool operator<(const Time& x, const Time& y);
43 
48 bool operator<=(const Time& x, const Time& y);
49 
51 bool operator>(const Time& x, const Time& y);
52 
57 bool operator>=(const Time& x, const Time& y);
58 
60 Time operator+(const Time& x, const Time& y);
61 
66 Time operator-(const Time& x, const Time& y);
67 
68 } // namespace Watchdog
69 
70 } // namespace Implementation
71 
72 } // namespace Parma_Polyhedra_Library
73 
76 public:
78  Time();
79 
81  explicit Time(long centisecs);
82 
84  Time(long s, long m);
85 
90  long seconds() const;
91 
96  long microseconds() const;
97 
99  Time& operator+=(const Time& y);
100 
105  Time& operator-=(const Time& y);
106 
108  bool OK() const;
109 
110 private:
112  static const long USECS_PER_SEC = 1000000L;
113 
115  static const long CSECS_PER_SEC = 100L;
116 
118  long secs;
119 
121  long microsecs;
122 };
123 
124 #include "Time_inlines.hh"
125 
126 #endif // !defined(PPL_Time_defs_hh)
long microseconds() const
Returns the number of microseconds that, when added to the number of seconds returned by seconds()...
Definition: Time_inlines.hh:65
static const long USECS_PER_SEC
Number of microseconds in a second.
Definition: Time_defs.hh:112
Time & operator+=(const Time &y)
Adds y to *this.
Definition: Time_inlines.hh:70
Time operator+(const Time &x, const Time &y)
Returns the sum of x and y.
bool operator<(const Time &x, const Time &y)
Returns true if and only if x is shorter than y.
Time operator-(const Time &x, const Time &y)
Returns the difference of x and y or the null interval, if x is shorter than y.
A class for representing and manipulating positive time intervals.
Definition: Time_defs.hh:75
bool operator==(const Time &x, const Time &y)
Returns true if and only if x and y are equal.
Time & operator-=(const Time &y)
Subtracts y from *this; if *this is shorter than y, *this is set to the null interval.
Definition: Time_inlines.hh:84
The entire library is confined to this namespace.
Definition: version.hh:61
static const long CSECS_PER_SEC
Number of centiseconds in a second.
Definition: Time_defs.hh:115
bool operator>(const Time &x, const Time &y)
Returns true if and only if x is longer than y.
bool operator!=(const Time &x, const Time &y)
Returns true if and only if x and y are different.
bool operator>=(const Time &x, const Time &y)
Returns true if and only if x is longer than or equal to y.
long seconds() const
Returns the number of whole seconds contained in the represented time interval.
Definition: Time_inlines.hh:60
bool OK() const
Checks if all the invariants are satisfied.
Definition: Time.cc:30
bool operator<=(const Time &x, const Time &y)
Returns true if and only if x is shorter than or equal to y.