SyDEVS  v0.6.7
Multiscale Simulation and Systems Modeling Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
node_context.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef SYDEVS_SYSTEMS_NODE_CONTEXT_H_
3 #define SYDEVS_SYSTEMS_NODE_CONTEXT_H_
4 
7 #include <memory>
8 #include <random>
9 
10 namespace sydevs {
11 namespace systems {
12 
13 class node_interface;
14 
15 
17 {
18 public:
19  node_context(const time_point& start_t, int64 seed, std::ostream& stream);
21 
22  node_context(const node_context&) = delete;
23  node_context& operator=(const node_context&) = delete;
24  node_context(node_context&&) = delete;
25  node_context& operator=(node_context&&) = delete;
26  virtual ~node_context() = default;
27 
31  std::mt19937& rng();
32  bool& time_printed();
33  std::ostream& stream();
34 
35 private:
36  void initialize_rng(int64 seed);
37 
38  node_structure internal_structure_;
39  node_interface* external_interface_ptr_;
40  std::unique_ptr<discrete_event_time> event_t_unique_ptr_;
41  discrete_event_time* event_t_ptr_;
42  std::unique_ptr<std::mt19937> rng_unique_ptr_;
43  std::mt19937* rng_ptr_;
44  std::unique_ptr<bool> t_printed_unique_ptr_;
45  bool* t_printed_ptr_;
46  std::ostream& stream_;
47 };
48 
49 
51 {
52  return internal_structure_;
53 }
54 
55 
57 {
58  return external_interface_ptr_;
59 }
60 
61 
63 {
64  return *event_t_ptr_;
65 }
66 
67 
69 {
70  return *t_printed_ptr_;
71 }
72 
73 
74 inline std::mt19937& node_context::rng()
75 {
76  return *rng_ptr_;
77 }
78 
79 
80 inline std::ostream& node_context::stream()
81 {
82  return stream_;
83 }
84 
85 
86 } // namespace
87 } // namespace
88 
89 #endif
A data structure which represents progress through a simulation, encapsulating both simulated time an...
Definition: discrete_event_time.h:36
discrete_event_time & event_time()
Definition: node_context.h:62
virtual ~node_context()=default
Destructor.
A data structure which represents a point in time as an arbitrary-precision multiple of its shortest ...
Definition: time_point.h:84
std::mt19937 & rng()
Definition: node_context.h:74
node_structure & internal_structure()
Definition: node_context.h:50
bool & time_printed()
Definition: node_context.h:68
std::ostream & stream()
Definition: node_context.h:80
Definition: node_context.h:16
Definition: node_interface.h:16
node_interface * external_interface_ptr()
Definition: node_context.h:56
node_context(const time_point &start_t, int64 seed, std::ostream &stream)
Definition: node_context.cpp:10
Definition: node_structure.h:15
node_context & operator=(const node_context &)=delete
No copy assignment.