Samchon Framework for CPP  1.0.0
MasterSystem.hpp
1 #pragma once
2 #include <samchon/templates/distributed/DistributedSystem.hpp>
3 #include <samchon/examples/interaction/base/SystemBase.hpp>
4 
5 #include <samchon/examples/interaction/base/ChiefBase.hpp>
6 
7 namespace samchon
8 {
9 namespace examples
10 {
11 namespace interaction
12 {
13  class Chief;
14 
15  class MasterSystem
16  : public templates::distributed::DistributedSystem,
17  public base::SystemBase
18  {
19  private:
20  typedef templates::distributed::DistributedSystem super;
21 
22  public:
23  /* ---------------------------------------------------------
24  CONSTRUCTORS
25  --------------------------------------------------------- */
26  MasterSystem(Chief *chief, std::shared_ptr<protocol::ClientDriver> driver)
27  : super((templates::external::base::ExternalSystemArrayBase*)chief, driver)
28  {
29  };
30 
31  virtual ~MasterSystem()
32  {
33  if (getUID() != -1)
34  getSystemArray<base::ChiefBase>()->getMonitor()->sendSystemStructure();
35  };
36 
37  virtual void construct(std::shared_ptr<library::XML> xml) override
38  {
39  setUID(xml->getProperty<int>("uid"));
40 
41  super::construct(xml);
42  };
43 
44  /* ---------------------------------------------------------
45  INVOKE MESSAGE CHAIN
46  --------------------------------------------------------- */
47  virtual void sendData(std::shared_ptr<protocol::Invoke> invoke) override
48  {
49  super::sendData(invoke);
50 
51  // NOTIFY SEND_DATA
52  getSystemArray<base::ChiefBase>()->getMonitor()->reportSendData(getUID(), invoke);
53  };
54  };
55 };
56 };
57 };
virtual void construct(std::shared_ptr< library::XML > xml) override
Construct data of the Entity from an XML object.
virtual void sendData(std::shared_ptr< Invoke >)=0
virtual void sendData(std::shared_ptr< protocol::Invoke > invoke) override