Samchon Framework for CPP  1.0.0
ExternalSystem.cpp
1 #include <samchon/protocol/ExternalSystem.hpp>
2 
3 #include <samchon/protocol/ExternalSystemRole.hpp>
4 
5 #include <samchon/library/XML.hpp>
6 #include <samchon/protocol/Invoke.hpp>
7 
8 using namespace std;
9 using namespace samchon::library;
10 using namespace samchon::protocol;
11 
12 /* ------------------------------------------------------------------
13  CONSTRUCTORS
14 ------------------------------------------------------------------ */
15 ExternalSystem::ExternalSystem()
16  : super(),
17  IClient()
18 {
19 }
20 void ExternalSystem::construct(shared_ptr<XML> xml)
21 {
22  this->name = xml->getProperty("name");
23 
24  this->ip = xml->getProperty("ip");
25  this->port = xml->getProperty<int>("port");
26 
27  super::construct(xml);
28 }
29 
30 /* ------------------------------------------------------------------
31  GETTERS
32 ------------------------------------------------------------------ */
33 auto ExternalSystem::key() const -> string
34 {
35  return name;
36 }
37 
38 /* ------------------------------------------------------------------
39  CHAIN OF INVOKE MESSAGE
40 ------------------------------------------------------------------ */
41 void ExternalSystem::replyData(shared_ptr<Invoke> invoke)
42 {
43  string &listener = invoke->getListener();
44 
45  for(size_t i = 0; i < size(); i++)
46  if(at(i)->hasReplyListener(listener) == true)
47  at(i)->replyData(invoke);
48 }
49 
50 /* ------------------------------------------------------------------
51  EXPORTERS
52 ------------------------------------------------------------------ */
53 auto ExternalSystem::TAG() const -> string
54 {
55  return "system";
56 }
57 auto ExternalSystem::CHILD_TAG() const -> string
58 {
59  return "role";
60 }
61 
62 auto ExternalSystem::toXML() const -> shared_ptr<XML>
63 {
64  shared_ptr<XML> &xml = super::toXML();
65  xml->setProperty("name", name);
66  xml->setProperty("ip", ip);
67  xml->setProperty("port", port);
68 
69  return xml;
70 }
virtual auto key() const -> std::string override
Get a key that can identify the Entity uniquely.
int port
A port number of an external system.
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the EntityGroup.
Definition: RWMutex.hpp:4
Package of libraries.
Definition: library.hpp:84
std::string name
A name can identify an external system.
virtual void replyData(std::shared_ptr< Invoke >) override
Handling replied message from an external system.
virtual auto TAG() const -> std::string override
A tag name when represented by XML.
std::string ip
An ip address of an external system.
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
An interface for a client.
Definition: IClient.hpp:53
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 CHILD_TAG() const -> std::string override
A tag name of children.
virtual void construct(std::shared_ptr< library::XML > xml)
Construct data of the Entity from an XML object.
Definition: EntityGroup.hpp:90