Samchon Framework for CPP  1.0.0
Viewer.hpp
1 #pragma once
2 #include <samchon/templates/external/ExternalSystem.hpp>
3 
4 #include <samchon/examples/interaction/base/MonitorBase.hpp>
5 #include <samchon/examples/interaction/base/ReporterBase.hpp>
6 #include <samchon/examples/interaction/base/SystemBase.hpp>
7 
8 #include <iostream>
9 
10 namespace samchon
11 {
12 namespace examples
13 {
14 namespace interaction
15 {
16  class Reporter;
17 
18  class Viewer : public templates::external::ExternalSystem
19  {
20  private:
21  typedef templates::external::ExternalSystem super;
22 
23  public:
24  /* ---------------------------------------------------------
25  CONSTRUCTORS
26  --------------------------------------------------------- */
27  Viewer(Reporter *reporter, std::shared_ptr<protocol::ClientDriver> driver)
28  : super((templates::external::base::ExternalSystemArrayBase*)reporter, driver)
29  {
30  std::cout << "A viewer has connected" << std::endl;
31 
32  //--------
33  // WHEN CONNECTED, THEN SEND SYSTEM STRUCTURE
34  //--------
35  System *system = ((base::MonitorBase*)(((base::ReporterBase*)reporter)->getMonitor()))->getRootSystem();
36  if (system == nullptr)
37  return;
38 
39  // SEND SYSTEM STRUCTURE OF ROOT.
40  sendData(std::make_shared<protocol::Invoke>("setSystems", ((base::SystemBase*)system)->toXML()));
41  };
42  virtual ~Viewer()
43  {
44  std::cout << "A veiwer has disconnected" << std::endl;
45  };
46 
47  protected:
48  virtual auto createChild(std::shared_ptr<library::XML>) -> templates::external::ExternalSystemRole* override
49  { // NO ROLE
50  return nullptr;
51  };
52  };
53 };
54 };
55 };
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
virtual void sendData(std::shared_ptr< protocol::Invoke > invoke) override