SyDEVS  v0.6.5
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sydevs::systems::discrete_event_time Class Reference

A data structure which represents progress through a simulation, encapsulating both simulated time and a counter of events within a single point in simulated time. More...

#include <discrete_event_time.h>

Public Member Functions

 discrete_event_time ()
 Constructs a discrete_event_time object starting at time zero and a counter value of zero. More...
 
 discrete_event_time (const time_point &t)
 Constructs a discrete_event_time object starting at time t and a counter value of zero. More...
 
 discrete_event_time (const time_point &t, int64 c)
 Constructs a discrete_event_time object starting at time t and a counter value of c. More...
 
 discrete_event_time (const discrete_event_time &)=default
 Copy constructor. More...
 
discrete_event_timeoperator= (const discrete_event_time &)=default
 Copy assignment. More...
 
 discrete_event_time (discrete_event_time &&)=default
 Move constructor. More...
 
discrete_event_timeoperator= (discrete_event_time &&)=default
 Move assignment. More...
 
virtual ~discrete_event_time ()=default
 Destructor. More...
 
const time_pointt () const
 Return the current point in simulated time. More...
 
int64 t_index () const
 Return the index associated with the current point in simulated time. More...
 
int64 c () const
 Return the counter value of associated with the current point in simulated time. More...
 
void advance (duration dt, const time_point &end_t)
 Advance the simulated time point by dt, but not beyond end_t. More...
 
void advance ()
 Advance the counter without changing simulated time point. More...
 

Detailed Description

A data structure which represents progress through a simulation, encapsulating both simulated time and a counter of events within a single point in simulated time.

A discrete_event_time object tracks both a simulated time point and the number of events or steps that have occurred within that time point. Whenever the simulated time point advances, the counter of past events is reset to zero.

Below is an example of how a discrete_event_time object can be initialized and advanced.

auto start_t = time_point() + 100_s; // Define start time.
auto end_t = time_point() + 400_s; // Define end time.
auto event_time = discrete_event_time(start_t); // Initialize.
event_time.advance(57_s, end_t); // Advance to 57_s, 0
event_time.advance(); // Advance to 57_s, 1
event_time.advance(240_s, end_t); // Advance to 297_s, 0
event_time.advance(); // Advance to 297_s, 1
event_time.advance(); // Advance to 297_s, 2

Constructor & Destructor Documentation

sydevs::systems::discrete_event_time::discrete_event_time ( )
inline

Constructs a discrete_event_time object starting at time zero and a counter value of zero.

sydevs::systems::discrete_event_time::discrete_event_time ( const time_point t)
inline

Constructs a discrete_event_time object starting at time t and a counter value of zero.

sydevs::systems::discrete_event_time::discrete_event_time ( const time_point t,
int64  c 
)
inline

Constructs a discrete_event_time object starting at time t and a counter value of c.

sydevs::systems::discrete_event_time::discrete_event_time ( const discrete_event_time )
default

Copy constructor.

sydevs::systems::discrete_event_time::discrete_event_time ( discrete_event_time &&  )
default

Move constructor.

virtual sydevs::systems::discrete_event_time::~discrete_event_time ( )
virtualdefault

Destructor.

Member Function Documentation

void sydevs::systems::discrete_event_time::advance ( duration  dt,
const time_point end_t 
)
inline

Advance the simulated time point by dt, but not beyond end_t.

void sydevs::systems::discrete_event_time::advance ( )
inline

Advance the counter without changing simulated time point.

int64 sydevs::systems::discrete_event_time::c ( ) const
inline

Return the counter value of associated with the current point in simulated time.

discrete_event_time& sydevs::systems::discrete_event_time::operator= ( const discrete_event_time )
default

Copy assignment.

discrete_event_time& sydevs::systems::discrete_event_time::operator= ( discrete_event_time &&  )
default

Move assignment.

const time_point & sydevs::systems::discrete_event_time::t ( ) const
inline

Return the current point in simulated time.

int64 sydevs::systems::discrete_event_time::t_index ( ) const
inline

Return the index associated with the current point in simulated time.


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