Samchon Framework for CPP  1.0.0
DistributedSystem.cpp
1 #include <samchon/protocol/master/DistributedSystem.hpp>
2 
3 #include <samchon/protocol/master/DistributedSystemArray.hpp>
4 #include <samchon/protocol/master/DistributedSystemRole.hpp>
5 
6 #include <samchon/protocol/Invoke.hpp>
7 #include <samchon/protocol/master/DSInvokeHistoryArray.hpp>
8 #include <samchon/protocol/master/DSInvokeHistory.hpp>
9 
10 using namespace std;
11 using namespace samchon;
12 using namespace samchon::library;
13 using namespace samchon::protocol;
14 using namespace samchon::protocol::master;
15 
16 /* ------------------------------------------------------------------
17  CONSTRUCTORS
18 ------------------------------------------------------------------ */
19 DistributedSystem::DistributedSystem()
20  : super()
21 {
23 }
24 DistributedSystem::~DistributedSystem()
25 {
26  delete invokeHistoryArray;
27 }
28 
29 void DistributedSystem::construct(shared_ptr<XML> xml)
30 {
31  super::construct(xml);
32 
33  performance = xml->getProperty<double>("performance");
34 }
35 
37 {
38  // DON'T MAKE CHILDREN IN SYSTEM.
39  // IT'S THE REPONSIBILITY OF DISTRIBUTED_SYSTEM_ARRAY
40  return nullptr;
41 }
42 
43 // GETTER
44 SHARED_ENTITY_ARRAY_ELEMENT_ACCESSOR_BODY(DistributedSystem, DistributedSystemRole)
45 
46 /* ------------------------------------------------------------------
47  CHAIN OF INVOKE MESSAGE
48 ------------------------------------------------------------------ */
49 void DistributedSystem::sendData(shared_ptr<Invoke> invoke)
50 {
51  const string &listener = invoke->getListener();
52 
53  for (size_t i = 0; i < size(); i++)
54  {
55  if (at(i)->hasSendListener(listener) == true)
56  {
57  shared_ptr<DSInvokeHistory> history(new DSInvokeHistory(this, at(i).get(), invoke));
58  invokeHistoryArray->push_back(history);
59  at(i)->invokeHistoryArray->push_back(history);
60 
61  break;
62  }
63  }
64 
65  super::sendData(invoke);
66 }
67 void DistributedSystem::replyData(shared_ptr<Invoke> invoke)
68 {
69 
70 }
71 
72 /* ------------------------------------------------------------------
73  EXPORTERS
74 ------------------------------------------------------------------ */
75 auto DistributedSystem::toXML() const -> shared_ptr<XML>
76 {
77  shared_ptr<XML> &xml = super::toXML();
78  xml->setProperty("performance", performance);
79 
80  if (invokeHistoryArray->empty() == false)
81  xml->push_back(invokeHistoryArray->toXML());
82 
83  return xml;
84 }
DSInvokeHistoryArray * invokeHistoryArray
A list of history log for reported Invoke messages.
virtual auto createChild(std::shared_ptr< library::XML >) -> ExternalSystemRole *override
Factory method of a child Entity.
A reported history of an Invoke message.
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
virtual void replyData(std::shared_ptr< Invoke >) override
Handling replied message from an external system.
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
Package of libraries.
Definition: library.hpp:84
virtual void sendData(std::shared_ptr< Invoke >)
Sends message to a related system.
Definition: IClient.cpp:309
An Entity and a container of children Entity objects.
Definition: EntityGroup.hpp:52
virtual auto toXML() const -> std::shared_ptr< library::XML >
Get an XML object represents the EntityGroup.
Package of network protocol and libraries.
Definition: protocol.hpp:185
A role of distributed processing system.
A network driver for a distributed system.
A role belongs to an external system.
Standard message of network I/O.
Definition: Invoke.hpp:47
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 void sendData(std::shared_ptr< Invoke >) override
Sends message to a related system.
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7