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  }
166  explicit inline Time (double v)
167  : m_data (lround (v))
168  {
169  if (g_markingTimes)
170  {
171  Mark (this);
172  }
173  }
174  explicit inline Time (int v)
175  : m_data (v)
176  {
177  if (g_markingTimes)
178  {
179  Mark (this);
180  }
181  }
182  explicit inline Time (long int v)
183  : m_data (v)
184  {
185  if (g_markingTimes)
186  {
187  Mark (this);
188  }
189  }
190  explicit inline Time (long long int v)
191  : m_data (v)
192  {
193  if (g_markingTimes)
194  {
195  Mark (this);
196  }
197  }
198  explicit inline Time (unsigned int v)
199  : m_data (v)
200  {
201  if (g_markingTimes)
202  {
203  Mark (this);
204  }
205  }
206  explicit inline Time (unsigned long int v)
207  : m_data (v)
208  {
209  if (g_markingTimes)
210  {
211  Mark (this);
212  }
213  }
214  explicit inline Time (unsigned long long int v)
215  : m_data (v)
216  {
217  if (g_markingTimes)
218  {
219  Mark (this);
220  }
221  }
222  explicit inline Time (const int64x64_t & v)
223  : m_data (v.GetHigh ())
224  {
225  if (g_markingTimes)
226  {
227  Mark (this);
228  }
229  }
253  explicit Time (const std::string & s);
254 
256  static Time Min ()
257  {
258  return Time (std::numeric_limits<int64_t>::min ());
259  }
261  static Time Max ()
262  {
263  return Time (std::numeric_limits<int64_t>::max ());
264  }
265 
267  ~Time ()
268  {
269  if (g_markingTimes)
270  {
271  Clear (this);
272  }
273  }
274 
276  inline bool IsZero (void) const
277  {
278  return m_data == 0;
279  }
281  inline bool IsNegative (void) const
282  {
283  return m_data <= 0;
284  }
286  inline bool IsPositive (void) const
287  {
288  return m_data >= 0;
289  }
291  inline bool IsStrictlyNegative (void) const
292  {
293  return m_data < 0;
294  }
296  inline bool IsStrictlyPositive (void) const
297  {
298  return m_data > 0;
299  }
306  inline int Compare (const Time & o) const
307  {
308  return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1;
309  }
310 
318  inline double GetYears (void) const
319  {
320  return ToDouble (Time::Y);
321  }
322  inline double GetDays (void) const
323  {
324  return ToDouble (Time::D);
325  }
326  inline double GetHours (void) const
327  {
328  return ToDouble (Time::H);
329  }
330  inline double GetMinutes (void) const
331  {
332  return ToDouble (Time::MIN);
333  }
334  inline double GetSeconds (void) const
335  {
336  return ToDouble (Time::S);
337  }
338  inline int64_t GetMilliSeconds (void) const
339  {
340  return ToInteger (Time::MS);
341  }
342  inline int64_t GetMicroSeconds (void) const
343  {
344  return ToInteger (Time::US);
345  }
346  inline int64_t GetNanoSeconds (void) const
347  {
348  return ToInteger (Time::NS);
349  }
350  inline int64_t GetPicoSeconds (void) const
351  {
352  return ToInteger (Time::PS);
353  }
354  inline int64_t GetFemtoSeconds (void) const
355  {
356  return ToInteger (Time::FS);
357  }
364  inline int64_t GetTimeStep (void) const
365  {
366  return m_data;
367  }
368  inline double GetDouble (void) const
369  {
370  return m_data;
371  }
372  inline int64_t GetInteger (void) const
373  {
374  return GetTimeStep ();
375  }
386  static void SetResolution (enum Unit resolution);
390  static enum Unit GetResolution (void);
391 
392 
399  inline static Time From (const int64x64_t & value)
400  {
401  return Time (value);
402  }
411  inline static Time FromInteger (uint64_t value, enum Unit unit)
412  {
413  struct Information *info = PeekInformation (unit);
414  if (info->fromMul)
415  {
416  value *= info->factor;
417  }
418  else
419  {
420  value /= info->factor;
421  }
422  return Time (value);
423  }
424  inline static Time FromDouble (double value, enum Unit unit)
425  {
426  return From (int64x64_t (value), unit);
427  }
428  inline static Time From (const int64x64_t & value, enum Unit unit)
429  {
430  struct Information *info = PeekInformation (unit);
431  // DO NOT REMOVE this temporary variable. It's here
432  // to work around a compiler bug in gcc 3.4
433  int64x64_t retval = value;
434  if (info->fromMul)
435  {
436  retval *= info->timeFrom;
437  }
438  else
439  {
440  retval.MulByInvert (info->timeFrom);
441  }
442  return Time (retval);
443  }
454  inline int64_t ToInteger (enum Unit unit) const
455  {
456  struct Information *info = PeekInformation (unit);
457  int64_t v = m_data;
458  if (info->toMul)
459  {
460  v *= info->factor;
461  }
462  else
463  {
464  v /= info->factor;
465  }
466  return v;
467  }
468  inline double ToDouble (enum Unit unit) const
469  {
470  return To (unit).GetDouble ();
471  }
472  inline int64x64_t To (enum Unit unit) const
473  {
474  struct Information *info = PeekInformation (unit);
475  int64x64_t retval = int64x64_t (m_data);
476  if (info->toMul)
477  {
478  retval *= info->timeTo;
479  }
480  else
481  {
482  retval.MulByInvert (info->timeTo);
483  }
484  return retval;
485  }
490  inline operator int64x64_t () const
491  {
492  return int64x64_t (m_data);
493  }
494 
495 
509  TimeWithUnit As (const enum Unit unit) const;
510 
517  typedef void (* TracedValueCallback)(const Time oldValue,
518  const Time newValue);
519 
520 private:
522  struct Information
523  {
524  bool toMul;
525  bool fromMul;
526  int64_t factor;
529  };
531  struct Resolution
532  {
535  };
536 
542  static inline struct Resolution *PeekResolution (void)
543  {
544  static struct Time::Resolution resolution = SetDefaultNsResolution ();
545  return & resolution;
546  }
553  static inline struct Information *PeekInformation (enum Unit timeUnit)
554  {
555  return & (PeekResolution ()->info[timeUnit]);
556  }
557 
563  static struct Resolution SetDefaultNsResolution (void);
571  static void SetResolution (enum Unit unit, struct Resolution *resolution,
572  const bool convert = true);
573 
593  typedef std::set< Time * > MarkedTimes;
608  static MarkedTimes * g_markingTimes;
609 public:
615  static bool StaticInit ();
616 private:
617 
618  /* Friend the Simulator class so it can call the private function
619  ClearMarkedTimes ()
620  */
621  friend class Simulator;
628  static void ClearMarkedTimes ();
633  static void Mark (Time * const time);
638  static void Clear (Time * const time);
643  static void ConvertTimes (const enum Unit unit);
644 
652  friend bool operator == (const Time & lhs, const Time & rhs);
653  friend bool operator != (const Time & lhs, const Time & rhs);
654  friend bool operator <= (const Time & lhs, const Time & rhs);
655  friend bool operator >= (const Time & lhs, const Time & rhs);
656  friend bool operator < (const Time & lhs, const Time & rhs);
657  friend bool operator > (const Time & lhs, const Time & rhs);
658  friend Time operator + (const Time & lhs, const Time & rhs);
659  friend Time operator - (const Time & lhs, const Time & rhs);
660  friend Time operator * (const Time & lhs, const int64_t & rhs);
661  friend Time operator * (const int64_t & lhs, const Time & rhs);
662  friend int64_t operator / (const Time & lhs, const Time & rhs);
663  friend Time operator / (const Time & lhs, const int64_t & rhs);
664  friend Time & operator += (Time & lhs, const Time & rhs);
665  friend Time & operator -= (Time & lhs, const Time & rhs);
673  friend Time Abs (const Time & time);
680  friend Time Max (const Time & ta, const Time & tb);
687  friend Time Min (const Time & ta, const Time & tb);
688 
689  int64_t m_data;
690 
691 }; // class Time
692 
693 
695 static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
696 
697 inline bool
698 operator == (const Time & lhs, const Time & rhs)
699 {
700  return lhs.m_data == rhs.m_data;
701 }
702 inline bool
703 operator != (const Time & lhs, const Time & rhs)
704 {
705  return lhs.m_data != rhs.m_data;
706 }
707 inline bool
708 operator <= (const Time & lhs, const Time & rhs)
709 {
710  return lhs.m_data <= rhs.m_data;
711 }
712 inline bool
713 operator >= (const Time & lhs, const Time & rhs)
714 {
715  return lhs.m_data >= rhs.m_data;
716 }
717 inline bool
718 operator < (const Time & lhs, const Time & rhs)
719 {
720  return lhs.m_data < rhs.m_data;
721 }
722 inline bool
723 operator > (const Time & lhs, const Time & rhs)
724 {
725  return lhs.m_data > rhs.m_data;
726 }
727 inline Time operator + (const Time & lhs, const Time & rhs)
728 {
729  return Time (lhs.m_data + rhs.m_data);
730 }
731 inline Time operator - (const Time & lhs, const Time & rhs)
732 {
733  return Time (lhs.m_data - rhs.m_data);
734 }
735 inline Time
736 operator * (const Time & lhs, const int64_t & rhs)
737 {
738  Time res = lhs;
739  res.m_data *= rhs;
740  return res;
741 }
742 inline Time
743 operator * (const int64_t & lhs, const Time & rhs)
744 {
745  Time res = rhs;
746  res.m_data *= lhs;
747  return res;
748 }
749 inline int64_t
750 operator / (const Time & lhs, const Time & rhs)
751 {
752  int64_t res = lhs.m_data / rhs.m_data;
753  return res;
754 }
755 inline Time
756 operator / (const Time & lhs, const int64_t & rhs)
757 {
758  Time res = lhs;
759  res.m_data /= rhs;
760  return res;
761 }
762 inline Time & operator += (Time & lhs, const Time & rhs)
763 {
764  lhs.m_data += rhs.m_data;
765  return lhs;
766 }
767 inline Time & operator -= (Time & lhs, const Time & rhs)
768 {
769  lhs.m_data -= rhs.m_data;
770  return lhs;
771 }
772 
773 
774 inline Time Abs (const Time & time)
775 {
776  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
777 }
778 inline Time Max (const Time & ta, const Time & tb)
779 {
780  return Time ((ta.m_data < tb.m_data) ? tb : ta);
781 }
782 inline Time Min (const Time & ta, const Time & tb)
783 {
784  return Time ((ta.m_data > tb.m_data) ? tb : ta);
785 }
786 
803 std::ostream & operator << (std::ostream & os, const Time & time);
814 std::istream & operator >> (std::istream & is, Time & time);
815 
834 inline Time Years (double value)
835 {
836  return Time::FromDouble (value, Time::Y);
837 }
838 inline Time Years (int64x64_t value)
839 {
840  return Time::From (value, Time::Y);
841 }
842 inline Time Days (double value)
843 {
844  return Time::FromDouble (value, Time::D);
845 }
846 inline Time Days (int64x64_t value)
847 {
848  return Time::From (value, Time::D);
849 }
850 inline Time Hours (double value)
851 {
852  return Time::FromDouble (value, Time::H);
853 }
854 inline Time Hours (int64x64_t value)
855 {
856  return Time::From (value, Time::H);
857 }
858 inline Time Minutes (double value)
859 {
860  return Time::FromDouble (value, Time::MIN);
861 }
862 inline Time Minutes (int64x64_t value)
863 {
864  return Time::From (value, Time::MIN);
865 }
866 inline Time Seconds (double value)
867 {
868  return Time::FromDouble (value, Time::S);
869 }
870 inline Time Seconds (int64x64_t value)
871 {
872  return Time::From (value, Time::S);
873 }
874 inline Time MilliSeconds (uint64_t value)
875 {
876  return Time::FromInteger (value, Time::MS);
877 }
879 {
880  return Time::From (value, Time::MS);
881 }
882 inline Time MicroSeconds (uint64_t value)
883 {
884  return Time::FromInteger (value, Time::US);
885 }
887 {
888  return Time::From (value, Time::US);
889 }
890 inline Time NanoSeconds (uint64_t value)
891 {
892  return Time::FromInteger (value, Time::NS);
893 }
895 {
896  return Time::From (value, Time::NS);
897 }
898 inline Time PicoSeconds (uint64_t value)
899 {
900  return Time::FromInteger (value, Time::PS);
901 }
903 {
904  return Time::From (value, Time::PS);
905 }
906 inline Time FemtoSeconds (uint64_t value)
907 {
908  return Time::FromInteger (value, Time::FS);
909 }
911 {
912  return Time::From (value, Time::FS);
913 }
923 inline Time TimeStep (uint64_t ts)
924 {
925  return Time (ts);
926 }
927 
930 
941 
948 inline
950 {
951  return MakeTimeChecker (Time::Min (), Time::Max ());
952 }
953 
961 inline
963 {
964  return MakeTimeChecker (min, Time::Max ());
965 }
966 
972 {
973 public:
980  TimeWithUnit (const Time time, const Time::Unit unit)
981  : m_time (time),
982  m_unit (unit)
983  { };
984 
985 private:
986  Time m_time;
988 
995  friend std::ostream & operator << (std::ostream & os, const TimeWithUnit & timeU);
996 
997 }; // class TimeWithUnit
998 
999 } // namespace ns3
1000 
1001 #endif /* TIME_H */
static struct Resolution * PeekResolution(void)
Get the current Resolution.
Definition: nstime.h:542
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:108
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
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:286
Control the scheduling of simulation events.
Definition: simulator.h:70
int64x64_t operator+(const int64x64_t &lhs)
Unary plus operator.
Definition: int64x64-128.h:410
friend Time operator*(const Time &lhs, const int64_t &rhs)
Arithmetic operator.
Definition: nstime.h:736
int64x64_t timeFrom
Multiplier to convert from this unit.
Definition: nstime.h:528
static Time Min()
Minimum representable Time.
Definition: nstime.h:256
A Time with attached unit, to facilitate output in that unit.
Definition: nstime.h:971
int64_t ToInteger(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:454
High precision numerical type, implementing Q64.64 fixed precision.
Definition: int64x64-128.h:45
bool IsZero(void) const
Definition: nstime.h:276
friend bool operator<(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:718
friend bool operator!=(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:703
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:399
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:874
second
Definition: nstime.h:114
#define ATTRIBUTE_VALUE_DEFINE(Name)
Declare the attribute value class Value for the class Name.
int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
Definition: int64x64-128.h:373
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:354
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:206
Time(const int64x64_t &v)
Construct from a numeric value.
Definition: nstime.h:222
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition: int64x64.h:145
int Compare(const Time &o) const
Compare this to another Time.
Definition: nstime.h:306
millisecond
Definition: nstime.h:115
hour, 60 minutes
Definition: nstime.h:112
friend Time operator-(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:731
int64x64_t To(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:472
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:898
struct Information info[LAST]
Conversion info from current unit.
Definition: nstime.h:533
static bool NS_UNUSED_GLOBAL(g_TimeStaticInit)
Force static initialization of Time.
day, 24 hours
Definition: nstime.h:111
friend Time operator+(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:727
static Time Max()
Maximum representable Time.
Definition: nstime.h:261
friend Time Abs(const Time &time)
Absolute value function for Time.
Definition: nstime.h:774
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition: int64x64.h:137
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:334
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:174
Time Years(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:834
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:342
friend Time & operator-=(Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:767
Time(long long int v)
Construct from a numeric value.
Definition: nstime.h:190
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:890
Current time unit, and conversion info.
Definition: nstime.h:531
static bool StaticInit()
Function to force static initialization of Time.
Definition: time.cc:63
Definition of assertion macros NS_ASSERT() and NS_ASSERT_MSG().
bool IsStrictlyPositive(void) const
Definition: nstime.h:296
bool fromMul
Multiple when converting From, otherwise divide.
Definition: nstime.h:525
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:428
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:468
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
year, 365 days
Definition: nstime.h:110
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)
Arithmetic operator.
Definition: nstime.h:713
minute, 60 seconds
Definition: nstime.h:113
Time(long int v)
Construct from a numeric value.
Definition: nstime.h:182
static struct Resolution SetDefaultNsResolution(void)
Set the default resolution.
Definition: time.cc:170
femtosecond
Definition: nstime.h:119
int64_t factor
Ratio of this unit / current unit.
Definition: nstime.h:526
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition: int64x64-128.h:356
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
Time(double v)
Construct from a numeric value.
Definition: nstime.h:166
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:1278
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:214
friend Time & operator+=(Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:762
friend bool operator==(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:698
bool IsNegative(void) const
Definition: nstime.h:281
int64_t GetTimeStep(void) const
Definition: nstime.h:364
friend int64_t operator/(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:750
Time Hours(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:850
Time TimeStep(uint64_t ts)
Definition: nstime.h:923
double GetHours(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:326
Time()
Default constructor, with value 0.
Definition: nstime.h:134
int64_t GetInteger(void) const
Definition: nstime.h:372
~Time()
Destructor.
Definition: nstime.h:267
double GetDouble(void) const
Definition: nstime.h:368
static struct Information * PeekInformation(enum Unit timeUnit)
Get the Information record for timeUnit for the current Resolution.
Definition: nstime.h:553
Declaration of Attribute helper macros.
Time Minutes(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:858
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:346
static Time FromDouble(double value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:424
#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:198
static void Mark(Time *const time)
Record a Time instance with the MarkedTimes.
Definition: time.cc:287
microsecond
Definition: nstime.h:116
friend bool operator>(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:723
int64_t GetPicoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:350
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:388
void(* TracedValueCallback)(const Time oldValue, const Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:517
How to convert between other units and the current unit.
Definition: nstime.h:522
static Time FromInteger(uint64_t value, enum Unit unit)
Create a Time equal to value in unit unit.
Definition: nstime.h:411
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:866
double GetDays(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:322
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.cc:95
enum Time::Unit unit
Current time unit.
Definition: nstime.h:534
Time::Unit m_unit
The unit to use in output.
Definition: nstime.h:987
bool IsStrictlyNegative(void) const
Definition: nstime.h:291
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:882
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Definition: nstime.h:980
picosecond
Definition: nstime.h:118
nanosecond
Definition: nstime.h:117
std::set< Time * > MarkedTimes
Record all instances of Time, so we can rescale them when the resolution changes. ...
Definition: nstime.h:593
static MarkedTimes * g_markingTimes
Record of outstanding Time objects which will need conversion when the resolution is set...
Definition: nstime.h:608
Time Days(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:842
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:906
double GetYears(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:318
static void ClearMarkedTimes()
Remove all MarkedTimes.
Definition: time.cc:256
friend bool operator<=(const Time &lhs, const Time &rhs)
Arithmetic operator.
Definition: nstime.h:708
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:338
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:330
Time & operator=(const Time &o)
Assignment operator.
Definition: nstime.h:128
Time m_time
The time.
Definition: nstime.h:983
int64x64_t timeTo
Multiplier to convert to this unit.
Definition: nstime.h:527
Time(const Time &o)
Copy constructor.
Definition: nstime.h:147
int64_t m_data
Virtual time value, in the current unit.
Definition: nstime.h:689
bool toMul
Multiply when converting To, otherwise divide.
Definition: nstime.h:524
int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
Definition: int64x64-128.h:382
Definition of the NS_UNUSED NS_UNUSED_GLOBAL macros.