SST/macro
|
A basic container for time (subject to future transplant). More...
#include <timestamp.h>
Public Types | |
enum | timestamp_param_type_t { exact } |
typedef int64_t | tick_t |
The type that holds a timestamp. More... | |
Public Member Functions | |
timestamp (double t) | |
Round the given time value (in seconds) to the nearest representable internal time. More... | |
timestamp (tick_t ticks, timestamp_param_type_t ty) | |
timestamp () | |
int64_t | ticks_int64 () const |
Convert a tick type to int64_t. More... | |
double | sec () const |
Return the current time in seconds. More... | |
double | msec () const |
Return the current time in milliseconds. More... | |
double | usec () const |
Return the current time in microseconds. More... | |
double | nsec () const |
Return the current time in nanoseconds. More... | |
double | psec () const |
Return the current time in picoseconds. More... | |
void | correct_round_off (const timestamp &now) |
tick_t | ticks () const |
Get the number of ticks. More... | |
bool | operator== (const timestamp &other) const |
Fast and exact comparison operations. More... | |
bool | operator!= (const timestamp &other) const |
bool | operator< (const timestamp &other) const |
bool | operator<= (const timestamp &other) const |
bool | operator> (const timestamp &other) const |
bool | operator>= (const timestamp &other) const |
timestamp & | operator+= (const timestamp &other) |
timestamp & | operator-= (const timestamp &other) |
timestamp & | operator*= (double scale) |
timestamp & | operator/= (double scale) |
Static Public Member Functions | |
static void | init_stamps (tick_t tick_spacing) |
static double | tick_interval_sec () |
static tick_t | tick_interval () |
Get the tick interval in picoseconds. More... | |
static int64_t | tick_interval_int64 () |
static const std::string & | tick_interval_string () |
Get the tick interval in std::string form (for example, "1ps"). More... | |
static tick_t | frequency () |
Get the number of ticks per second (1e12/tick_interval()). More... | |
static double | max_time () |
Get the largest time value possible (in seconds). More... | |
static double | min_time () |
Get the smallest (most negative) time value possible (in seconds). More... | |
static timestamp | exact_psec (int64_t psec) |
Get a time value corresponding exactly to the given number of picoseconds. More... | |
static timestamp | exact_nsec (int64_t nsec) |
Get a time value corresponding exactly to the given number of nanoseconds. More... | |
static timestamp | exact_usec (int64_t usec) |
Get a time value corresponding exactly to the given number of microseconds. More... | |
static timestamp | exact_msec (int64_t msec) |
Get a time value corresponding exactly to the given number of milliseconds. More... | |
static timestamp | exact_sec (int64_t sec) |
Get a time value corresponding exactly to the given number of seconds. More... | |
template<typename T > | |
static timestamp | exact_ticks (T val) |
Get a time value with exactly the given number of ticks. More... | |
Static Public Attributes | |
static tick_t | zero |
Static Private Member Functions | |
static timestamp | scaled_time (int64_t value, int64_t scaling, const char *caller, const char *units) |
Picoseconds between clock ticks. More... | |
Private Attributes | |
tick_t | ticks_ |
The current time value of this container in ticks. More... | |
A basic container for time (subject to future transplant).
Stores time as an integral number of picoseconds (tentatively). With 1 psec resolution, a 64 bit int can hold roughly +/- 106 days.
Intended to be reasonably compatible with ns3::HighPrecision time.
Definition at line 29 of file timestamp.h.
typedef int64_t sstmac::timestamp::tick_t |
The type that holds a timestamp.
Definition at line 33 of file timestamp.h.
Enumerator | |
---|---|
exact |
Definition at line 49 of file timestamp.h.
sstmac::timestamp::timestamp | ( | double | t | ) |
Round the given time value (in seconds) to the nearest representable internal time.
sprockit::time_error | if this time is outside the range that can can be represented with this time container |
|
explicit |
|
explicit |
void sstmac::timestamp::correct_round_off | ( | const timestamp & | now | ) |
|
static |
Get a time value corresponding exactly to the given number of milliseconds.
sprockit::time_error | if this time cannot be exactly represented. |
Referenced by ticks().
|
static |
Get a time value corresponding exactly to the given number of nanoseconds.
sprockit::time_error | if this time cannot be exactly represented. |
Referenced by ticks().
|
static |
Get a time value corresponding exactly to the given number of picoseconds.
sprockit::time_error | if this time cannot be exactly represented. |
Referenced by ticks().
|
static |
Get a time value corresponding exactly to the given number of seconds.
sprockit::time_error | if this time cannot be exactly represented. |
Referenced by ticks().
|
inlinestatic |
Get a time value with exactly the given number of ticks.
This is a template function to ensure that we do proper range checking on input values.
Definition at line 159 of file timestamp.h.
References ticks_.
|
static |
Get a time value corresponding exactly to the given number of microseconds.
sprockit::time_error | if this time cannot be exactly represented. |
Referenced by ticks().
|
static |
Get the number of ticks per second (1e12/tick_interval()).
Referenced by ticks().
|
static |
|
static |
Get the largest time value possible (in seconds).
Referenced by ticks().
|
static |
Get the smallest (most negative) time value possible (in seconds).
Referenced by ticks().
double sstmac::timestamp::msec | ( | ) | const |
Return the current time in milliseconds.
Referenced by ticks().
double sstmac::timestamp::nsec | ( | ) | const |
Return the current time in nanoseconds.
Referenced by ticks().
|
inline |
Definition at line 171 of file timestamp.h.
References ticks_.
timestamp& sstmac::timestamp::operator*= | ( | double | scale | ) |
Referenced by operator>=().
Referenced by operator>=().
Referenced by operator>=().
timestamp& sstmac::timestamp::operator/= | ( | double | scale | ) |
Referenced by operator>=().
|
inline |
Definition at line 175 of file timestamp.h.
References ticks_.
|
inline |
Definition at line 179 of file timestamp.h.
References ticks_.
|
inline |
Fast and exact comparison operations.
Definition at line 167 of file timestamp.h.
References ticks_.
|
inline |
Definition at line 183 of file timestamp.h.
References ticks_.
|
inline |
Definition at line 187 of file timestamp.h.
References sstmac::operator*(), operator*=(), sstmac::operator+(), operator+=(), sstmac::operator-(), operator-=(), sstmac::operator/(), operator/=(), sstmac::operator<<(), START_SERIALIZATION_NAMESPACE, ticks_, and sstmac::to_printf_type().
double sstmac::timestamp::psec | ( | ) | const |
Return the current time in picoseconds.
Referenced by ticks().
|
staticprivate |
Picoseconds between clock ticks.
double sstmac::timestamp::sec | ( | ) | const |
Return the current time in seconds.
Referenced by ticks().
|
static |
Get the tick interval in picoseconds.
Referenced by ticks().
|
static |
Referenced by ticks().
|
static |
Referenced by ticks().
|
static |
Get the tick interval in std::string form (for example, "1ps").
Referenced by ticks().
|
inline |
Get the number of ticks.
Definition at line 94 of file timestamp.h.
References exact_msec(), exact_nsec(), exact_psec(), exact_sec(), exact_usec(), frequency(), max_time(), min_time(), msec(), nsec(), psec(), sec(), tick_interval(), tick_interval_int64(), tick_interval_sec(), tick_interval_string(), ticks_, and usec().
int64_t sstmac::timestamp::ticks_int64 | ( | ) | const |
Convert a tick type to int64_t.
double sstmac::timestamp::usec | ( | ) | const |
Return the current time in microseconds.
Referenced by ticks().
|
private |
The current time value of this container in ticks.
Definition at line 43 of file timestamp.h.
Referenced by exact_ticks(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and ticks().
|
static |
Definition at line 63 of file timestamp.h.