|
1 /* -*- Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */ |
|
2 /* |
|
3 * Copyright (c) 2005,2006 INRIA |
|
4 * All rights reserved. |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License version 2 as |
|
8 * published by the Free Software Foundation; |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 * |
|
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 */ |
|
21 #ifndef TIME_H |
|
22 #define TIME_H |
|
23 |
|
24 #include <stdint.h> |
|
25 |
|
26 namespace ns3 { |
|
27 |
|
28 /** |
|
29 * \brief simulation time |
|
30 * |
|
31 * This class is used by the user to specify when a scheduled event |
|
32 * is expected to expire (see ns3::Simulator::schedule). |
|
33 */ |
|
34 class Time { |
|
35 public: |
|
36 Time (Time const &o); |
|
37 Time &operator = (Time const &o); |
|
38 /** |
|
39 * \returns the time stored in this |
|
40 * instance as seconds. |
|
41 */ |
|
42 double s (void) const; |
|
43 /** |
|
44 * \returns the time stored in this |
|
45 * instance as microseconds. |
|
46 */ |
|
47 uint64_t us (void) const; |
|
48 /** |
|
49 * \returns the time stored in this |
|
50 * instance as nanoseconds. |
|
51 */ |
|
52 uint64_t ns (void) const; |
|
53 /** |
|
54 * \returns true if this instance represents |
|
55 * the "destroy" time. |
|
56 */ |
|
57 bool isDestroy (void) const; |
|
58 /** |
|
59 * \param s absolute time in seconds |
|
60 * \returns a constructed Time object |
|
61 */ |
|
62 static Time absS (double s); |
|
63 /** |
|
64 * \param us absolute time in microseconds |
|
65 * \returns a constructed Time object |
|
66 */ |
|
67 static Time absUs (uint64_t us); |
|
68 /** |
|
69 * \param ns absolute time in nanoseconds |
|
70 * \returns a constructed Time object |
|
71 */ |
|
72 static Time absNs (uint64_t ns); |
|
73 /** |
|
74 * \param s relative time in seconds |
|
75 * \returns a constructed Time object |
|
76 */ |
|
77 static Time relS (double s); |
|
78 /** |
|
79 * \param us relative time in microseconds |
|
80 * \returns a constructed Time object |
|
81 */ |
|
82 static Time relUs (uint64_t us); |
|
83 /** |
|
84 * \param ns relative time in nanoseconds |
|
85 * \returns a constructed Time object |
|
86 */ |
|
87 static Time relNs (uint64_t ns); |
|
88 /** |
|
89 * \returns a constructed Time object which represents |
|
90 * the current simulation time |
|
91 */ |
|
92 static Time now (void); |
|
93 /** |
|
94 * \returns a constructed Time object which represents |
|
95 * the current "destroy" simulation time, that |
|
96 * is, the time when Simulator::destroy is |
|
97 * invoked by the user. |
|
98 */ |
|
99 static Time destroy (void); |
|
100 private: |
|
101 Time (uint64_t ns); |
|
102 Time (); |
|
103 uint64_t m_ns; |
|
104 bool m_isDestroy; |
|
105 }; |
|
106 |
|
107 |
|
108 }; // namespace ns3 |
|
109 |
|
110 #endif /* TIME_H */ |