SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
statistic_node.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYDEVS_SYSTEMS_STATISTIC_NODE_H_
3 #define SYDEVS_SYSTEMS_STATISTIC_NODE_H_
4 
6 
7 namespace sydevs {
8 namespace systems {
9 
10 
19 template<typename T>
21 {
22 public:
35  statistic_node(const std::string& node_name, const node_context& external_context);
36 
38 
39  const T& value() const;
40 
41 private:
42  pointer val_;
43 
44  virtual void flow_event();
45 };
46 
47 
48 template<typename T>
49 inline statistic_node<T>::statistic_node(const std::string& node_name, const node_context& external_context)
50  : function_node(node_name, external_context)
51  , statistic("statistic", external_interface())
52  , val_()
53 {
54 }
55 
56 
57 template<typename T>
58 inline const T& statistic_node<T>::value() const
59 {
60  return val_.dereference<T>();
61 }
62 
63 
64 template<typename T>
66 {
67  val_ = qualified_type<T>::copy(statistic.value());
68 }
69 
70 
71 } // namespace
72 } // namespace
73 
74 #endif
const std::string & node_name() const
Returns the name of the node.
Definition: system_node.h:135
port< flow, input, T > statistic
The flow input port on which the statistic value is obtained.
Definition: statistic_node.h:37
A class template for nodes which accept statistic values.
Definition: statistic_node.h:20
static pointer copy(const T &X)
If T is a qualified type, returns a deep copy of X.
Definition: qualified_type.h:174
Definition: node_context.h:16
A base class for indivisible nodes in which function behavior is procedurally encoded.
Definition: function_node.h:21
statistic_node(const std::string &node_name, const node_context &external_context)
Constructs a statistic_node.
Definition: statistic_node.h:49
const T & value() const
Returns the statistic value.
Definition: statistic_node.h:58
A class template for flow input ports.
Definition: port.h:68
A data type which represents a pointer to anything.
Definition: pointer.h:27