Samchon Framework for CPP
1.0.0
|
A network driver for an external server. More...
#include <ExternalServer.hpp>
Public Member Functions | |
ExternalServer () | |
Default Constructor. More... | |
virtual void | construct (std::shared_ptr< library::XML >) override |
Construct data of the Entity from an XML object. More... | |
virtual void | start () override |
Start interaction. More... | |
virtual auto | getIP () const -> std::string override |
Destinatio IP. More... | |
virtual auto | getPort () const -> int override |
Destination port. More... | |
virtual auto | getMyIP () const -> std::string override |
(optional) My IP, if you want to bind More... | |
virtual auto | toXML () const -> std::shared_ptr< library::XML > override |
Get an XML object represents the EntityGroup. More... | |
![]() | |
ExternalSystem () | |
Default Constructor. More... | |
virtual auto | key () const -> std::string override |
Get a key that can identify the Entity uniquely. More... | |
virtual void | replyData (std::shared_ptr< Invoke >) override |
Handling replied message from an external system. More... | |
virtual auto | TAG () const -> std::string override |
A tag name when represented by XML. More... | |
virtual auto | CHILD_TAG () const -> std::string override |
A tag name of children. More... | |
![]() | |
EntityGroup () | |
Default Constructor. More... | |
auto | has (const std::string &key) const -> bool |
Indicates whether a container has an object having the specified identifier. More... | |
auto | get (const std::string &key) -> value_type & |
Access the element by specified identifier(key). More... | |
auto | get (const std::string &key) const -> const value_type & |
Access the const element by specified identifier(key). More... | |
![]() | |
Entity () | |
Default Constructor. More... | |
![]() | |
IEntityGroup () | |
Default Constructor. More... | |
![]() | |
IClient () | |
Default Constructor. More... | |
virtual void | listen () |
Listens message from a related system. More... | |
virtual void | sendData (std::shared_ptr< Invoke >) |
Sends message to a related system. More... | |
![]() | |
IProtocol () | |
Default Constructor. More... | |
![]() | |
ServerConnector () | |
Default Constructor. More... | |
virtual void | connect () |
Connect to a server. More... | |
Protected Attributes | |
std::string | myIP |
A custom ip address of my system to bind. More... | |
![]() | |
std::string | name |
A name can identify an external system. More... | |
std::string | ip |
An ip address of an external system. More... | |
int | port |
A port number of an external system. More... | |
![]() | |
Socket * | socket |
Socket for network I/O. More... | |
std::mutex * | sendMtx |
A mutex for sending message. More... | |
![]() | |
boost::asio::io_service * | ioService |
An io_service of Boost.Asio's own. More... | |
EndPoint * | endPoint |
An endpoint directing a server. More... | |
EndPoint * | localEndPoint |
(Optional) An local endpoint of the client (my system) More... | |
Additional Inherited Members | |
![]() | |
virtual auto | createChild (std::shared_ptr< library::XML >) -> entity_type *=0 |
Factory method of a child Entity. More... | |
![]() | |
virtual auto | BUFFER_SIZE () const -> size_t |
Buffer size of network I/O. More... | |
virtual void | _replyData (std::shared_ptr< Invoke >) |
A method for pre-processing replied Invoke message. More... | |
A network driver for an external server.
ExternalServer is an ExternalSystem specialized in server driver.
ExternalSystem is a boundary class interacting with an external system by network communication. Also, ExternalSystem is an abstract class that a network role, which one is server and which one is client, is not determined yet.
The ExternalSystem has ExternalSystemRole(s) groupped methods, handling Invoke message interacting with the external system, by subject or unit of a moudle. The ExternalSystemRole is categorized in a 'control'.
The ExternalSystem class takes a role of interaction with external system in network level. However, within a framework of Samchon Framework, a boundary class like the ExternalSystem is not such important. You can find some evidence in a relationship between ExternalSystemArray, ExternalSystem and ExternalSystemRole.
Of course, the ExternalSystemRole is belonged to an ExternalSystem. However, if you access an ExternalSystemRole from an ExternalSystemArray directly, not passing by a belonged ExternalSystem, and send an Invoke message even you're not knowing which ExternalSystem is related in, it's called "Proxy pattern".
Like the explanation of "Proxy pattern", you can utilize an ExternalSystemRole as a proxy of an ExternalSystem. With the pattern, you can only concentrate on ExternalSystemRole itself, what to do with Invoke message, irrespective of the ExternalSystemRole is belonged to which ExternalSystem.
Definition at line 20 of file ExternalServer.hpp.
ExternalServer::ExternalServer | ( | ) |
Default Constructor.
Definition at line 13 of file ExternalServer.cpp.
|
overridevirtual |
Construct data of the Entity from an XML object.
Constructs the EntityGroup's own member variables only from the input XML object.
Do not consider about constructing children Entity objects' data in EntityGroup::construct(). Those children Entity objects' data will constructed by their own construct() method. Even insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Constructs only data of EntityGroup's own.
Overrides the construct() method and fetch data of member variables from the XML.
By recommended guidance, data representing member variables are contained in properties of the put XML object.
xml | An xml used to construct data of entity |
Reimplemented from samchon::protocol::ExternalSystem.
Reimplemented in samchon::protocol::master::DistributedServer, and samchon::protocol::master::ParallelServer.
Definition at line 18 of file ExternalServer.cpp.
References samchon::protocol::ExternalSystem::construct(), and myIP.
|
overridevirtual |
Start interaction.
An abstract method starting interaction with an external system.
If an external systems are a server, starts connection and listening Inovoke message, else clients, just starts listening only. You also can addict your own procudures of starting the driver, but if you directly override method of abstract ExternalSystem, be careful about virtual inheritance.
Implements samchon::protocol::ExternalSystem.
Definition at line 28 of file ExternalServer.cpp.
References samchon::protocol::ServerConnector::connect(), and samchon::protocol::IClient::listen().
Referenced by samchon::example::interaction::TSPSlave::main(), and samchon::example::interaction::PackerSlave::main().
|
overridevirtual |
Destinatio IP.
Implements samchon::protocol::ServerConnector.
Definition at line 37 of file ExternalServer.cpp.
References samchon::protocol::ExternalSystem::ip.
|
overridevirtual |
Destination port.
Implements samchon::protocol::ServerConnector.
Definition at line 41 of file ExternalServer.cpp.
References samchon::protocol::ExternalSystem::port.
|
overridevirtual |
(optional) My IP, if you want to bind
Reimplemented from samchon::protocol::ServerConnector.
Definition at line 46 of file ExternalServer.cpp.
References myIP.
|
overridevirtual |
Get an XML object represents the EntityGroup.
Archives the EntityGroup's own member variables only to the returned XML object.
Do not consider about archiving children Entity objects' data in EntityGroup::toXML(). Those children Entity objects will converted to XML object by their own toXML() method. The insertion of XML objects representing children are done by abstract method of EntityGroup::toXML().
Archives only data of EntityGroup's own.
Returns an XML object that can represents the Entity containing member variables into properties.
A member variable (not object, but atomic value like number, string or date) is categorized as a property within the framework of entity side. Thus, when overriding a toXML() method and archiving member variables to an XML object to return, puts each variable to be a property belongs to only an XML object.
Don't archive the member variable of atomic value to XML::value causing enormouse creation of XML objects to number of member variables. An Entity must be represented by only an XML instance (tag).
Standard Usage | Non-standard usage abusing value |
---|---|
<memberList> <member id='jhnam88' name='Jeongho+Nam' birthdate='1988-03-11' /> <member id='master' name='Administartor' birthdate='2011-07-28' /> </memberList> | <member> <id>jhnam88</id> <name>Jeongho+Nam</name> <birthdate>1988-03-11</birthdate> </member> |
Reimplemented from samchon::protocol::ExternalSystem.
Reimplemented in samchon::protocol::master::DistributedServer, and samchon::protocol::master::ParallelServer.
Definition at line 54 of file ExternalServer.cpp.
References myIP, and samchon::protocol::ExternalSystem::toXML().
|
protected |
A custom ip address of my system to bind.
Definition at line 31 of file ExternalServer.hpp.
Referenced by samchon::protocol::master::ParallelServer::construct(), construct(), getMyIP(), samchon::protocol::master::ParallelSlaveClientMediator::ParallelSlaveClientMediator(), samchon::protocol::master::ParallelServer::toXML(), and toXML().