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 
645 public:
651  static bool StaticInit ();
652 
653 private:
654 
655  /* Friend the Simulator class so it can call the private function
656  ClearMarkedTimes ()
657  */
658  friend class Simulator;
665  static void ClearMarkedTimes ();
670  static void Mark (Time * const time);
675  static void Clear (Time * const time);
680  static void ConvertTimes (const enum Unit unit);
681 
682  /*
683  * \name Arithmetic Operators
684  * Arithmetic operators between Times, and scaling by scalars.
685  */
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 bool operator < (const Time & lhs, const Time & rhs);
698  friend bool operator > (const Time & lhs, const Time & rhs);
699  friend Time operator + (const Time & lhs, const Time & rhs);
700  friend Time operator - (const Time & lhs, const Time & rhs);
701  friend Time operator * (const Time & lhs, const int64_t & rhs);
702  friend Time operator * (const int64_t & lhs, const Time & rhs);
703  friend Time operator * (const Time & lhs, const int64x64_t & rhs);
704  friend Time operator * (const int64x64_t & lhs, const Time & rhs);
705  friend int64x64_t operator / (const Time & lhs, const Time & rhs);
706  friend Time operator / (const Time & lhs, const int64_t & rhs);
707  friend Time operator / (const Time & lhs, const int64x64_t & rhs);
708  friend Time & operator += (Time & lhs, const Time & rhs);
709  friend Time & operator -= (Time & lhs, const Time & rhs);
717  friend Time Abs (const Time & time);
724  friend Time Max (const Time & ta, const Time & tb);
731  friend Time Min (const Time & ta, const Time & tb);
732 
733  int64_t m_data;
734 
735 }; // class Time
736 
737 namespace TracedValueCallback {
738 
745 typedef void (* Time)(Time oldValue, Time newValue);
746 
747 } // namespace TracedValueCallback
748 
751 
762 inline bool
763 operator == (const Time & lhs, const Time & rhs)
764 {
765  return lhs.m_data == rhs.m_data;
766 }
774 inline bool
775 operator != (const Time & lhs, const Time & rhs)
776 {
777  return lhs.m_data != rhs.m_data;
778 }
786 inline bool
787 operator <= (const Time & lhs, const Time & rhs)
788 {
789  return lhs.m_data <= rhs.m_data;
790 }
798 inline bool
799 operator >= (const Time & lhs, const Time & rhs)
800 {
801  return lhs.m_data >= rhs.m_data;
802 }
810 inline bool
811 operator < (const Time & lhs, const Time & rhs)
812 {
813  return lhs.m_data < rhs.m_data;
814 }
822 inline bool
823 operator > (const Time & lhs, const Time & rhs)
824 {
825  return lhs.m_data > rhs.m_data;
826 }
834 inline Time operator + (const Time & lhs, const Time & rhs)
835 {
836  return Time (lhs.m_data + rhs.m_data);
837 }
845 inline Time operator - (const Time & lhs, const Time & rhs)
846 {
847  return Time (lhs.m_data - rhs.m_data);
848 }
856 inline Time
857 operator * (const Time & lhs, const int64_t & rhs)
858 {
859  Time res = lhs;
860  res.m_data *= rhs;
861  return res;
862 }
870 inline Time
871 operator * (const int64_t & lhs, const Time & rhs)
872 {
873  Time res = rhs;
874  res.m_data *= lhs;
875  return res;
876 }
884 inline Time
885 operator * (const Time & lhs, const int64x64_t & rhs)
886 {
887  int64x64_t res = lhs.m_data;
888  res *= rhs;
889  return Time (res);
890 }
898 inline Time
899 operator * (const int64x64_t & lhs, const Time & rhs)
900 {
901  return rhs * lhs;
902 }
910 inline int64x64_t
911 operator / (const Time & lhs, const Time & rhs)
912 {
913  int64x64_t num = lhs.m_data;
914  int64x64_t den = rhs.m_data;
915  return num / den;
916 }
924 inline Time
925 operator / (const Time & lhs, const int64_t & rhs)
926 {
927  Time res = lhs;
928  res.m_data /= rhs;
929  return res;
930 }
938 inline Time
939 operator / (const Time & lhs, const int64x64_t & rhs)
940 {
941  int64x64_t res = lhs.m_data;
942  res /= rhs;
943  return Time (res);
944 }
952 inline Time & operator += (Time & lhs, const Time & rhs)
953 {
954  lhs.m_data += rhs.m_data;
955  return lhs;
956 }
964 inline Time & operator -= (Time & lhs, const Time & rhs)
965 {
966  lhs.m_data -= rhs.m_data;
967  return lhs;
968 }
969 
970 inline Time Abs (const Time & time)
971 {
972  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
973 }
974 inline Time Max (const Time & ta, const Time & tb)
975 {
976  return Time ((ta.m_data < tb.m_data) ? tb : ta);
977 }
978 inline Time Min (const Time & ta, const Time & tb)
979 {
980  return Time ((ta.m_data > tb.m_data) ? tb : ta);
981 }
982 
999 std::ostream & operator << (std::ostream & os, const Time & time);
1010 std::istream & operator >> (std::istream & is, Time & time);
1011  // \ingroup time
1013 
1032 inline Time Years (double value)
1033 {
1034  return Time::FromDouble (value, Time::Y);
1035 }
1036 inline Time Years (int64x64_t value)
1037 {
1038  return Time::From (value, Time::Y);
1039 }
1040 inline Time Days (double value)
1041 {
1042  return Time::FromDouble (value, Time::D);
1043 }
1044 inline Time Days (int64x64_t value)
1045 {
1046  return Time::From (value, Time::D);
1047 }
1048 inline Time Hours (double value)
1049 {
1050  return Time::FromDouble (value, Time::H);
1051 }
1052 inline Time Hours (int64x64_t value)
1053 {
1054  return Time::From (value, Time::H);
1055 }
1056 inline Time Minutes (double value)
1057 {
1058  return Time::FromDouble (value, Time::MIN);
1059 }
1060 inline Time Minutes (int64x64_t value)
1061 {
1062  return Time::From (value, Time::MIN);
1063 }
1064 inline Time Seconds (double value)
1065 {
1066  return Time::FromDouble (value, Time::S);
1067 }
1068 inline Time Seconds (int64x64_t value)
1069 {
1070  return Time::From (value, Time::S);
1071 }
1072 inline Time MilliSeconds (uint64_t value)
1073 {
1074  return Time::FromInteger (value, Time::MS);
1075 }
1077 {
1078  return Time::From (value, Time::MS);
1079 }
1080 inline Time MicroSeconds (uint64_t value)
1081 {
1082  return Time::FromInteger (value, Time::US);
1083 }
1085 {
1086  return Time::From (value, Time::US);
1087 }
1088 inline Time NanoSeconds (uint64_t value)
1089 {
1090  return Time::FromInteger (value, Time::NS);
1091 }
1093 {
1094  return Time::From (value, Time::NS);
1095 }
1096 inline Time PicoSeconds (uint64_t value)
1097 {
1098  return Time::FromInteger (value, Time::PS);
1099 }
1101 {
1102  return Time::From (value, Time::PS);
1103 }
1104 inline Time FemtoSeconds (uint64_t value)
1105 {
1106  return Time::FromInteger (value, Time::FS);
1107 }
1109 {
1110  return Time::From (value, Time::FS);
1111 }
1121 inline Time TimeStep (uint64_t ts)
1122 {
1123  return Time (ts);
1124 }
1125 
1128 
1139 
1146 inline
1148 {
1149  return MakeTimeChecker (Time::Min (), Time::Max ());
1150 }
1151 
1159 inline
1161 {
1162  return MakeTimeChecker (min, Time::Max ());
1163 }
1164 
1170 {
1171 public:
1178  TimeWithUnit (const Time time, const Time::Unit unit)
1179  : m_time (time),
1180  m_unit (unit)
1181  { }
1182 
1183 private:
1186 
1193  friend std::ostream & operator << (std::ostream & os, const TimeWithUnit & timeU);
1194 
1195 }; // class TimeWithUnit
1196 
1197 } // namespace ns3
1198 
1199 #endif /* TIME_H */
int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
Definition: int64x64-128.h:377
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:414
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:399
#define NS_UNUSED_GLOBAL(x)
Mark a variable at file scope as unused.
Definition: unused.h:50
friend Time operator*(const Time &lhs, const int64_t &rhs)
Multiplication operator for Time.
Definition: nstime.h:857
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:1169
static bool g_TimeStaticInit
Force static initialization of Time.
Definition: nstime.h:750
#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:811
friend bool operator!=(const Time &lhs, const Time &rhs)
Inequality operator for Time.
Definition: nstime.h:775
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:422
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:1072
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:745
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:389
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:845
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:155
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:449
Time PicoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1096
struct Information info[LAST]
Conversion info from current unit.
Definition: nstime.h:568
friend Time operator+(const Time &lhs, const Time &rhs)
Addition operator for Time.
Definition: nstime.h:834
static Time Max()
Maximum representable Time.
Definition: nstime.h:273
friend Time Abs(const Time &time)
Absolute value function for Time.
Definition: nstime.h:970
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:1032
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:381
bool IsZero(void) const
Definition: nstime.h:288
friend Time & operator-=(Time &lhs, const Time &rhs)
Subtraction operator for Time.
Definition: nstime.h:964
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:1088
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:404
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:344
friend bool operator>=(const Time &lhs, const Time &rhs)
Greater than or equal operator for Time.
Definition: nstime.h:799
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:911
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:1592
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:952
friend bool operator==(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:763
Time Hours(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1048
Time TimeStep(uint64_t ts)
Definition: nstime.h:1121
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:1056
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:288
friend bool operator>(const Time &lhs, const Time &rhs)
Greater than operator for Time.
Definition: nstime.h:823
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:1064
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition: int64x64-128.h:368
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:137
double GetDouble(void) const
Get this value as a double.
Definition: int64x64-128.h:206
enum Time::Unit unit
Current time unit.
Definition: nstime.h:569
Time::Unit m_unit
The unit to use in output.
Definition: nstime.h:1185
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:314
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1080
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Definition: nstime.h:1178
int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
Definition: int64x64-128.h:386
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:1040
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1104
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:257
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:787
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:1184
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:733
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.