A Discrete-Event Network Simulator
API
nstime.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef TIME_H
21 #define TIME_H
22 
23 #include "assert.h"
24 #include "attribute.h"
25 #include "attribute-helper.h"
26 #include "int64x64.h"
27 #include "unused.h"
28 #include <stdint.h>
29 #include <limits>
30 #include <cmath>
31 #include <ostream>
32 #include <set>
33 
41 namespace ns3 {
42 
43 class TimeWithUnit;
44 
102 class Time
103 {
104 public:
108  enum Unit
109  {
110  Y = 0,
111  D = 1,
112  H = 2,
113  MIN = 3,
114  S = 4,
115  MS = 5,
116  US = 6,
117  NS = 7,
118  PS = 8,
119  FS = 9,
120  LAST = 10
121  };
122 
128  inline Time & operator = (const Time & o)
129  {
130  m_data = o.m_data;
131  return *this;
132  }
134  inline Time ()
135  : m_data ()
136  {
137  if (g_markingTimes)
138  {
139  Mark (this);
140  }
141  }
147  inline Time(const Time & o)
148  : m_data (o.m_data)
149  {
150  if (g_markingTimes)
151  {
152  Mark (this);
153  }
154  }
155 
161  Time (Time &&o)
162  : m_data (o.m_data)
163  {
164  if (g_markingTimes)
165  {
166  Mark (this);
167  }
168  }
179  explicit inline Time (double v)
180  : m_data (lround (v))
181  {
182  if (g_markingTimes)
183  {
184  Mark (this);
185  }
186  }
187  explicit inline Time (int v)
188  : m_data (v)
189  {
190  if (g_markingTimes)
191  {
192  Mark (this);
193  }
194  }
195  explicit inline Time (long int v)
196  : m_data (v)
197  {
198  if (g_markingTimes)
199  {
200  Mark (this);
201  }
202  }
203  explicit inline Time (long long int v)
204  : m_data (v)
205  {
206  if (g_markingTimes)
207  {
208  Mark (this);
209  }
210  }
211  explicit inline Time (unsigned int v)
212  : m_data (v)
213  {
214  if (g_markingTimes)
215  {
216  Mark (this);
217  }
218  }
219  explicit inline Time (unsigned long int v)
220  : m_data (v)
221  {
222  if (g_markingTimes)
223  {
224  Mark (this);
225  }
226  }
227  explicit inline Time (unsigned long long int v)
228  : m_data (v)
229  {
230  if (g_markingTimes)
231  {
232  Mark (this);
233  }
234  }
235  explicit inline Time (const int64x64_t & v)
236  : m_data (v.GetHigh ())
237  {
238  if (g_markingTimes)
239  {
240  Mark (this);
241  }
242  }
265  explicit Time (const std::string & s);
266 
268  static Time Min ()
269  {
271  }
273  static Time Max ()
274  {
276  }
277 
279  ~Time ()
280  {
281  if (g_markingTimes)
282  {
283  Clear (this);
284  }
285  }
286 
288  inline bool IsZero (void) const
289  {
290  return m_data == 0;
291  }
293  inline bool IsNegative (void) const
294  {
295  return m_data <= 0;
296  }
298  inline bool IsPositive (void) const
299  {
300  return m_data >= 0;
301  }
303  inline bool IsStrictlyNegative (void) const
304  {
305  return m_data < 0;
306  }
308  inline bool IsStrictlyPositive (void) const
309  {
310  return m_data > 0;
311  }
318  inline int Compare (const Time & o) const
319  {
320  return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1;
321  }
322 
339  inline double GetYears (void) const
340  {
341  return ToDouble (Time::Y);
342  }
343  inline double GetDays (void) const
344  {
345  return ToDouble (Time::D);
346  }
347  inline double GetHours (void) const
348  {
349  return ToDouble (Time::H);
350  }
351  inline double GetMinutes (void) const
352  {
353  return ToDouble (Time::MIN);
354  }
355  inline double GetSeconds (void) const
356  {
357  return ToDouble (Time::S);
358  }
359  inline int64_t GetMilliSeconds (void) const
360  {
361  return ToInteger (Time::MS);
362  }
363  inline int64_t GetMicroSeconds (void) const
364  {
365  return ToInteger (Time::US);
366  }
367  inline int64_t GetNanoSeconds (void) const
368  {
369  return ToInteger (Time::NS);
370  }
371  inline int64_t GetPicoSeconds (void) const
372  {
373  return ToInteger (Time::PS);
374  }
375  inline int64_t GetFemtoSeconds (void) const
376  {
377  return ToInteger (Time::FS);
378  }
391  inline int64_t GetTimeStep (void) const
392  {
393  return m_data;
394  }
395  inline double GetDouble (void) const
396  {
397  return static_cast<double> (m_data);
398  }
399  inline int64_t GetInteger (void) const
400  {
401  return GetTimeStep ();
402  }
413  static void SetResolution (enum Unit resolution);
417  static enum Unit GetResolution (void);
418 
419 
426  inline static Time From (const int64x64_t & value)
427  {
428  return Time (value);
429  }
443  inline static Time FromInteger (uint64_t value, enum Unit unit)
444  {
445  struct Information *info = PeekInformation (unit);
446  if (info->fromMul)
447  {
448  value *= info->factor;
449  }
450  else
451  {
452  value /= info->factor;
453  }
454  return Time (value);
455  }
456  inline static Time FromDouble (double value, enum Unit unit)
457  {
458  return From (int64x64_t (value), unit);
459  }
460  inline static Time From (const int64x64_t & value, enum Unit unit)
461  {
462  struct Information *info = PeekInformation (unit);
463  // DO NOT REMOVE this temporary variable. It's here
464  // to work around a compiler bug in gcc 3.4
465  int64x64_t retval = value;
466  if (info->fromMul)
467  {
468  retval *= info->timeFrom;
469  }
470  else
471  {
472  retval.MulByInvert (info->timeFrom);
473  }
474  return Time (retval);
475  }
491  inline int64_t ToInteger (enum Unit unit) const
492  {
493  struct Information *info = PeekInformation (unit);
494  int64_t v = m_data;
495  if (info->toMul)
496  {
497  v *= info->factor;
498  }
499  else
500  {
501  v /= info->factor;
502  }
503  return v;
504  }
505  inline double ToDouble (enum Unit unit) const
506  {
507  return To (unit).GetDouble ();
508  }
509  inline int64x64_t To (enum Unit unit) const
510  {
511  struct Information *info = PeekInformation (unit);
512  int64x64_t retval = int64x64_t (m_data);
513  if (info->toMul)
514  {
515  retval *= info->timeTo;
516  }
517  else
518  {
519  retval.MulByInvert (info->timeTo);
520  }
521  return retval;
522  }
527  inline operator int64x64_t () const
528  {
529  return int64x64_t (m_data);
530  }
531 
532 
546  TimeWithUnit As (const enum Unit unit) const;
547 
553  typedef void (* TracedCallback)(Time value);
554 
555 private:
557  struct Information
558  {
559  bool toMul;
560  bool fromMul;
561  int64_t factor;
564  };
566  struct Resolution
567  {
570  };
571 
577  static inline struct Resolution *PeekResolution (void)
578  {
579  static struct Time::Resolution resolution = SetDefaultNsResolution ();
580  return & resolution;
581  }
588  static inline struct Information *PeekInformation (enum Unit timeUnit)
589  {
590  return & (PeekResolution ()->info[timeUnit]);
591  }
592 
598  static struct Resolution SetDefaultNsResolution (void);
606  static void SetResolution (enum Unit unit, struct Resolution *resolution,
607  const bool convert = true);
608 
628  typedef std::set< Time * > MarkedTimes;
644 public:
650  static bool StaticInit ();
651 private:
652 
653  /* Friend the Simulator class so it can call the private function
654  ClearMarkedTimes ()
655  */
656  friend class Simulator;
663  static void ClearMarkedTimes ();
668  static void Mark (Time * const time);
673  static void Clear (Time * const time);
678  static void ConvertTimes (const enum Unit unit);
679 
680  /*
681  * \name Arithmetic Operators
682  * Arithmetic operators between Times, and scaling by scalars.
683  */
691  friend bool operator == (const Time & lhs, const Time & rhs);
692  friend bool operator != (const Time & lhs, const Time & rhs);
693  friend bool operator <= (const Time & lhs, const Time & rhs);
694  friend bool operator >= (const Time & lhs, const Time & rhs);
695  friend bool operator < (const Time & lhs, const Time & rhs);
696  friend bool operator > (const Time & lhs, const Time & rhs);
697  friend Time operator + (const Time & lhs, const Time & rhs);
698  friend Time operator - (const Time & lhs, const Time & rhs);
699  friend Time operator * (const Time & lhs, const int64_t & rhs);
700  friend Time operator * (const int64_t & lhs, const Time & rhs);
701  friend Time operator * (const Time & lhs, const int64x64_t & rhs);
702  friend Time operator * (const int64x64_t & lhs, const Time & rhs);
703  friend int64x64_t operator / (const Time & lhs, const Time & rhs);
704  friend Time operator / (const Time & lhs, const int64_t & rhs);
705  friend Time operator / (const Time & lhs, const int64x64_t & rhs);
706  friend Time & operator += (Time & lhs, const Time & rhs);
707  friend Time & operator -= (Time & lhs, const Time & rhs);
715  friend Time Abs (const Time & time);
722  friend Time Max (const Time & ta, const Time & tb);
729  friend Time Min (const Time & ta, const Time & tb);
730 
731  int64_t m_data;
732 
733 }; // class Time
734 
735 namespace TracedValueCallback {
736 
743  typedef void (* Time)(Time oldValue, Time newValue);
744 
745 } // namespace TracedValueCallback
746 
748 static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
749 
760 inline bool
761 operator == (const Time & lhs, const Time & rhs)
762 {
763  return lhs.m_data == rhs.m_data;
764 }
772 inline bool
773 operator != (const Time & lhs, const Time & rhs)
774 {
775  return lhs.m_data != rhs.m_data;
776 }
784 inline bool
785 operator <= (const Time & lhs, const Time & rhs)
786 {
787  return lhs.m_data <= rhs.m_data;
788 }
796 inline bool
797 operator >= (const Time & lhs, const Time & rhs)
798 {
799  return lhs.m_data >= rhs.m_data;
800 }
808 inline bool
809 operator < (const Time & lhs, const Time & rhs)
810 {
811  return lhs.m_data < rhs.m_data;
812 }
820 inline bool
821 operator > (const Time & lhs, const Time & rhs)
822 {
823  return lhs.m_data > rhs.m_data;
824 }
832 inline Time operator + (const Time & lhs, const Time & rhs)
833 {
834  return Time (lhs.m_data + rhs.m_data);
835 }
843 inline Time operator - (const Time & lhs, const Time & rhs)
844 {
845  return Time (lhs.m_data - rhs.m_data);
846 }
854 inline Time
855 operator * (const Time & lhs, const int64_t & rhs)
856 {
857  Time res = lhs;
858  res.m_data *= rhs;
859  return res;
860 }
868 inline Time
869 operator * (const int64_t & lhs, const Time & rhs)
870 {
871  Time res = rhs;
872  res.m_data *= lhs;
873  return res;
874 }
882 inline Time
883 operator * (const Time & lhs, const int64x64_t & rhs)
884 {
885  int64x64_t res = lhs.m_data;
886  res *= rhs;
887  return Time (res);
888 }
896 inline Time
897 operator * (const int64x64_t & lhs, const Time & rhs)
898 {
899  return rhs * lhs;
900 }
908 inline int64x64_t
909 operator / (const Time & lhs, const Time & rhs)
910 {
911  int64x64_t num = lhs.m_data;
912  int64x64_t den = rhs.m_data;
913  return num / den;
914 }
922 inline Time
923 operator / (const Time & lhs, const int64_t & rhs)
924 {
925  Time res = lhs;
926  res.m_data /= rhs;
927  return res;
928 }
936 inline Time
937 operator / (const Time & lhs, const int64x64_t & rhs)
938 {
939  int64x64_t res = lhs.m_data;
940  res /= rhs;
941  return Time (res);
942 }
950 inline Time & operator += (Time & lhs, const Time & rhs)
951 {
952  lhs.m_data += rhs.m_data;
953  return lhs;
954 }
962 inline Time & operator -= (Time & lhs, const Time & rhs)
963 {
964  lhs.m_data -= rhs.m_data;
965  return lhs;
966 }
967 
968 inline Time Abs (const Time & time)
969 {
970  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
971 }
972 inline Time Max (const Time & ta, const Time & tb)
973 {
974  return Time ((ta.m_data < tb.m_data) ? tb : ta);
975 }
976 inline Time Min (const Time & ta, const Time & tb)
977 {
978  return Time ((ta.m_data > tb.m_data) ? tb : ta);
979 }
980 
997 std::ostream & operator << (std::ostream & os, const Time & time);
1008 std::istream & operator >> (std::istream & is, Time & time);
1009  // \ingroup time
1011 
1030 inline Time Years (double value)
1031 {
1032  return Time::FromDouble (value, Time::Y);
1033 }
1034 inline Time Years (int64x64_t value)
1035 {
1036  return Time::From (value, Time::Y);
1037 }
1038 inline Time Days (double value)
1039 {
1040  return Time::FromDouble (value, Time::D);
1041 }
1042 inline Time Days (int64x64_t value)
1043 {
1044  return Time::From (value, Time::D);
1045 }
1046 inline Time Hours (double value)
1047 {
1048  return Time::FromDouble (value, Time::H);
1049 }
1050 inline Time Hours (int64x64_t value)
1051 {
1052  return Time::From (value, Time::H);
1053 }
1054 inline Time Minutes (double value)
1055 {
1056  return Time::FromDouble (value, Time::MIN);
1057 }
1058 inline Time Minutes (int64x64_t value)
1059 {
1060  return Time::From (value, Time::MIN);
1061 }
1062 inline Time Seconds (double value)
1063 {
1064  return Time::FromDouble (value, Time::S);
1065 }
1066 inline Time Seconds (int64x64_t value)
1067 {
1068  return Time::From (value, Time::S);
1069 }
1070 inline Time MilliSeconds (uint64_t value)
1071 {
1072  return Time::FromInteger (value, Time::MS);
1073 }
1075 {
1076  return Time::From (value, Time::MS);
1077 }
1078 inline Time MicroSeconds (uint64_t value)
1079 {
1080  return Time::FromInteger (value, Time::US);
1081 }
1083 {
1084  return Time::From (value, Time::US);
1085 }
1086 inline Time NanoSeconds (uint64_t value)
1087 {
1088  return Time::FromInteger (value, Time::NS);
1089 }
1091 {
1092  return Time::From (value, Time::NS);
1093 }
1094 inline Time PicoSeconds (uint64_t value)
1095 {
1096  return Time::FromInteger (value, Time::PS);
1097 }
1099 {
1100  return Time::From (value, Time::PS);
1101 }
1102 inline Time FemtoSeconds (uint64_t value)
1103 {
1104  return Time::FromInteger (value, Time::FS);
1105 }
1107 {
1108  return Time::From (value, Time::FS);
1109 }
1119 inline Time TimeStep (uint64_t ts)
1120 {
1121  return Time (ts);
1122 }
1123 
1126 
1137 
1144 inline
1146 {
1147  return MakeTimeChecker (Time::Min (), Time::Max ());
1148 }
1149 
1157 inline
1159 {
1160  return MakeTimeChecker (min, Time::Max ());
1161 }
1162 
1168 {
1169 public:
1176  TimeWithUnit (const Time time, const Time::Unit unit)
1177  : m_time (time),
1178  m_unit (unit)
1179  { };
1180 
1181 private:
1182  Time m_time;
1184 
1191  friend std::ostream & operator << (std::ostream & os, const TimeWithUnit & timeU);
1192 
1193 }; // class TimeWithUnit
1194 
1195 } // namespace ns3
1196 
1197 #endif /* TIME_H */
int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
Definition: int64x64-128.h:373
static struct Resolution * PeekResolution(void)
Get the current Resolution.
Definition: nstime.h:577
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
nanosecond
Definition: nstime.h:117
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
microsecond
Definition: nstime.h:116
Control the scheduling of simulation events.
Definition: simulator.h:68
int64x64_t operator+(const int64x64_t &lhs)
Unary plus operator.
Definition: int64x64-128.h:410
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:399
friend Time operator*(const Time &lhs, const int64_t &rhs)
Multiplication operator for Time.
Definition: nstime.h:855
int64x64_t timeFrom
Multiplier to convert from this unit.
Definition: nstime.h:563
static Time Min()
Minimum representable Time.
Definition: nstime.h:268
A Time with attached unit, to facilitate output in that unit.
Definition: nstime.h:1167
#define min(a, b)
Definition: 80211b.c:42
int64_t ToInteger(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:491
day, 24 hours
Definition: nstime.h:111
High precision numerical type, implementing Q64.64 fixed precision.
Definition: int64x64-128.h:45
Forward calls to a chain of Callback.
friend bool operator<(const Time &lhs, const Time &rhs)
Less than operator for Time.
Definition: nstime.h:809
friend bool operator!=(const Time &lhs, const Time &rhs)
Inequality operator for Time.
Definition: nstime.h:773
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
#define ATTRIBUTE_VALUE_DEFINE(name)
Declare the attribute value class nameValue for the class name.
minute, 60 seconds
Definition: nstime.h:113
int64x64_t operator-(const int64x64_t &lhs)
Unary negation operator (change sign operator).
Definition: int64x64-128.h:418
static Time From(const int64x64_t &value)
Create a Time in the current unit.
Definition: nstime.h:426
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:505
bool IsStrictlyPositive(void) const
Definition: nstime.h:308
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:743
double GetYears(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:339
hour, 60 minutes
Definition: nstime.h:112
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:388
Time(unsigned long int v)
Construct from a numeric value.
Definition: nstime.h:219
Time(const int64x64_t &v)
Construct from a numeric value.
Definition: nstime.h:235
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition: int64x64.h:145
int64_t GetPicoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:371
friend Time operator-(const Time &lhs, const Time &rhs)
Difference operator for Time.
Definition: nstime.h:843
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:153
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
Time PicoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1094
struct Information info[LAST]
Conversion info from current unit.
Definition: nstime.h:568
static bool NS_UNUSED_GLOBAL(g_TimeStaticInit)
Force static initialization of Time.
friend Time operator+(const Time &lhs, const Time &rhs)
Addition operator for Time.
Definition: nstime.h:832
static Time Max()
Maximum representable Time.
Definition: nstime.h:273
friend Time Abs(const Time &time)
Absolute value function for Time.
Definition: nstime.h:968
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition: int64x64.h:137
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:108
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:197
Time(int v)
Construct from a numeric value.
Definition: nstime.h:187
Time Years(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1030
picosecond
Definition: nstime.h:118
year, 365 days
Definition: nstime.h:110
#define max(a, b)
Definition: 80211b.c:43
static enum Unit GetResolution(void)
Definition: time.cc:380
bool IsZero(void) const
Definition: nstime.h:288
friend Time & operator-=(Time &lhs, const Time &rhs)
Subtraction operator for Time.
Definition: nstime.h:962
Time(long long int v)
Construct from a numeric value.
Definition: nstime.h:203
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1086
Current time unit, and conversion info.
Definition: nstime.h:566
static bool StaticInit()
Function to force static initialization of Time.
Definition: time.cc:63
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
bool fromMul
Multiple when converting From, otherwise divide.
Definition: nstime.h:560
friend std::ostream & operator<<(std::ostream &os, const TimeWithUnit &timeU)
Output streamer.
Definition: time.cc:403
static Time From(const int64x64_t &value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:460
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:108
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
static void ConvertTimes(const enum Unit unit)
Convert existing Times to the new unit.
Definition: time.cc:343
friend bool operator>=(const Time &lhs, const Time &rhs)
Greater than or equal operator for Time.
Definition: nstime.h:797
double GetDouble(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:395
Time(long int v)
Construct from a numeric value.
Definition: nstime.h:195
static struct Resolution SetDefaultNsResolution(void)
Set the default resolution.
Definition: time.cc:170
int64_t factor
Ratio of this unit / current unit.
Definition: nstime.h:561
int64x64_t operator/(const int64x64_t &lhs, const int64x64_t &rhs)
Division operator.
Definition: int64x64.h:119
int64x64_t Abs(const int64x64_t &value)
Absolute value.
Definition: int64x64.h:184
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
friend int64x64_t operator/(const Time &lhs, const Time &rhs)
Division operator for Time.
Definition: nstime.h:909
double GetDays(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:343
Time(double v)
Construct from a numeric value.
Definition: nstime.h:179
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1471
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time(unsigned long long int v)
Construct from a numeric value.
Definition: nstime.h:227
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
friend Time & operator+=(Time &lhs, const Time &rhs)
Addition operator for Time.
Definition: nstime.h:950
friend bool operator==(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:761
Time Hours(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1046
Time TimeStep(uint64_t ts)
Definition: nstime.h:1119
Time()
Default constructor, with value 0.
Definition: nstime.h:134
~Time()
Destructor.
Definition: nstime.h:279
static struct Information * PeekInformation(enum Unit timeUnit)
Get the Information record for timeUnit for the current Resolution.
Definition: nstime.h:588
Attribute helper (ATTRIBUTE_ )macros definition.
Time Minutes(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1054
double max(double x, double y)
static Time FromDouble(double value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:456
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type.
Time(unsigned int v)
Construct from a numeric value.
Definition: nstime.h:211
static void Mark(Time *const time)
Record a Time instance with the MarkedTimes.
Definition: time.cc:287
friend bool operator>(const Time &lhs, const Time &rhs)
Greater than operator for Time.
Definition: nstime.h:821
double GetMinutes(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:351
int Compare(const Time &o) const
Compare this to another Time.
Definition: nstime.h:318
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:359
bool IsPositive(void) const
Definition: nstime.h:298
How to convert between other units and the current unit.
Definition: nstime.h:557
bool IsStrictlyNegative(void) const
Definition: nstime.h:303
static Time FromInteger(uint64_t value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:443
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition: int64x64-128.h:364
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:135
double GetDouble(void) const
Get this value as a double.
Definition: int64x64-128.h:203
enum Time::Unit unit
Current time unit.
Definition: nstime.h:569
Time::Unit m_unit
The unit to use in output.
Definition: nstime.h:1183
static void SetResolution(enum Unit resolution)
Definition: time.cc:180
double min(double x, double y)
int64x64_t To(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:509
static void Clear(Time *const time)
Remove a Time instance from the MarkedTimes, called by ~Time().
Definition: time.cc:313
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Definition: nstime.h:1176
int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
Definition: int64x64-128.h:382
second
Definition: nstime.h:114
std::set< Time *> MarkedTimes
Record all instances of Time, so we can rescale them when the resolution changes. ...
Definition: nstime.h:628
static MarkedTimes * g_markingTimes
Record of outstanding Time objects which will need conversion when the resolution is set...
Definition: nstime.h:643
Time Days(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1038
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1102
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:375
static void ClearMarkedTimes()
Remove all MarkedTimes.
Definition: time.cc:256
femtosecond
Definition: nstime.h:119
millisecond
Definition: nstime.h:115
friend bool operator<=(const Time &lhs, const Time &rhs)
Less than or equal operator for Time.
Definition: nstime.h:785
Declaration of the ns3::int64x64_t type and associated operators.
Time & operator=(const Time &o)
Assignment operator.
Definition: nstime.h:128
double GetHours(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:347
Time m_time
The time.
Definition: nstime.h:1179
int64x64_t timeTo
Multiplier to convert to this unit.
Definition: nstime.h:562
Time(const Time &o)
Copy constructor.
Definition: nstime.h:147
bool IsNegative(void) const
Definition: nstime.h:293
int64_t m_data
Virtual time value, in the current unit.
Definition: nstime.h:731
bool toMul
Multiply when converting To, otherwise divide.
Definition: nstime.h:559
Time(Time &&o)
Move constructor.
Definition: nstime.h:161
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:391
NS_UNUSED and NS_UNUSED_GLOBAL macro definitions.