Samchon Framework for CPP  1.0.0
MasterDriver.hpp
1 #pragma once
2 #include <samchon/templates/parallel/MediatorClient.hpp>
3 
4 #include <samchon/examples/interaction/base/MasterBase.hpp>
5 
6 namespace samchon
7 {
8 namespace examples
9 {
10 namespace interaction
11 {
12  class Mediator;
13 
14  class MasterDriver : public templates::parallel::MediatorClient
15  {
16  private:
17  typedef templates::parallel::MediatorClient super;
18 
19  int uid;
20 
21  public:
22  MasterDriver(Mediator *mediator, int port)
23  : super((templates::external::base::ExternalSystemArrayBase*)mediator, "127.0.0.1", port)
24  {
25  uid = -1;
26  };
27  virtual ~MasterDriver() = default;
28 
29  virtual void sendData(std::shared_ptr<protocol::Invoke> invoke) override
30  {
31  super::sendData(invoke);
32 
33  if (uid != -1)
34  getSystemArray<base::MasterBase>()->getMonitor()->reportSendData(uid, invoke);
35  };
36  virtual void replyData(std::shared_ptr<protocol::Invoke> invoke) override
37  {
38  if (invoke->getListener() == "set_master_uid")
39  uid = invoke->front()->getValue<int>();
40  else
41  super::replyData(invoke);
42  };
43  };
44 };
45 };
46 };
virtual void replyData(std::shared_ptr< Invoke >)=0
virtual void sendData(std::shared_ptr< Invoke >)=0