SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
atomic_node.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYDEVS_SYSTEMS_ATOMIC_NODE_H_
3 #define SYDEVS_SYSTEMS_ATOMIC_NODE_H_
4 
6 
7 namespace sydevs {
8 namespace systems {
9 
10 
29 class atomic_node : public system_node
30 {
31 public:
42  atomic_node(const std::string& node_name, const node_context& external_context);
43 
44  virtual ~atomic_node() = default;
45 
46  void print_on_elapsed_duration(bool flag = true) const;
47  void print_on_planned_duration(bool flag = true) const;
48 
49  data_mode node_dmode() const;
50 
54  void handle_finalization_event(duration elapsed_dt);
55 
56 private:
57  void adopt_component_print_flags(const system_node& node) const;
58 
59  virtual duration initialization_event() = 0;
60  virtual duration unplanned_event(duration elapsed_dt) = 0;
61  virtual duration planned_event(duration elapsed_dt) = 0;
62  virtual void finalization_event(duration elapsed_dt) = 0;
63 
64  bool initialized_;
65  bool finalized_;
66 };
67 
68 
69 inline atomic_node::atomic_node(const std::string& node_name, const node_context& external_context)
70  : system_node(node_name, external_context)
71  , initialized_(false)
72  , finalized_(false)
73 {
74 }
75 
76 
77 inline void atomic_node::print_on_elapsed_duration(bool flag) const
78 {
80 }
81 
82 
83 inline void atomic_node::print_on_planned_duration(bool flag) const
84 {
86 }
87 
88 
90 {
91  return message;
92 }
93 
94 
95 inline void atomic_node::adopt_component_print_flags(const system_node& node) const
96 {
97 }
98 
99 
100 } // namespace
101 } // namespace
102 
103 #endif
duration handle_planned_event(duration elapsed_dt)
Invoked when the planned duration elapses; calls planned_event.
Definition: atomic_node.cpp:32
const std::string & node_name() const
Returns the name of the node.
Definition: system_node.h:135
data_mode
Indicates the relevant data communication paradigm: dataflow (flow) or message-passing (message)...
Definition: data_mode.h:16
atomic_node(const std::string &node_name, const node_context &external_context)
Constructs an atomic_node.
Definition: atomic_node.h:69
A base class for all nodes from which systems models are constructed.
Definition: system_node.h:41
duration handle_unplanned_event(duration elapsed_dt)
Invoked whenever a message is received; calls unplanned_event.
Definition: atomic_node.cpp:20
A base class for indivisible nodes in which simulation behavior is procedurally encoded.
Definition: atomic_node.h:29
void print_on_planned_duration(bool flag=true) const
If flag is true, all planned durations are printed for this node.
Definition: atomic_node.h:83
void print_on_planned_duration(bool flag)
Definition: node_interface.cpp:396
data_mode node_dmode() const
Returns message for all atomic nodes.
Definition: atomic_node.h:89
Definition: node_context.h:16
void handle_finalization_event(duration elapsed_dt)
Invoked at the end of a simulation; calls finalization_event.
Definition: atomic_node.cpp:44
duration handle_initialization_event()
Invoked at the beginning of a simulation; calls initialization_event.
Definition: atomic_node.cpp:7
void print_on_elapsed_duration(bool flag=true) const
If flag is true, all elapsed durations are printed for this node.
Definition: atomic_node.h:77
Indicates message-passing.
virtual ~atomic_node()=default
Destructor.
void print_on_elapsed_duration(bool flag)
Definition: node_interface.cpp:376
node_interface & external_IO() const
Returns a non-const reference to the node's external interface.
Definition: system_node.h:288