Samchon Framework for CPP  1.0.0
ParallelClientArrayMediator.cpp
1 #include <samchon/protocol/master/ParallelClientArrayMediator.hpp>
2 
3 #include <samchon/protocol/master/ParallelSlaveClientMediator.hpp>
4 
5 #include <array>
6 #include <thread>
7 #include <samchon/library/XML.hpp>
8 
9 using namespace std;
10 using namespace samchon::library;
11 using namespace samchon::protocol;
12 using namespace samchon::protocol::master;
13 
14 /* ------------------------------------------------------------------
15  CONSTRUCTORS
16 ------------------------------------------------------------------ */
17 ParallelClientArrayMediator::ParallelClientArrayMediator()
18  : super(),
20 {
22 }
23 void ParallelClientArrayMediator::construct(shared_ptr<XML> xml)
24 {
26 
27  if (xml->has(slave->TAG()))
28  slave->construct(xml->get(slave->TAG())->at(0));
29 }
30 
31 /* ------------------------------------------------------------------
32  PROCESS
33 ------------------------------------------------------------------ */
35 {
36  //STARTS EACH SYSTEM ASYNCHRONOUSLY
37  array<thread, 2> threadArray =
38  {
39  thread
40  (
41  [this]()
42  {
43  super::start();
44  }
45  ),
46  thread
47  (
48  [this]()
49  {
51  }
52  )
53  };
54 
55  //HOWEVER, THIS START IS SYNCHRONOUS
56  for (size_t i = 0; i < threadArray.size(); i++)
57  threadArray[i].join();
58 }
59 
60 /* ------------------------------------------------------------------
61  EXPORTERS
62 ------------------------------------------------------------------ */
63 auto ParallelClientArrayMediator::toXML() const -> shared_ptr<XML>
64 {
65  shared_ptr<XML> &xml = network_super::toXML();
66  xml->push_back(slave->toXML());
67 
68  return xml;
69 }
An array of ExternalSystem(s).
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
virtual auto TAG() const -> std::string override
A tag name when represented by XML.
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
Package for external system, within the framework of master.
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
Package of network protocol and libraries.
Definition: protocol.hpp:185
virtual void start() override
Start interaction.
ParallelSlaveSystemMediator * slave
A slave system for mediation.
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
virtual void construct(std::shared_ptr< library::XML >) override
Construct data of the Entity from an XML object.
XML is a class representing xml object.
Definition: XML.hpp:72
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.