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

A base class for all nodes from which systems models are constructed. More...

#include <system_node.h>

Inherited by sydevs::systems::atomic_node, sydevs::systems::collection_node_base, sydevs::systems::composite_node, and sydevs::systems::function_node.

Classes

class  error
 

Public Member Functions

 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 data_mode node_dmode () const =0
 Returns flow if the node has data flow elements only, and message otherwise. 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...
 

Protected Member Functions

 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

std::mt19937 & rng
 Reference to the random number generator. More...
 

Detailed Description

A base class for all nodes from which systems models are constructed.

The system_node abstract base class is inherited by classes representing various types of system nodes:

Concrete derived classes must implement the following pure virtual member functions:

  • node_dmode, which distinguishes between flow (data flow, untimed) nodes and message (message passing, timed) nodes;
  • time_precision, which indicates the time quantum that must evenly divide all planned and elapsed durations associated with the node (unless the time precision is no_scale);
  • adopt_component_print_flags, which copies print flags from the components of another node to the components of this node.
  • handle_initialization_event, which is called at the beginning of a simulation;
  • handle_unplanned_event, which is called whenever a message is received;
  • handle_planned_event, which is called when the planned duration elapses;
  • handle_finalization_event, which is called at the end of a simulation.

Constructor & Destructor Documentation

sydevs::systems::system_node::system_node ( const system_node )
delete

No copy constructor.

sydevs::systems::system_node::system_node ( system_node &&  )
delete

No move constructor.

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

Destructor.

sydevs::systems::system_node::system_node ( const std::string &  node_name,
const node_context external_context 
)
inlineprotected

Constructs a system_node.

Constructs the system node and its associated node_interface object that associates the node with its surrounding context. The rng reference is connected with the main random number generator.

Parameters
node_nameThe name of the node within the encompassing context.
external_contextThe context in which the node is constructed.

Member Function Documentation

void sydevs::systems::system_node::adopt_print_flags ( const system_node node) const

Adopts the print flags of node.

timer & sydevs::systems::system_node::ET ( ) const
inlineprotected

Returns a non-const reference to the node's event timer.

const timer & sydevs::systems::system_node::event_timer ( ) const
inline

Returns the object that accumulated wallclock event durations.

const node_interface & sydevs::systems::system_node::external_interface ( ) const
inline

Returns the object responsible for exchanging information between the node and its surrounding context.

node_interface & sydevs::systems::system_node::external_IO ( ) const
inlineprotected

Returns a non-const reference to the node's external interface.

const std::string & sydevs::systems::system_node::full_name ( ) const
inline

Returns the full name of the node, including parent nodes.

virtual data_mode sydevs::systems::system_node::node_dmode ( ) const
pure virtual

Returns flow if the node has data flow elements only, and message otherwise.

Implemented in sydevs::systems::atomic_node, sydevs::systems::composite_node, sydevs::systems::function_node, and sydevs::systems::collection_node_base.

int64 sydevs::systems::system_node::node_index ( ) const
inline

Returns the index of the node within the parent node.

const std::string & sydevs::systems::system_node::node_name ( ) const
inline

Returns the name of the node.

system_node& sydevs::systems::system_node::operator= ( const system_node )
delete

No copy assignment.

system_node& sydevs::systems::system_node::operator= ( system_node &&  )
delete

No move assignment.

template<typename T >
void sydevs::systems::system_node::print ( const T &  X)
inline

Prints X while indicating the simulation time and node.

void sydevs::systems::system_node::print ( const char *  raw_text)
inline

Prints raw_text while indicating the simulation time and node.

void sydevs::systems::system_node::print ( const std::string &  text)
inline

Prints text while indicating the simulation time and node.

void sydevs::systems::system_node::print_on_event ( bool  flag = true) const
inline

If flag is true, all event types are printed for this node.

void sydevs::systems::system_node::process_finalization_event ( duration  elapsed_dt)
inline

Processes a finalization event after an elapsed duration elapsed_dt.

duration sydevs::systems::system_node::process_initialization_event ( )
inline

Processes an initialization event; returns a planned duration.

duration sydevs::systems::system_node::process_planned_event ( duration  elapsed_dt)
inline

Processes a planned event after an elapsed duration elapsed_dt; returns a planned duration.

duration sydevs::systems::system_node::process_unplanned_event ( duration  elapsed_dt)
inline

Processes an unplanned event after an elapsed duration elapsed_dt; returns a planned duration.

duration sydevs::systems::system_node::scale_planned_dt ( duration  planned_dt) const
protected

Adjusts the planned duration obtained from other nodes' event handlers.

Checks for errors in the planned duration planned_dt including e.g. invalidity, negativity, and loss of precision. Returns a duration that is equal except that the precision level is set to the node's time precision.

Parameters
planned_dtThe unscaled planned duration value.
Returns
A planned duration with a value equal to planned_dt, but where the precision level may be changed to match time_precision().
virtual scale sydevs::systems::system_node::time_precision ( ) const
pure virtual

Returns the time precision associated with the node, or no_scale.

Implemented in sydevs::systems::composite_node, and sydevs::systems::function_node.

Member Data Documentation

std::mt19937& sydevs::systems::system_node::rng
protected

Reference to the random number generator.


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