Samchon Framework for CPP  1.0.0
DSInvokeHistory.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/templates/slave/InvokeHistory.hpp>
5 
6 #include <samchon/templates/distributed/base/DistributedSystemArrayBase.hpp>
7 #include <samchon/templates/external/base/ExternalSystemBase.hpp>
8 
9 namespace samchon
10 {
11 namespace templates
12 {
13 namespace distributed
14 {
15  class DistributedSystem;
16  class DistributedProcess;
17 
34  : public slave::InvokeHistory
35  {
36  friend class DistributedSystem;
37 
38  private:
40 
41  DistributedSystem *system_;
42  DistributedProcess *process_;
43  double weight_;
44 
45  public:
46  /* ---------------------------------------------------------
47  CONSTRUCTORS
48  --------------------------------------------------------- */
55  : super()
56  {
57  this->system_ = system;
58  };
59 
68  DSInvokeHistory(DistributedSystem *system, DistributedProcess *process, std::shared_ptr<protocol::Invoke> invoke, double weight)
69  : super(invoke)
70  {
71  this->system_ = system;
72  this->process_ = process;
73  this->weight_ = weight;
74  };
75 
76  virtual ~DSInvokeHistory() = default;
77 
78  virtual void construct(std::shared_ptr<library::XML> xml) override
79  {
80  super::construct(xml);
81 
82  if (xml->hasProperty("process") == false)
83  {
84  process_ = nullptr;
85  return;
86  }
87 
88  std::string &process_name = xml->getProperty("process");
89  base::DistributedSystemArrayBase *system_array = ((external::base::ExternalSystemBase*)system)->getSystemArray<base::DistributedSystemArrayBase>();
90 
91  if (system_array->hasProcess(process_name) == true)
92  process_ = system_array->getProcess(process_name).get();
93  else
94  process_ = nullptr;
95  };
96 
97  /* ---------------------------------------------------------
98  ACCESSORS
99  --------------------------------------------------------- */
103  auto getSystem() const -> DistributedSystem*
104  {
105  return system_;
106  };
107 
112  {
113  return process_;
114  };
115 
121  auto getWeight() const -> double
122  {
123  return weight_;
124  };
125 
126  /* ---------------------------------------------------------
127  EXPORTERS
128  --------------------------------------------------------- */
129  virtual auto toXML() const -> std::shared_ptr<library::XML> override
130  {
131  std::shared_ptr<library::XML> &xml = super::toXML();
132  if (process_ != nullptr)
133  xml->setProperty("process", ((protocol::Entity<std::string>*)process_)->key());
134 
135  return xml;
136  };
137  };
138 };
139 };
140 };
auto getProcess() const -> DistributedProcess *
virtual auto key() const -> size_t override
Get a key that can identify the Entity uniquely.
DSInvokeHistory(DistributedSystem *system, DistributedProcess *process, std::shared_ptr< protocol::Invoke > invoke, double weight)
auto getSystem() const -> DistributedSystem *