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

A base class for indivisible nodes in which simulation behavior is procedurally encoded. More...

#include <atomic_node.h>

Inherits sydevs::systems::system_node.

Public Member Functions

 atomic_node (const std::string &node_name, const node_context &external_context)
 Constructs an atomic_node. More...
 
virtual ~atomic_node ()=default
 Destructor. More...
 
void print_on_elapsed_duration (bool flag=true) const
 If flag is true, all elapsed durations are printed for this node. More...
 
void print_on_planned_duration (bool flag=true) const
 If flag is true, all planned durations are printed for this node. More...
 
data_mode node_dmode () const
 Returns message for all atomic nodes. More...
 
duration handle_initialization_event ()
 Invoked at the beginning of a simulation; calls initialization_event. More...
 
duration handle_unplanned_event (duration elapsed_dt)
 Invoked whenever a message is received; calls unplanned_event. More...
 
duration handle_planned_event (duration elapsed_dt)
 Invoked when the planned duration elapses; calls planned_event. More...
 
void handle_finalization_event (duration elapsed_dt)
 Invoked at the end of a simulation; calls finalization_event. More...
 
- Public Member Functions inherited from sydevs::systems::system_node
 system_node (const system_node &)=delete
 No copy constructor. More...
 
system_nodeoperator= (const system_node &)=delete
 No copy assignment. More...
 
 system_node (system_node &&)=delete
 No move constructor. More...
 
system_nodeoperator= (system_node &&)=delete
 No move assignment. More...
 
virtual ~system_node ()=default
 Destructor. More...
 
const std::string & node_name () const
 Returns the name of the node. More...
 
const std::string & full_name () const
 Returns the full name of the node, including parent nodes. More...
 
int64 node_index () const
 Returns the index of the node within the parent node. More...
 
const node_interfaceexternal_interface () const
 Returns the object responsible for exchanging information between the node and its surrounding context. More...
 
const timerevent_timer () const
 Returns the object that accumulated wallclock event durations. More...
 
template<typename T >
void print (const T &X)
 Prints X while indicating the simulation time and node. More...
 
void print (const char *raw_text)
 Prints raw_text while indicating the simulation time and node. More...
 
void print (const std::string &text)
 Prints text while indicating the simulation time and node. More...
 
void print_on_event (bool flag=true) const
 If flag is true, all event types are printed for this node. More...
 
void adopt_print_flags (const system_node &node) const
 Adopts the print flags of node. More...
 
virtual scale time_precision () const =0
 Returns the time precision associated with the node, or no_scale. More...
 
duration process_initialization_event ()
 Processes an initialization event; returns a planned duration. More...
 
duration process_unplanned_event (duration elapsed_dt)
 Processes an unplanned event after an elapsed duration elapsed_dt; returns a planned duration. More...
 
duration process_planned_event (duration elapsed_dt)
 Processes a planned event after an elapsed duration elapsed_dt; returns a planned duration. More...
 
void process_finalization_event (duration elapsed_dt)
 Processes a finalization event after an elapsed duration elapsed_dt. More...
 

Additional Inherited Members

- Protected Member Functions inherited from sydevs::systems::system_node
 system_node (const std::string &node_name, const node_context &external_context)
 Constructs a system_node. More...
 
node_interfaceexternal_IO () const
 Returns a non-const reference to the node's external interface. More...
 
timerET () const
 Returns a non-const reference to the node's event timer. More...
 
duration scale_planned_dt (duration planned_dt) const
 Adjusts the planned duration obtained from other nodes' event handlers. More...
 
- Protected Attributes inherited from sydevs::systems::system_node
std::mt19937 & rng
 Reference to the random number generator. More...
 

Detailed Description

A base class for indivisible nodes in which simulation behavior is procedurally encoded.

The atomic_node abstract base class is inherited by classes that represent system behavior using procedurally defined event handling functions. These event handlers are specified by overriding the following pure virtual member functions:

  • initialization_event, which is invoked during initialization and returns a planned duration;
  • unplanned_event, which is invoked when a message input is received and returns a planned duration.
  • planned_event, which is invoked when the previous planned duration elapses and returns a planned duration;
  • finalization, which is invoked during finalization.

Constructor & Destructor Documentation

sydevs::systems::atomic_node::atomic_node ( const std::string &  node_name,
const node_context external_context 
)
inline

Constructs an atomic_node.

The atomic node is created along with its associated node_interface object.

Parameters
node_nameThe name of the node within the encompassing context.
external_contextThe context in which the node is constructed.
virtual sydevs::systems::atomic_node::~atomic_node ( )
virtualdefault

Destructor.

Member Function Documentation

void sydevs::systems::atomic_node::handle_finalization_event ( duration  elapsed_dt)
virtual

Invoked at the end of a simulation; calls finalization_event.

Implements sydevs::systems::system_node.

duration sydevs::systems::atomic_node::handle_initialization_event ( )
virtual

Invoked at the beginning of a simulation; calls initialization_event.

Implements sydevs::systems::system_node.

duration sydevs::systems::atomic_node::handle_planned_event ( duration  elapsed_dt)
virtual

Invoked when the planned duration elapses; calls planned_event.

Implements sydevs::systems::system_node.

duration sydevs::systems::atomic_node::handle_unplanned_event ( duration  elapsed_dt)
virtual

Invoked whenever a message is received; calls unplanned_event.

Implements sydevs::systems::system_node.

data_mode sydevs::systems::atomic_node::node_dmode ( ) const
inlinevirtual

Returns message for all atomic nodes.

Implements sydevs::systems::system_node.

void sydevs::systems::atomic_node::print_on_elapsed_duration ( bool  flag = true) const
inline

If flag is true, all elapsed durations are printed for this node.

void sydevs::systems::atomic_node::print_on_planned_duration ( bool  flag = true) const
inline

If flag is true, all planned durations are printed for this node.


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