Samchon Framework for CPP  1.0.0
Reporter.hpp
1 #pragma once
2 #include <samchon/templates/external/ExternalClientArray.hpp>
3 # include <samchon/examples/interaction/Viewer.hpp>
4 #include <samchon/examples/interaction/base/ReporterBase.hpp>
5 
6 #include <samchon/examples/interaction/base/MonitorBase.hpp>
7 #include <samchon/examples/interaction/base/SystemBase.hpp>
8 
9 namespace samchon
10 {
11 namespace examples
12 {
13 namespace interaction
14 {
15  class Monitor;
16 
17  class Reporter
18  : public templates::external::ExternalClientArray<Viewer>,
19  public base::ReporterBase
20  {
21  private:
22  typedef templates::external::ExternalClientArray<Viewer> super;
23 
24  Monitor *monitor;
25 
26  public:
27  /* ---------------------------------------------------------
28  CONSTRUCTORS
29  --------------------------------------------------------- */
30  Reporter(Monitor *monitor) : super()
31  {
32  this->monitor = monitor;
33  };
34  virtual ~Reporter() = default;
35 
36  protected:
37  virtual auto createExternalClient(std::shared_ptr<protocol::ClientDriver> driver) -> Viewer* override
38  {
39  return new Viewer(this, driver);
40  };
41 
42  public:
43  /* ---------------------------------------------------------
44  ACCESSORS
45  --------------------------------------------------------- */
46  virtual auto getMonitor() const -> Monitor* override
47  {
48  return monitor;
49  };
50 
51  /* ---------------------------------------------------------
52  INVOKE MESSAGE CHAIN
53  --------------------------------------------------------- */
54  virtual void sendSystems() override final
55  {
56  System *root = ((base::MonitorBase*)monitor)->getRootSystem();
57  if (root == nullptr)
58  return;
59 
60  sendData(std::make_shared<protocol::Invoke>("setSystems", ((base::SystemBase*)root)->toXML()));
61  };
62 
63  virtual void replyData(std::shared_ptr<protocol::Invoke>)
64  {
65  // NOTHING TO DO
66  };
67  };
68 };
69 };
70 };
virtual void replyData(std::shared_ptr< Invoke >)=0
virtual void sendData(std::shared_ptr< protocol::Invoke > invoke)
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the EntityGroup.