SST/macro
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | List of all members
sstmac::timestamp Class Reference

A basic container for time (subject to future transplant). More...

#include <timestamp.h>

Collaboration diagram for sstmac::timestamp:
Collaboration graph

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
 
timestampoperator+= (const timestamp &other)
 
timestampoperator-= (const timestamp &other)
 
timestampoperator*= (double scale)
 
timestampoperator/= (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...
 

Detailed Description

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.

Member Typedef Documentation

typedef int64_t sstmac::timestamp::tick_t

The type that holds a timestamp.

Definition at line 33 of file timestamp.h.

Member Enumeration Documentation

Enumerator
exact 

Definition at line 49 of file timestamp.h.

Constructor & Destructor Documentation

sstmac::timestamp::timestamp ( double  t)

Round the given time value (in seconds) to the nearest representable internal time.

Exceptions
sprockit::time_errorif this time is outside the range that can can be represented with this time container
sstmac::timestamp::timestamp ( tick_t  ticks,
timestamp_param_type_t  ty 
)
explicit
sstmac::timestamp::timestamp ( )
explicit

Member Function Documentation

void sstmac::timestamp::correct_round_off ( const timestamp now)
static timestamp sstmac::timestamp::exact_msec ( int64_t  msec)
static

Get a time value corresponding exactly to the given number of milliseconds.

Exceptions
sprockit::time_errorif this time cannot be exactly represented.

Referenced by ticks().

static timestamp sstmac::timestamp::exact_nsec ( int64_t  nsec)
static

Get a time value corresponding exactly to the given number of nanoseconds.

Exceptions
sprockit::time_errorif this time cannot be exactly represented.

Referenced by ticks().

static timestamp sstmac::timestamp::exact_psec ( int64_t  psec)
static

Get a time value corresponding exactly to the given number of picoseconds.

Exceptions
sprockit::time_errorif this time cannot be exactly represented.

Referenced by ticks().

static timestamp sstmac::timestamp::exact_sec ( int64_t  sec)
static

Get a time value corresponding exactly to the given number of seconds.

Exceptions
sprockit::time_errorif this time cannot be exactly represented.

Referenced by ticks().

template<typename T >
static timestamp sstmac::timestamp::exact_ticks ( val)
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 timestamp sstmac::timestamp::exact_usec ( int64_t  usec)
static

Get a time value corresponding exactly to the given number of microseconds.

Exceptions
sprockit::time_errorif this time cannot be exactly represented.

Referenced by ticks().

static tick_t sstmac::timestamp::frequency ( )
static

Get the number of ticks per second (1e12/tick_interval()).

Referenced by ticks().

static void sstmac::timestamp::init_stamps ( tick_t  tick_spacing)
static
static double sstmac::timestamp::max_time ( )
static

Get the largest time value possible (in seconds).

Referenced by ticks().

static double sstmac::timestamp::min_time ( )
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().

bool sstmac::timestamp::operator!= ( const timestamp other) const
inline

Definition at line 171 of file timestamp.h.

References ticks_.

timestamp& sstmac::timestamp::operator*= ( double  scale)

Referenced by operator>=().

timestamp& sstmac::timestamp::operator+= ( const timestamp other)

Referenced by operator>=().

timestamp& sstmac::timestamp::operator-= ( const timestamp other)

Referenced by operator>=().

timestamp& sstmac::timestamp::operator/= ( double  scale)

Referenced by operator>=().

bool sstmac::timestamp::operator< ( const timestamp other) const
inline

Definition at line 175 of file timestamp.h.

References ticks_.

bool sstmac::timestamp::operator<= ( const timestamp other) const
inline

Definition at line 179 of file timestamp.h.

References ticks_.

bool sstmac::timestamp::operator== ( const timestamp other) const
inline

Fast and exact comparison operations.

Definition at line 167 of file timestamp.h.

References ticks_.

bool sstmac::timestamp::operator> ( const timestamp other) const
inline

Definition at line 183 of file timestamp.h.

References ticks_.

bool sstmac::timestamp::operator>= ( const timestamp other) const
inline
double sstmac::timestamp::psec ( ) const

Return the current time in picoseconds.

Referenced by ticks().

static timestamp sstmac::timestamp::scaled_time ( int64_t  value,
int64_t  scaling,
const char *  caller,
const char *  units 
)
staticprivate

Picoseconds between clock ticks.

double sstmac::timestamp::sec ( ) const

Return the current time in seconds.

Referenced by ticks().

static tick_t sstmac::timestamp::tick_interval ( )
static

Get the tick interval in picoseconds.

Referenced by ticks().

static int64_t sstmac::timestamp::tick_interval_int64 ( )
static

Referenced by ticks().

static double sstmac::timestamp::tick_interval_sec ( )
static

Referenced by ticks().

static const std::string& sstmac::timestamp::tick_interval_string ( )
static

Get the tick interval in std::string form (for example, "1ps").

Referenced by ticks().

tick_t sstmac::timestamp::ticks ( ) const
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().

Here is the call graph for this function:

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().

Member Data Documentation

tick_t sstmac::timestamp::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().

tick_t sstmac::timestamp::zero
static

Definition at line 63 of file timestamp.h.


The documentation for this class was generated from the following file: