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 
548 private:
550  struct Information
551  {
552  bool toMul;
553  bool fromMul;
554  int64_t factor;
557  };
559  struct Resolution
560  {
561  struct Information info[LAST];
562  enum Time::Unit unit;
563  };
564 
570  static inline struct Resolution *PeekResolution (void)
571  {
572  static struct Time::Resolution resolution = SetDefaultNsResolution ();
573  return & resolution;
574  }
581  static inline struct Information *PeekInformation (enum Unit timeUnit)
582  {
583  return & (PeekResolution ()->info[timeUnit]);
584  }
585 
591  static struct Resolution SetDefaultNsResolution (void);
599  static void SetResolution (enum Unit unit, struct Resolution *resolution,
600  const bool convert = true);
601 
621  typedef std::set< Time * > MarkedTimes;
636  static MarkedTimes * g_markingTimes;
637 public:
643  static bool StaticInit ();
644 private:
645 
646  /* Friend the Simulator class so it can call the private function
647  ClearMarkedTimes ()
648  */
649  friend class Simulator;
656  static void ClearMarkedTimes ();
661  static void Mark (Time * const time);
666  static void Clear (Time * const time);
671  static void ConvertTimes (const enum Unit unit);
672 
673  /*
674  * \name Arithmetic Operators
675  * Arithmetic operators between Times, and scaling by scalars.
676  */
684  friend bool operator == (const Time & lhs, const Time & rhs);
685  friend bool operator != (const Time & lhs, const Time & rhs);
686  friend bool operator <= (const Time & lhs, const Time & rhs);
687  friend bool operator >= (const Time & lhs, const Time & rhs);
688  friend bool operator < (const Time & lhs, const Time & rhs);
689  friend bool operator > (const Time & lhs, const Time & rhs);
690  friend Time operator + (const Time & lhs, const Time & rhs);
691  friend Time operator - (const Time & lhs, const Time & rhs);
692  friend Time operator * (const Time & lhs, const int64_t & rhs);
693  friend Time operator * (const int64_t & lhs, const Time & rhs);
694  friend int64_t operator / (const Time & lhs, const Time & rhs);
695  friend Time operator / (const Time & lhs, const int64_t & rhs);
696  friend Time & operator += (Time & lhs, const Time & rhs);
697  friend Time & operator -= (Time & lhs, const Time & rhs);
705  friend Time Abs (const Time & time);
712  friend Time Max (const Time & ta, const Time & tb);
719  friend Time Min (const Time & ta, const Time & tb);
720 
721  int64_t m_data;
722 
723 }; // class Time
724 
725 namespace TracedValueCallback {
726 
733  typedef void (* Time)(Time oldValue, Time newValue);
734 
735 } // namespace TracedValueCallback
736 
738 static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
739 
747 inline bool
748 operator == (const Time & lhs, const Time & rhs)
749 {
750  return lhs.m_data == rhs.m_data;
751 }
759 inline bool
760 operator != (const Time & lhs, const Time & rhs)
761 {
762  return lhs.m_data != rhs.m_data;
763 }
771 inline bool
772 operator <= (const Time & lhs, const Time & rhs)
773 {
774  return lhs.m_data <= rhs.m_data;
775 }
783 inline bool
784 operator >= (const Time & lhs, const Time & rhs)
785 {
786  return lhs.m_data >= rhs.m_data;
787 }
795 inline bool
796 operator < (const Time & lhs, const Time & rhs)
797 {
798  return lhs.m_data < rhs.m_data;
799 }
807 inline bool
808 operator > (const Time & lhs, const Time & rhs)
809 {
810  return lhs.m_data > rhs.m_data;
811 }
819 inline Time operator + (const Time & lhs, const Time & rhs)
820 {
821  return Time (lhs.m_data + rhs.m_data);
822 }
830 inline Time operator - (const Time & lhs, const Time & rhs)
831 {
832  return Time (lhs.m_data - rhs.m_data);
833 }
841 inline Time
842 operator * (const Time & lhs, const int64_t & rhs)
843 {
844  Time res = lhs;
845  res.m_data *= rhs;
846  return res;
847 }
855 inline Time
856 operator * (const int64_t & lhs, const Time & rhs)
857 {
858  Time res = rhs;
859  res.m_data *= lhs;
860  return res;
861 }
869 inline int64_t
870 operator / (const Time & lhs, const Time & rhs)
871 {
872  int64_t res = lhs.m_data / rhs.m_data;
873  return res;
874 }
882 inline Time
883 operator / (const Time & lhs, const int64_t & rhs)
884 {
885  Time res = lhs;
886  res.m_data /= rhs;
887  return res;
888 }
896 inline Time & operator += (Time & lhs, const Time & rhs)
897 {
898  lhs.m_data += rhs.m_data;
899  return lhs;
900 }
908 inline Time & operator -= (Time & lhs, const Time & rhs)
909 {
910  lhs.m_data -= rhs.m_data;
911  return lhs;
912 }
915 inline Time Abs (const Time & time)
916 {
917  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
918 }
919 inline Time Max (const Time & ta, const Time & tb)
920 {
921  return Time ((ta.m_data < tb.m_data) ? tb : ta);
922 }
923 inline Time Min (const Time & ta, const Time & tb)
924 {
925  return Time ((ta.m_data > tb.m_data) ? tb : ta);
926 }
927 
944 std::ostream & operator << (std::ostream & os, const Time & time);
955 std::istream & operator >> (std::istream & is, Time & time);
956 
975 inline Time Years (double value)
976 {
977  return Time::FromDouble (value, Time::Y);
978 }
979 inline Time Years (int64x64_t value)
980 {
981  return Time::From (value, Time::Y);
982 }
983 inline Time Days (double value)
984 {
985  return Time::FromDouble (value, Time::D);
986 }
987 inline Time Days (int64x64_t value)
988 {
989  return Time::From (value, Time::D);
990 }
991 inline Time Hours (double value)
992 {
993  return Time::FromDouble (value, Time::H);
994 }
995 inline Time Hours (int64x64_t value)
996 {
997  return Time::From (value, Time::H);
998 }
999 inline Time Minutes (double value)
1000 {
1001  return Time::FromDouble (value, Time::MIN);
1002 }
1003 inline Time Minutes (int64x64_t value)
1004 {
1005  return Time::From (value, Time::MIN);
1006 }
1007 inline Time Seconds (double value)
1008 {
1009  return Time::FromDouble (value, Time::S);
1010 }
1011 inline Time Seconds (int64x64_t value)
1012 {
1013  return Time::From (value, Time::S);
1014 }
1015 inline Time MilliSeconds (uint64_t value)
1016 {
1017  return Time::FromInteger (value, Time::MS);
1018 }
1020 {
1021  return Time::From (value, Time::MS);
1022 }
1023 inline Time MicroSeconds (uint64_t value)
1024 {
1025  return Time::FromInteger (value, Time::US);
1026 }
1028 {
1029  return Time::From (value, Time::US);
1030 }
1031 inline Time NanoSeconds (uint64_t value)
1032 {
1033  return Time::FromInteger (value, Time::NS);
1034 }
1036 {
1037  return Time::From (value, Time::NS);
1038 }
1039 inline Time PicoSeconds (uint64_t value)
1040 {
1041  return Time::FromInteger (value, Time::PS);
1042 }
1044 {
1045  return Time::From (value, Time::PS);
1046 }
1047 inline Time FemtoSeconds (uint64_t value)
1048 {
1049  return Time::FromInteger (value, Time::FS);
1050 }
1052 {
1053  return Time::From (value, Time::FS);
1054 }
1064 inline Time TimeStep (uint64_t ts)
1065 {
1066  return Time (ts);
1067 }
1068 
1071 
1082 
1089 inline
1091 {
1092  return MakeTimeChecker (Time::Min (), Time::Max ());
1093 }
1094 
1102 inline
1104 {
1105  return MakeTimeChecker (min, Time::Max ());
1106 }
1107 
1113 {
1114 public:
1121  TimeWithUnit (const Time time, const Time::Unit unit)
1122  : m_time (time),
1123  m_unit (unit)
1124  { };
1125 
1126 private:
1127  Time m_time;
1129 
1136  friend std::ostream & operator << (std::ostream & os, const TimeWithUnit & timeU);
1137 
1138 }; // class TimeWithUnit
1139 
1140 } // namespace ns3
1141 
1142 #endif /* TIME_H */
static struct Resolution * PeekResolution(void)
Get the current Resolution.
Definition: nstime.h:570
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
bool IsPositive(void) const
Definition: nstime.h:298
microsecond
Definition: nstime.h:116
Control the scheduling of simulation events.
Definition: simulator.h:68
friend Time operator*(const Time &lhs, const int64_t &rhs)
Multiplication operator for Time.
Definition: nstime.h:842
int64x64_t timeFrom
Multiplier to convert from this unit.
Definition: nstime.h:556
static Time Min()
Minimum representable Time.
Definition: nstime.h:268
A Time with attached unit, to facilitate output in that unit.
Definition: nstime.h:1112
int64_t ToInteger(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:491
#define min(a, b)
Definition: 80211b.c:42
day, 24 hours
Definition: nstime.h:111
High precision numerical type, implementing Q64.64 fixed precision.
Definition: int64x64-128.h:45
bool IsZero(void) const
Definition: nstime.h:288
friend bool operator<(const Time &lhs, const Time &rhs)
Less than operator for Time.
Definition: nstime.h:796
friend bool operator!=(const Time &lhs, const Time &rhs)
Inequality operator for Time.
Definition: nstime.h:760
#define ATTRIBUTE_VALUE_DEFINE(name)
Declare the attribute value class nameValue for the class name.
minute, 60 seconds
Definition: nstime.h:113
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:1015
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
hour, 60 minutes
Definition: nstime.h:112
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:375
double GetDouble(void) const
Get this value as a double.
Definition: int64x64-128.h:203
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
int Compare(const Time &o) const
Compare this to another Time.
Definition: nstime.h:318
double m_time
friend Time operator-(const Time &lhs, const Time &rhs)
Difference operator for Time.
Definition: nstime.h:830
int64x64_t To(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:509
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:1039
struct Information info[LAST]
Conversion info from current unit.
Definition: nstime.h:561
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:819
static Time Max()
Maximum representable Time.
Definition: nstime.h:273
friend Time Abs(const Time &time)
Absolute value function for Time.
Definition: nstime.h:915
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
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:975
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
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
friend Time & operator-=(Time &lhs, const Time &rhs)
Subtraction operator for Time.
Definition: nstime.h:908
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:1031
Current time unit, and conversion info.
Definition: nstime.h:559
static bool StaticInit()
Function to force static initialization of Time.
Definition: time.cc:63
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
bool IsStrictlyPositive(void) const
Definition: nstime.h:308
bool fromMul
Multiple when converting From, otherwise divide.
Definition: nstime.h:553
static Time From(const int64x64_t &value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:460
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:505
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:108
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:784
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:554
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Time(double v)
Construct from a numeric value.
Definition: nstime.h:179
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
friend Time & operator+=(Time &lhs, const Time &rhs)
Addition operator for Time.
Definition: nstime.h:896
friend bool operator==(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:748
bool IsNegative(void) const
Definition: nstime.h:293
int64_t GetTimeStep(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:391
friend int64_t operator/(const Time &lhs, const Time &rhs)
Division operator for Time.
Definition: nstime.h:870
Time Hours(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:991
Time TimeStep(uint64_t ts)
Definition: nstime.h:1064
double GetHours(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:347
Time()
Default constructor, with value 0.
Definition: nstime.h:134
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:399
~Time()
Destructor.
Definition: nstime.h:279
double GetDouble(void) const
Get the raw time value, in the current resolution unit.
Definition: nstime.h:395
static struct Information * PeekInformation(enum Unit timeUnit)
Get the Information record for timeUnit for the current Resolution.
Definition: nstime.h:581
Attribute helper (ATTRIBUTE_ )macros definition.
Time Minutes(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:999
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
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:808
int64_t GetPicoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:371
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:388
How to convert between other units and the current unit.
Definition: nstime.h:550
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:1007
double GetDays(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:343
Time::Unit m_unit
The unit to use in output.
Definition: nstime.h:1128
bool IsStrictlyNegative(void) const
Definition: nstime.h:303
static void SetResolution(enum Unit resolution)
Definition: time.cc:180
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:1023
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Definition: nstime.h:1121
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:621
static MarkedTimes * g_markingTimes
Record of outstanding Time objects which will need conversion when the resolution is set...
Definition: nstime.h:636
Time Days(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:983
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1047
double GetYears(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:339
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:772
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:359
Declaration of the ns3::int64x64_t type and associated operators.
double GetMinutes(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:351
Time & operator=(const Time &o)
Assignment operator.
Definition: nstime.h:128
Time m_time
The time.
Definition: nstime.h:1124
int64x64_t timeTo
Multiplier to convert to this unit.
Definition: nstime.h:555
Time(const Time &o)
Copy constructor.
Definition: nstime.h:147
int64_t m_data
Virtual time value, in the current unit.
Definition: nstime.h:721
bool toMul
Multiply when converting To, otherwise divide.
Definition: nstime.h:552
Time(Time &&o)
Move constructor.
Definition: nstime.h:161
NS_UNUSED and NS_UNUSED_GLOBAL macro definitions.