18#include "ns3/core-export.h"
194 explicit inline Time(
long int v)
203 explicit inline Time(
long long int v)
212 explicit inline Time(
unsigned int v)
221 explicit inline Time(
unsigned long int v)
230 explicit inline Time(
unsigned long long int v)
271 explicit Time(
const std::string& s);
280 return Time(std::numeric_limits<int64_t>::min());
290 return Time(std::numeric_limits<int64_t>::max());
355 return (m_data < o.
m_data) ? -1 : (m_data == o.
m_data) ? 0 : 1;
376 return ToDouble(Time::Y);
381 return ToDouble(Time::D);
386 return ToDouble(Time::H);
391 return ToDouble(Time::MIN);
396 return ToDouble(Time::S);
401 return ToInteger(Time::MS);
406 return ToInteger(Time::US);
411 return ToInteger(Time::NS);
416 return ToInteger(Time::PS);
421 return ToInteger(Time::FS);
443 return static_cast<double>(m_data);
448 return GetTimeStep();
460 static void SetResolution(
Unit resolution);
464 static Unit GetResolution();
596 return To(unit).GetDouble();
633 return From(this->To(unit).Round(), unit);
696 return &(PeekResolution()->info[timeUnit]);
704 static Resolution& SetDefaultNsResolution();
712 static void SetResolution(
Unit unit, Resolution* resolution,
const bool convert =
true);
764 static bool MarkingTimes();
772 static bool StaticInit();
791 static void ClearMarkedTimes();
796 static void Mark(
Time*
const time);
801 static void Clear(
Time*
const time);
806 static void ConvertTimes(
const Unit unit);
834 friend int64_t
Div(
const Time& lhs,
const Time& rhs);
838 friend std::enable_if_t<std::is_integral_v<T>,
Time>
operator*(
const Time& lhs, T rhs);
843 friend std::enable_if_t<std::is_arithmetic_v<T>,
Time>
operator*(T lhs,
const Time& rhs);
846 friend std::enable_if_t<std::is_integral_v<T>,
Time>
operator/(
const Time& lhs, T rhs);
856 friend std::enable_if_t<std::is_floating_point_v<T>,
Time>
operator*(
const Time& lhs, T rhs);
858 friend std::enable_if_t<std::is_floating_point_v<T>,
Time>
operator/(
const Time& lhs, T rhs);
873namespace TracedValueCallback
991 return static_cast<uint64_t
>(time.
m_data) < event.
GetTs();
1054std::enable_if_t<std::is_integral_v<T>,
Time>
1057 static_assert(!std::is_same_v<T, bool>,
"Multiplying a Time by a boolean is not supported");
1064std::enable_if_t<std::is_floating_point_v<T>,
Time>
1084std::enable_if_t<std::is_arithmetic_v<T>, Time>
1140std::enable_if_t<std::is_integral_v<T>,
Time>
1143 static_assert(!std::is_same_v<T, bool>,
"Dividing a Time by a boolean is not supported");
1150std::enable_if_t<std::is_floating_point_v<T>,
Time>
1489inline Ptr<const AttributeChecker>
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
Attribute helper (ATTRIBUTE_ )macros definition.
ns3::AttributeValue, ns3::AttributeAccessor and ns3::AttributeChecker declarations.
bool operator<(const Room &a, const Room &b)
An identifier for simulation events.
Smart pointer class similar to boost::intrusive_ptr.
Control the scheduling of simulation events.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
bool IsPositive() const
Exactly equivalent to t >= 0.
Time(const Time &o)
Copy constructor.
Time(const int64x64_t &v)
Construct from a numeric value.
Time(unsigned long int v)
Construct from a numeric value.
static Time From(const int64x64_t &value)
Create a Time in the current unit.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time(long long int v)
Construct from a numeric value.
static Information * PeekInformation(Unit timeUnit)
Get the Information record for timeUnit for the current Resolution.
int64_t GetFemtoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64x64_t To(Unit unit) const
Get the Time value expressed in a particular unit.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Time & operator=(const Time &o)
Assignment operator.
Time TimeStep(uint64_t ts)
Scheduler interface.
Time(double v)
Construct from a numeric value.
int64_t GetInteger() const
Get the raw time value, in the current resolution unit.
bool IsNegative() const
Exactly equivalent to t <= 0.
static bool StaticInit()
Function to force static initialization of Time.
Time(unsigned long long int v)
Construct from a numeric value.
double GetMinutes() const
Get an approximation of the time stored in this instance in the indicated unit.
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
static Time From(const int64x64_t &value, Unit unit)
Create a Time equal to value in unit unit.
Unit
The unit to use to interpret a number representing time.
Time()
Default constructor, with value 0.
double GetDays() const
Get an approximation of the time stored in this instance in the indicated unit.
Time RoundTo(Unit unit) const
Round a Time to a specific unit.
static MarkedTimes * g_markingTimes
Record of outstanding Time objects which will need conversion when the resolution is set.
int64_t m_data
Virtual time value, in the current unit.
static Resolution * PeekResolution()
Get the current Resolution.
int64_t GetPicoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetYears() const
Get an approximation of the time stored in this instance in the indicated unit.
Time(int v)
Construct from a numeric value.
Time(Time &&o)
Move constructor.
int64_t ToInteger(Unit unit) const
Get the Time value expressed in a particular unit.
static Time FromInteger(uint64_t value, Unit unit)
Create a Time equal to value in unit unit.
bool IsStrictlyNegative() const
Exactly equivalent to t < 0.
Time(unsigned int v)
Construct from a numeric value.
int Compare(const Time &o) const
Compare this to another Time.
static Time FromDouble(double value, Unit unit)
Create a Time equal to value in unit unit.
double GetDouble() const
Get the raw time value, in the current resolution unit.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
double ToDouble(Unit unit) const
Get the Time value expressed in a particular unit.
bool IsZero() const
Exactly equivalent to t == 0.
int64_t GetTimeStep() const
Get the raw time value, in the current resolution unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Time(long int v)
Construct from a numeric value.
double GetHours() const
Get an approximation of the time stored in this instance in the indicated unit.
std::set< Time * > MarkedTimes
Record all instances of Time, so we can rescale them when the resolution changes.
A Time with attached unit, to facilitate output in that unit.
friend std::ostream & operator<<(std::ostream &os, const TimeWithUnit &timeU)
Output streamer.
TimeWithUnit(const Time time, const Time::Unit unit)
Attach a unit to a Time.
Time::Unit m_unit
The unit to use in output.
Forward calls to a chain of Callback.
High precision numerical type, implementing Q64.64 fixed precision.
void MulByInvert(const int64x64_t &o)
Multiply this value by a Q0.128 value, presumably representing an inverse, completing a division oper...
ns3::EventId declarations.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
#define ATTRIBUTE_ACCESSOR_DEFINE(type)
Define the attribute accessor functions MakeTypeAccessor for class type .
#define ATTRIBUTE_VALUE_DEFINE(name)
Declare the attribute value class nameValue for the class name
#define TYPENAMEGET_DEFINE(T)
Macro that defines a template specialization for TypeNameGet<T>() .
int64x64_t operator/(const int64x64_t &lhs, const int64x64_t &rhs)
Division operator.
bool operator>=(const int64x64_t &lhs, const int64x64_t &rhs)
Greater or equal operator.
bool operator<=(const int64x64_t &lhs, const int64x64_t &rhs)
Less or equal operator.
int64x64_t operator-(const int64x64_t &lhs, const int64x64_t &rhs)
Subtraction operator.
int64x64_t operator+(const int64x64_t &lhs, const int64x64_t &rhs)
Addition operator.
int64x64_t Abs(const int64x64_t &value)
Absolute value.
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
bool operator>(const Length &left, const Length &right)
Check if left has a value greater than right.
int64_t Div(const Length &numerator, const Length &denominator, Length *remainder)
Calculate how many times numerator can be split into denominator sized pieces.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Days(double value)
Construct a Time in the indicated unit.
Time Hours(double value)
Construct a Time in the indicated unit.
Time PicoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Minutes(double value)
Construct a Time in the indicated unit.
Time Years(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Declaration of the ns3::int64x64_t type and associated operators.
Length::Unit Unit
Save some typing by defining a short alias for Length::Unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time Rem(const Time &lhs, const Time &rhs)
Remainder (modulus) from the quotient of two Times.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Time operator%(const Time &lhs, const Time &rhs)
Remainder (modulus) from the quotient of two Times.
bool operator==(const EventId &a, const EventId &b)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Time & operator+=(Time &lhs, const Time &rhs)
Compound addition assignment for Time.
std::istream & operator>>(std::istream &is, Angles &a)
bool operator<(const EventId &a, const EventId &b)
Time & operator-=(Time &lhs, const Time &rhs)
Compound subtraction assignment for Time.
Current time unit, and conversion info.
Time::Unit unit
Current time unit.
ns3::TypeNameGet() function declarations.