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

A base class for all nodes defined as fixed-structure compositions of different types of nodes. More...

#include <composite_node.h>

Inherits sydevs::systems::system_node.

Public Member Functions

 composite_node (const std::string &node_name, const node_context &external_context)
 Constructs a composite_node. More...
 
virtual ~composite_node ()=default
 Destructor. More...
 
data_mode node_dmode () const
 Returns flow if all component nodes have data flow elements only, and message otherwise. More...
 
scale time_precision () const
 Returns no_scale for all composite nodes. More...
 
duration handle_initialization_event ()
 Invoked at the beginning of a simulation, calls process_initialization_event on all component nodes. More...
 
duration handle_unplanned_event (duration elapsed_dt)
 Invoked whenever a message is received; calls process_unplanned_event on receiving component nodes. More...
 
duration handle_planned_event (duration elapsed_dt)
 Invoked when the planned duration elapses; calls process_planned_event on the source node and propagates messages. More...
 
void handle_finalization_event (duration elapsed_dt)
 Invoked at the end of a simulation; calls process_finalization_event on all component nodes. 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...
 
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...
 
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

const node_contextinternal_context ()
 Returns a representation of the internal context, which is also the external context of the component nodes. More...
 
template<data_mode dmode, typename T >
void inward_link (const port< dmode, input, T > &src_port, const port< dmode, input, T > &dst_port)
 Constructs an inward link. More...
 
template<data_mode dmode, typename T >
void inner_link (const port< dmode, output, T > &src_port, const port< dmode, input, T > &dst_port)
 Constructs an inner link. More...
 
template<data_mode dmode, typename T >
void outward_link (const port< dmode, output, T > &src_port, const port< dmode, output, T > &dst_port)
 Constructs an outward link. More...
 
- 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...
 
duration scale_planned_dt (duration planned_dt) const
 Adjusts the planned duration obtained from other nodes' event handlers. More...
 

Additional Inherited Members

- Protected Attributes inherited from sydevs::systems::system_node
std::mt19937 & rng
 Reference to the random number generator. More...
 

Detailed Description

A base class for all nodes defined as fixed-structure compositions of different types of nodes.

The composite_node base class is inherited by classes that represent system behavior using networks of component nodes connected by links. The component nodes can be of an assortment of different types. The network itself has a fixed structure than cannot change duing a simulation.

Constructor & Destructor Documentation

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

Constructs a composite_node.

The composite 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::composite_node::~composite_node ( )
virtualdefault

Destructor.

Member Function Documentation

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

Invoked at the end of a simulation; calls process_finalization_event on all component nodes.

Implements sydevs::systems::system_node.

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

Invoked at the beginning of a simulation, calls process_initialization_event on all component nodes.

Implements sydevs::systems::system_node.

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

Invoked when the planned duration elapses; calls process_planned_event on the source node and propagates messages.

Implements sydevs::systems::system_node.

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

Invoked whenever a message is received; calls process_unplanned_event on receiving component nodes.

Implements sydevs::systems::system_node.

template<data_mode dmode, typename T >
void sydevs::systems::composite_node::inner_link ( const port< dmode, output, T > &  src_port,
const port< dmode, input, T > &  dst_port 
)
inlineprotected

Constructs an inner link.

An inner link is created from an output port on one of the component nodes to an input port on another component node.

Parameters
src_portThe source port on one of the component nodes.
dst_portThe destination port on one of the component nodes.
const node_context & sydevs::systems::composite_node::internal_context ( )
inlineprotected

Returns a representation of the internal context, which is also the external context of the component nodes.

template<data_mode dmode, typename T >
void sydevs::systems::composite_node::inward_link ( const port< dmode, input, T > &  src_port,
const port< dmode, input, T > &  dst_port 
)
inlineprotected

Constructs an inward link.

An inwward link is created from an input port on the interface of the composite node to an input port on one of the component nodes.

Parameters
src_portThe source port on the interface of the composite node.
dst_portThe destination port on one of the component nodes.
data_mode sydevs::systems::composite_node::node_dmode ( ) const
virtual

Returns flow if all component nodes have data flow elements only, and message otherwise.

Implements sydevs::systems::system_node.

template<data_mode dmode, typename T >
void sydevs::systems::composite_node::outward_link ( const port< dmode, output, T > &  src_port,
const port< dmode, output, T > &  dst_port 
)
inlineprotected

Constructs an outward link.

An outward link is created from an output port on one of the component nodes to an output port on the interface of the composite node.

Parameters
src_portThe source port on one of the component nodes.
dst_portThe destination port on the interface of the composite node.
scale sydevs::systems::composite_node::time_precision ( ) const
inlinevirtual

Returns no_scale for all composite nodes.

Implements sydevs::systems::system_node.


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