Samchon Framework for CPP  1.0.0
ParallelSystemArrayMediator.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/templates/parallel/ParallelSystemArray.hpp>
5 #include <samchon/templates/parallel/MediatorSystem.hpp>
6 
7 namespace samchon
8 {
9 namespace templates
10 {
11 namespace parallel
12 {
45  template <class System = ParallelSystem>
47  : public virtual ParallelSystemArray<System>
48  {
49  private:
51 
52  std::unique_ptr<MediatorSystem> mediator_;
53 
54  public:
55  /* ---------------------------------------------------------
56  CONSTRUCTORS
57  --------------------------------------------------------- */
62  : super()
63  {
64  };
65  virtual ~ParallelSystemArrayMediator() = default;
66 
67  protected:
89  virtual auto createMediator() -> MediatorSystem* = 0;
90 
97  virtual void startMediator()
98  {
99  if (mediator_ != nullptr)
100  return;
101 
102  mediator_.reset(createMediator());
103  mediator_->start();
104  };
105 
106  public:
107  /* ---------------------------------------------------------
108  ACCESSORS
109  --------------------------------------------------------- */
122  auto getMediator() const -> MediatorSystem*
123  {
124  return mediator_.get();
125  };
126 
127  protected:
128  /* ---------------------------------------------------------
129  HISTORY HANDLER
130  --------------------------------------------------------- */
131  virtual auto _Complete_history(std::shared_ptr<slave::InvokeHistory> history) -> bool override
132  {
133  bool ret = super::_Complete_history(history);
134  if (ret == true)
135  mediator_->_Complete_history(history->getUID());
136 
137  return ret;
138  };
139  };
140 };
141 };
142 };
virtual auto createMediator() -> MediatorSystem *=0
An Entity and a container of children Entity objects.
Definition: EntityGroup.hpp:40