Samchon Framework for CPP  1.0.0
MediatorClient.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/templates/parallel/MediatorSystem.hpp>
5 #include <samchon/protocol/ServerConnector.hpp>
6 
7 namespace samchon
8 {
9 namespace templates
10 {
11 namespace parallel
12 {
23  : public MediatorSystem
24  {
25  private:
26  typedef MediatorSystem super;
27 
28  protected:
29  std::string ip_;
30  int port_;
31 
32  public:
33  /* ---------------------------------------------------------
34  CONSTRUCTORS
35  --------------------------------------------------------- */
43  MediatorClient(external::base::ExternalSystemArrayBase *system_array_, const std::string &ip, int port)
44  : super(system_array_)
45  {
46  this->ip_ = ip;
47  this->port_ = port;
48  };
49  virtual ~MediatorClient() = default;
50 
51  protected:
65  {
66  return new protocol::ServerConnector(this);
67  };
68 
69  public:
70  /* ---------------------------------------------------------
71  METHOD OF CONNECTOR
72  --------------------------------------------------------- */
73  virtual void start() override
74  {
75  if (communicator_ != nullptr)
76  return;
77 
79  communicator_.reset(connector);
80 
81  connector->connect(ip_, port_);
82  };
83  };
84 };
85 };
86 };
virtual auto createServerConnector() -> protocol::ServerConnector *
MediatorClient(external::base::ExternalSystemArrayBase *system_array_, const std::string &ip, int port)
virtual void connect(const std::string &ip, int port)