A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 namespace ns3 {
35 
36 class TimeWithUnit;
37 
79 class Time
80 {
81 public:
85  enum Unit
86  {
87  Y = 0,
88  D = 1,
89  H = 2,
90  MIN = 3,
91  S = 4,
92  MS = 5,
93  US = 6,
94  NS = 7,
95  PS = 8,
96  FS = 9,
97  LAST = 10
98  };
99 
100  inline Time & operator = (const Time & o)
101  {
102  m_data = o.m_data;
103  return *this;
104  }
105  inline Time ()
106  : m_data ()
107  {
108  if (g_markingTimes)
109  {
110  Mark (this);
111  }
112  }
113  inline Time(const Time & o)
114  : m_data (o.m_data)
115  {
116  if (g_markingTimes)
117  {
118  Mark (this);
119  }
120  }
121  explicit inline Time (double v)
122  : m_data (lround (v))
123  {
124  if (g_markingTimes)
125  {
126  Mark (this);
127  }
128  }
129  explicit inline Time (int v)
130  : m_data (v)
131  {
132  if (g_markingTimes)
133  {
134  Mark (this);
135  }
136  }
137  explicit inline Time (long int v)
138  : m_data (v)
139  {
140  if (g_markingTimes)
141  {
142  Mark (this);
143  }
144  }
145  explicit inline Time (long long int v)
146  : m_data (v)
147  {
148  if (g_markingTimes)
149  {
150  Mark (this);
151  }
152  }
153  explicit inline Time (unsigned int v)
154  : m_data (v)
155  {
156  if (g_markingTimes)
157  {
158  Mark (this);
159  }
160  }
161  explicit inline Time (unsigned long int v)
162  : m_data (v)
163  {
164  if (g_markingTimes)
165  {
166  Mark (this);
167  }
168  }
169  explicit inline Time (unsigned long long int v)
170  : m_data (v)
171  {
172  if (g_markingTimes)
173  {
174  Mark (this);
175  }
176  }
197  explicit Time (const std::string & s);
198 
202  static Time Min ()
203  {
204  return Time (std::numeric_limits<int64_t>::min ());
205  }
209  static Time Max ()
210  {
211  return Time (std::numeric_limits<int64_t>::max ());
212  }
213 
217  ~Time ()
218  {
219  if (g_markingTimes)
220  {
221  Clear (this);
222  }
223  }
224 
228  inline bool IsZero (void) const
229  {
230  return m_data == 0;
231  }
235  inline bool IsNegative (void) const
236  {
237  return m_data <= 0;
238  }
242  inline bool IsPositive (void) const
243  {
244  return m_data >= 0;
245  }
249  inline bool IsStrictlyNegative (void) const
250  {
251  return m_data < 0;
252  }
256  inline bool IsStrictlyPositive (void) const
257  {
258  return m_data > 0;
259  }
263  inline int Compare (const Time & o) const
264  {
265  return (m_data < o.m_data) ? -1 : (m_data == o.m_data) ? 0 : 1;
266  }
267 
272  inline double GetSeconds (void) const
273  {
274  return ToDouble (Time::S);
275  }
276 
281  inline int64_t GetMilliSeconds (void) const
282  {
283  return ToInteger (Time::MS);
284  }
289  inline int64_t GetMicroSeconds (void) const
290  {
291  return ToInteger (Time::US);
292  }
297  inline int64_t GetNanoSeconds (void) const
298  {
299  return ToInteger (Time::NS);
300  }
305  inline int64_t GetPicoSeconds (void) const
306  {
307  return ToInteger (Time::PS);
308  }
313  inline int64_t GetFemtoSeconds (void) const
314  {
315  return ToInteger (Time::FS);
316  }
317 
322  inline double GetMinutes (void) const
323  {
324  return ToDouble (Time::MIN);
325  }
330  inline double GetHours (void) const
331  {
332  return ToDouble (Time::H);
333  }
338  inline double GetDays (void) const
339  {
340  return ToDouble (Time::D);
341  }
346  inline double GetYears (void) const
347  {
348  return ToDouble (Time::Y);
349  }
350 
354  inline int64_t GetTimeStep (void) const
355  {
356  return m_data;
357  }
358  inline double GetDouble (void) const
359  {
360  return m_data;
361  }
362  inline int64_t GetInteger (void) const
363  {
364  return GetTimeStep ();
365  }
366 
367 
375  static void SetResolution (enum Unit resolution);
379  static enum Unit GetResolution (void);
390  inline static Time FromInteger (uint64_t value, enum Unit timeUnit)
391  {
392  struct Information *info = PeekInformation (timeUnit);
393  if (info->fromMul)
394  {
395  value *= info->factor;
396  }
397  else
398  {
399  value /= info->factor;
400  }
401  return Time (value);
402  }
410  inline int64_t ToInteger (enum Unit timeUnit) const
411  {
412  struct Information *info = PeekInformation (timeUnit);
413  int64_t v = m_data;
414  if (info->toMul)
415  {
416  v *= info->factor;
417  }
418  else
419  {
420  v /= info->factor;
421  }
422  return v;
423  }
431  inline static Time FromDouble (double value, enum Unit timeUnit)
432  {
433  return From (int64x64_t (value), timeUnit);
434  }
442  inline double ToDouble (enum Unit timeUnit) const
443  {
444  return To (timeUnit).GetDouble ();
445  }
446  static inline Time From (const int64x64_t & from, enum Unit timeUnit)
447  {
448  struct Information *info = PeekInformation (timeUnit);
449  // DO NOT REMOVE this temporary variable. It's here
450  // to work around a compiler bug in gcc 3.4
451  int64x64_t retval = from;
452  if (info->fromMul)
453  {
454  retval *= info->timeFrom;
455  }
456  else
457  {
458  retval.MulByInvert (info->timeFrom);
459  }
460  return Time (retval);
461  }
462  inline int64x64_t To (enum Unit timeUnit) const
463  {
464  struct Information *info = PeekInformation (timeUnit);
465  int64x64_t retval = int64x64_t (m_data);
466  if (info->toMul)
467  {
468  retval *= info->timeTo;
469  }
470  else
471  {
472  retval.MulByInvert (info->timeTo);
473  }
474  return retval;
475  }
476  inline operator int64x64_t () const
477  {
478  return int64x64_t (m_data);
479  }
480  explicit inline Time (const int64x64_t & value)
481  : m_data (value.GetHigh ())
482  {
483  if (g_markingTimes)
484  {
485  Mark (this);
486  }
487  }
488  inline static Time From (const int64x64_t & value)
489  {
490  return Time (value);
491  }
492 
505  TimeWithUnit As (const enum Unit unit) const;
506 
507 private:
511  struct Information
512  {
513  bool toMul;
514  bool fromMul;
515  int64_t factor;
518  };
522  struct Resolution
523  {
526  };
527 
528  static inline struct Resolution *PeekResolution (void)
529  {
530  static struct Time::Resolution resolution = SetDefaultNsResolution ();
531  return & resolution;
532  }
533  static inline struct Information *PeekInformation (enum Unit timeUnit)
534  {
535  return & (PeekResolution ()->info[timeUnit]);
536  }
537 
538  static struct Resolution SetDefaultNsResolution (void);
539  static void SetResolution (enum Unit unit, struct Resolution *resolution,
540  const bool convert = true);
541 
561  typedef std::set< Time * > MarkedTimes;
577 public:
581  static bool StaticInit ();
582 private:
583 
584  /* Friend the Simulator class so it can call the private function
585  ClearMarkedTimes ()
586  */
587  friend class Simulator;
594  static void ClearMarkedTimes ();
598  static void Mark (Time * const time);
602  static void Clear (Time * const time);
606  static void ConvertTimes (const enum Unit unit);
607 
608  friend bool operator == (const Time & lhs, const Time & rhs);
609  friend bool operator != (const Time & lhs, const Time & rhs);
610  friend bool operator <= (const Time & lhs, const Time & rhs);
611  friend bool operator >= (const Time & lhs, const Time & rhs);
612  friend bool operator < (const Time & lhs, const Time & rhs);
613  friend bool operator > (const Time & lhs, const Time & rhs);
614  friend Time operator + (const Time & lhs, const Time & rhs);
615  friend Time operator - (const Time & lhs, const Time & rhs);
616  friend Time operator * (const Time & lhs, const int64_t & rhs);
617  friend Time operator * (const int64_t & lhs, const Time & rhs);
618  friend int64_t operator / (const Time & lhs, const Time & rhs);
619  friend Time operator / (const Time & lhs, const int64_t & rhs);
620  friend Time & operator += (Time & lhs, const Time & rhs);
621  friend Time & operator -= (Time & lhs, const Time & rhs);
622  friend Time Abs (const Time & time);
623  friend Time Max (const Time & ta, const Time & tb);
624  friend Time Min (const Time & ta, const Time & tb);
625 
626 
627  int64_t m_data;
628 
629 }; // class Time
630 
631 
633 static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
634 
635 inline bool
636 operator == (const Time & lhs, const Time & rhs)
637 {
638  return lhs.m_data == rhs.m_data;
639 }
640 inline bool
641 operator != (const Time & lhs, const Time & rhs)
642 {
643  return lhs.m_data != rhs.m_data;
644 }
645 inline bool
646 operator <= (const Time & lhs, const Time & rhs)
647 {
648  return lhs.m_data <= rhs.m_data;
649 }
650 inline bool
651 operator >= (const Time & lhs, const Time & rhs)
652 {
653  return lhs.m_data >= rhs.m_data;
654 }
655 inline bool
656 operator < (const Time & lhs, const Time & rhs)
657 {
658  return lhs.m_data < rhs.m_data;
659 }
660 inline bool
661 operator > (const Time & lhs, const Time & rhs)
662 {
663  return lhs.m_data > rhs.m_data;
664 }
665 inline Time operator + (const Time & lhs, const Time & rhs)
666 {
667  return Time (lhs.m_data + rhs.m_data);
668 }
669 inline Time operator - (const Time & lhs, const Time & rhs)
670 {
671  return Time (lhs.m_data - rhs.m_data);
672 }
673 inline Time
674 operator * (const Time & lhs, const int64_t & rhs)
675 {
676  Time res = lhs;
677  res.m_data *= rhs;
678  return res;
679 }
680 inline Time
681 operator * (const int64_t & lhs, const Time & rhs)
682 {
683  Time res = rhs;
684  res.m_data *= lhs;
685  return res;
686 }
687 inline int64_t
688 operator / (const Time & lhs, const Time & rhs)
689 {
690  int64_t res = lhs.m_data / rhs.m_data;
691  return res;
692 }
693 inline Time
694 operator / (const Time & lhs, const int64_t & rhs)
695 {
696  Time res = lhs;
697  res.m_data /= rhs;
698  return res;
699 }
700 inline Time & operator += (Time & lhs, const Time & rhs)
701 {
702  lhs.m_data += rhs.m_data;
703  return lhs;
704 }
705 inline Time & operator -= (Time & lhs, const Time & rhs)
706 {
707  lhs.m_data -= rhs.m_data;
708  return lhs;
709 }
710 
717 inline Time Max (const Time & ta, const Time & tb)
718 {
719  return Time ((ta.m_data < tb.m_data) ? tb : ta);
720 }
727 inline Time Min (const Time & ta, const Time & tb)
728 {
729  return Time ((ta.m_data > tb.m_data) ? tb : ta);
730 }
731 
737 inline Time Abs (const Time & time)
738 {
739  return Time ((time.m_data < 0) ? -time.m_data : time.m_data);
740 }
741 
754 std::ostream & operator<< (std::ostream & os, const Time & time);
761 std::istream & operator>> (std::istream & is, Time & time);
762 
774 inline Time Seconds (double seconds)
775 {
776  return Time::FromDouble (seconds, Time::S);
777 }
778 
790 inline Time MilliSeconds (uint64_t ms)
791 {
792  return Time::FromInteger (ms, Time::MS);
793 }
805 inline Time MicroSeconds (uint64_t us)
806 {
807  return Time::FromInteger (us, Time::US);
808 }
820 inline Time NanoSeconds (uint64_t ns)
821 {
822  return Time::FromInteger (ns, Time::NS);
823 }
835 inline Time PicoSeconds (uint64_t ps)
836 {
837  return Time::FromInteger (ps, Time::PS);
838 }
850 inline Time FemtoSeconds (uint64_t fs)
851 {
852  return Time::FromInteger (fs, Time::FS);
853 }
865 inline Time Minutes (double minutes)
866 {
867  return Time::FromDouble (minutes, Time::MIN);
868 }
880 inline Time Hours (double hours)
881 {
882  return Time::FromDouble (hours, Time::H);
883 }
895 inline Time Days (double days)
896 {
897  return Time::FromDouble (days, Time::D);
898 }
910 inline Time Years (double years)
911 {
912  return Time::FromDouble (years, Time::Y);
913 }
914 
919 inline Time Seconds (int64x64_t seconds)
920 {
921  return Time::From (seconds, Time::S);
922 }
928 {
929  return Time::From (ms, Time::MS);
930 }
936 {
937  return Time::From (us, Time::US);
938 }
944 {
945  return Time::From (ns, Time::NS);
946 }
952 {
953  return Time::From (ps, Time::PS);
954 }
960 {
961  return Time::From (fs, Time::FS);
962 }
967 inline Time Minutes (int64x64_t minutes)
968 {
969  return Time::From (minutes, Time::MIN);
970 }
975 inline Time Hours (int64x64_t hours)
976 {
977  return Time::From (hours, Time::H);
978 }
983 inline Time Days (int64x64_t days)
984 {
985  return Time::From (days, Time::D);
986 }
991 inline Time Years (int64x64_t years)
992 {
993  return Time::From (years, Time::Y);
994 }
995 
996 // internal function not publicly documented
997 inline Time TimeStep (uint64_t ts)
998 {
999  return Time (ts);
1000 }
1001 
1010 
1017 Ptr<const AttributeChecker> MakeTimeChecker (const Time min, const Time max);
1018 
1024 inline
1026 {
1027  return MakeTimeChecker (Time::Min (), Time::Max ());
1028 }
1029 
1035 inline
1037 {
1038  return MakeTimeChecker (min, Time::Max ());
1039 }
1040 
1046 {
1047 public:
1054  TimeWithUnit (const Time time, const Time::Unit unit)
1055  : m_time (time),
1056  m_unit (unit)
1057  { };
1058 
1059 private:
1060  Time m_time;
1062 
1064  friend std::ostream & operator << (std::ostream & os, const TimeWithUnit & time);
1065 
1066 }; // class TimeWithUnit
1067 
1068 } // namespace ns3
1069 
1070 #endif /* TIME_H */
static struct Resolution * PeekResolution(void)
Definition: nstime.h:528
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:774
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:49
nanosecond
Definition: nstime.h:94
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
bool IsPositive(void) const
Definition: nstime.h:242
microsecond
Definition: nstime.h:93
Time(const int64x64_t &value)
Definition: nstime.h:480
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
Definition: nstime.h:790
Time Minutes(double minutes)
create ns3::Time instances in units of minutes (equal to 60 seconds).
Definition: nstime.h:865
double ToDouble(enum Unit timeUnit) const
Definition: nstime.h:442
Control the scheduling of simulation events.
Definition: simulator.h:63
Time MilliSeconds(int64x64_t ms)
Definition: nstime.h:927
int64x64_t operator+(const int64x64_t &lhs)
Unary plus operator.
Definition: int64x64-128.h:381
friend Time operator*(const Time &lhs, const int64_t &rhs)
Definition: nstime.h:674
int64x64_t timeFrom
Multiplier to convert from this unit.
Definition: nstime.h:517
static Time Min()
Minimum representable Time.
Definition: nstime.h:202
A Time with attached unit, to facilitate output in that unit.
Definition: nstime.h:1045
Time TimeStep(uint64_t ts)
Definition: nstime.h:997
Time Minutes(int64x64_t minutes)
Definition: nstime.h:967
Time PicoSeconds(uint64_t ps)
create ns3::Time instances in units of picoseconds.
Definition: nstime.h:835
Time FemtoSeconds(int64x64_t fs)
Definition: nstime.h:959
day, 24 hours
Definition: nstime.h:88
High precision numerical type, implementing Q64.64 fixed precision.
Definition: int64x64-128.h:20
bool IsZero(void) const
Definition: nstime.h:228
friend bool operator<(const Time &lhs, const Time &rhs)
Definition: nstime.h:656
friend bool operator!=(const Time &lhs, const Time &rhs)
Definition: nstime.h:641
int64_t ToInteger(enum Unit timeUnit) const
Definition: nstime.h:410
Time Days(int64x64_t days)
Definition: nstime.h:983
minute, 60 seconds
Definition: nstime.h:90
int64x64_t operator-(const int64x64_t &lhs)
Unary negation operator (change sign operator)
Definition: int64x64-128.h:389
static Time From(const int64x64_t &value)
Definition: nstime.h:488
Time Years(double years)
create ns3::Time instances in units of years (equal to 365 days).
Definition: nstime.h:910
#define ATTRIBUTE_VALUE_DEFINE(Name)
Declare the attribute value class NameValue for the class Name
int64x64_t & operator+=(int64x64_t &lhs, const int64x64_t &rhs)
Compound addition operator.
Definition: int64x64-128.h:344
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:89
int64_t GetFemtoSeconds(void) const
Definition: nstime.h:313
Time NanoSeconds(int64x64_t ns)
Definition: nstime.h:943
double GetDouble(void) const
Get this value as a double.
Definition: int64x64-128.h:175
Time(unsigned long int v)
Definition: nstime.h:161
Time FemtoSeconds(uint64_t fs)
create ns3::Time instances in units of femtoseconds.
Definition: nstime.h:850
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
Definition: int64x64.h:154
int Compare(const Time &o) const
Definition: nstime.h:263
Time Seconds(int64x64_t seconds)
Definition: nstime.h:919
Time MicroSeconds(int64x64_t us)
Definition: nstime.h:935
friend Time operator-(const Time &lhs, const Time &rhs)
Definition: nstime.h:669
static Time FromDouble(double value, enum Unit timeUnit)
Definition: nstime.h:431
struct Information info[LAST]
Conversion info from current unit.
Definition: nstime.h:524
static bool NS_UNUSED_GLOBAL(g_TimeStaticInit)
Force static initialization of Time.
friend Time operator+(const Time &lhs, const Time &rhs)
Definition: nstime.h:665
static Time Max()
Maximum representable Time.
Definition: nstime.h:209
friend Time Abs(const Time &time)
Absolute value function for Time.
Definition: nstime.h:737
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
Definition: int64x64.h:146
double GetSeconds(void) const
Definition: nstime.h:272
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:117
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:194
Time(int v)
Definition: nstime.h:129
picosecond
Definition: nstime.h:95
year, 365 days
Definition: nstime.h:87
static enum Unit GetResolution(void)
Definition: time.cc:376
int64_t GetMicroSeconds(void) const
Definition: nstime.h:289
friend Time & operator-=(Time &lhs, const Time &rhs)
Definition: nstime.h:705
Time(long long int v)
Definition: nstime.h:145
Current time unit, and conversion info.
Definition: nstime.h:522
static bool StaticInit()
Function to force static initialization of Time.
Definition: time.cc:59
Time MicroSeconds(uint64_t us)
create ns3::Time instances in units of microseconds.
Definition: nstime.h:805
bool IsStrictlyPositive(void) const
Definition: nstime.h:256
bool fromMul
Multiple when converting From, otherwise divide.
Definition: nstime.h:514
Time NanoSeconds(uint64_t ns)
create ns3::Time instances in units of nanoseconds.
Definition: nstime.h:820
Ptr< SampleEmitter > s
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:85
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:204
static void ConvertTimes(const enum Unit unit)
Convert existing Times to the new unit.
Definition: time.cc:339
Time PicoSeconds(int64x64_t ps)
Definition: nstime.h:951
friend bool operator>=(const Time &lhs, const Time &rhs)
Definition: nstime.h:651
ATTRIBUTE_ACCESSOR_DEFINE(Boolean)
Time(long int v)
Definition: nstime.h:137
static struct Resolution SetDefaultNsResolution(void)
Definition: time.cc:166
int64_t factor
Ratio of this unit / current unit.
Definition: nstime.h:515
bool operator<(const int64x64_t &lhs, const int64x64_t &rhs)
Less than operator.
Definition: int64x64-128.h:327
int64x64_t operator/(const int64x64_t &lhs, const int64x64_t &rhs)
Division operator.
Definition: int64x64.h:128
int64x64_t Abs(const int64x64_t &value)
Absolute value.
Definition: int64x64.h:183
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:43
Time(double v)
Definition: nstime.h:121
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:1217
Time(unsigned long long int v)
Definition: nstime.h:169
Time Years(int64x64_t years)
Definition: nstime.h:991
friend Time & operator+=(Time &lhs, const Time &rhs)
Definition: nstime.h:700
friend bool operator==(const Time &lhs, const Time &rhs)
Definition: nstime.h:636
bool IsNegative(void) const
Definition: nstime.h:235
int64_t GetTimeStep(void) const
Definition: nstime.h:354
friend int64_t operator/(const Time &lhs, const Time &rhs)
Definition: nstime.h:688
double GetHours(void) const
Definition: nstime.h:330
Time Days(double days)
create ns3::Time instances in units of days (equal to 24 hours).
Definition: nstime.h:895
Time()
Definition: nstime.h:105
int64_t GetInteger(void) const
Definition: nstime.h:362
~Time()
Destructor.
Definition: nstime.h:217
double GetDouble(void) const
Definition: nstime.h:358
static struct Information * PeekInformation(enum Unit timeUnit)
Definition: nstime.h:533
int64_t GetNanoSeconds(void) const
Definition: nstime.h:297
Time(unsigned int v)
Definition: nstime.h:153
static void Mark(Time *const time)
Record a Time instance with the MarkedTimes.
Definition: time.cc:283
friend bool operator>(const Time &lhs, const Time &rhs)
Definition: nstime.h:661
static Time FromInteger(uint64_t value, enum Unit timeUnit)
Definition: nstime.h:390
Time Hours(double hours)
create ns3::Time instances in units of hours (equal to 60 minutes).
Definition: nstime.h:880
int64_t GetPicoSeconds(void) const
Definition: nstime.h:305
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:384
How to convert between other units and the current unit.
Definition: nstime.h:511
double GetDays(void) const
Definition: nstime.h:338
bool operator>(const int64x64_t &lhs, const int64x64_t &rhs)
Greater operator.
Definition: int64x64-128.h:335
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.cc:89
enum Time::Unit unit
Current time unit.
Definition: nstime.h:525
Time::Unit m_unit
The unit to use in output.
Definition: nstime.h:1061
bool IsStrictlyNegative(void) const
Definition: nstime.h:249
static void SetResolution(enum Unit resolution)
Definition: time.cc:176
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:441
static void Clear(Time *const time)
Remove a Time instance from the MarkedTimes, called by ~Time()
Definition: time.cc:309
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Definition: nstime.h:1054
second
Definition: nstime.h:91
friend std::ostream & operator<<(std::ostream &os, const TimeWithUnit &time)
Output streamer.
Definition: time.cc:399
std::set< Time * > MarkedTimes
Record all instances of Time, so we can rescale them when the resolution changes. ...
Definition: nstime.h:561
static MarkedTimes * g_markingTimes
Record of outstanding Time objects which will need conversion when the resolution is set...
Definition: nstime.h:576
double GetYears(void) const
Definition: nstime.h:346
Time Hours(int64x64_t hours)
Definition: nstime.h:975
static void ClearMarkedTimes()
Remove all MarkedTimes.
Definition: time.cc:252
femtosecond
Definition: nstime.h:96
millisecond
Definition: nstime.h:92
friend bool operator<=(const Time &lhs, const Time &rhs)
Definition: nstime.h:646
int64_t GetMilliSeconds(void) const
Definition: nstime.h:281
double GetMinutes(void) const
Definition: nstime.h:322
Time & operator=(const Time &o)
Definition: nstime.h:100
static Time From(const int64x64_t &from, enum Unit timeUnit)
Definition: nstime.h:446
Time m_time
The time.
Definition: nstime.h:1057
int64x64_t timeTo
Multiplier to convert to this unit.
Definition: nstime.h:516
Time(const Time &o)
Definition: nstime.h:113
int64_t m_data
Virtual time value, in the current unit.
Definition: nstime.h:627
bool toMul
Multiply when converting To, otherwise divide.
Definition: nstime.h:513
int64x64_t & operator-=(int64x64_t &lhs, const int64x64_t &rhs)
Compound subtraction operator.
Definition: int64x64-128.h:353
int64x64_t To(enum Unit timeUnit) const
Definition: nstime.h:462