Samchon Framework for CPP  1.0.0
samchon::protocol::ExternalClientArray Class Reference

An array of ExternalClient(s) More...

#include <ExternalClientArray.hpp>

Collaboration diagram for samchon::protocol::ExternalClientArray:

Public Member Functions

 ExternalClientArray ()
 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 toXML () const -> std::shared_ptr< library::XML > override
 Get an XML object represents the EntityGroup. More...
 
- Public Member Functions inherited from samchon::protocol::ExternalSystemArray
 ExternalSystemArray ()
 Default Constructor. More...
 
auto hasRole (const std::string &) const -> bool
 Test whether has a role. More...
 
auto getRole (const std::string &) const -> std::shared_ptr< ExternalSystemRole >
 Get a role. More...
 
virtual void sendData (std::shared_ptr< Invoke >) override
 Sends an Invoke message to related ExternalSystem(s). More...
 
virtual void replyData (std::shared_ptr< Invoke >) override
 Handle replied Invoke message. 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...
 
- Public Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
 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...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
virtual auto key () const -> std::string
 Get a key that can identify the Entity uniquely. More...
 
- Public Member Functions inherited from samchon::protocol::IEntityGroup
 IEntityGroup ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
 IProtocol ()
 Default Constructor. More...
 

Protected Member Functions

virtual auto PORT () const -> int
 Port number of the server. More...
 
virtual auto MY_IP () const -> std::string
 (optional) Server's IP More...
 
virtual void addClient (Socket *) override
 Handling connection of a physical client. More...
 
- Protected Member Functions inherited from samchon::protocol::EntityGroup< _Container, _ETy, T >
virtual auto createChild (std::shared_ptr< library::XML >) -> entity_type *=0
 Factory method of a child Entity. More...
 

Protected Attributes

std::string myIP
 A custom ip address of my system to bind. More...
 
int port
 A port number for accepting external clients. More...
 

Additional Inherited Members

- Private Member Functions inherited from samchon::protocol::IServer
 IServer ()
 Default Constructor. More...
 
virtual void open ()
 Open the server. More...
 
virtual void close ()
 Close the server. More...
 
- Private Attributes inherited from samchon::protocol::IServer
Acceptor * acceptor
 An acceptor for clients. More...
 

Detailed Description

An array of ExternalClient(s)

ExternalClientArray is an ExternalSystemArray specialized in clients' driver.

[Inherited]

ExternalSystemArray is an abstract class containing and managing external system drivers.

Also, ExternalSystemArray can access to ExternalSystemRole(s) directly. With the method, you can use an ExternalSystemRole as "logical proxy" of an ExternalSystem. 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, the ExternalSystemRole acted a role of proxy.

It's called as "Proxy pattern". 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.

ExternalSystemArray::getRole("something")->sendData(invoke);
protocol_external_system.png
Example Sources
See also
samchon::protocol
Author
Jeongho Nam http://samchon.org

Definition at line 20 of file ExternalClientArray.hpp.

Constructor & Destructor Documentation

ExternalClientArray::ExternalClientArray ( )

Default Constructor.

Definition at line 16 of file ExternalClientArray.cpp.

Member Function Documentation

void ExternalClientArray::construct ( std::shared_ptr< library::XML xml)
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.

[Inherited]
Construct data of the Entity from an XML object.

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.

Parameters
xmlAn xml used to construct data of entity

Reimplemented from samchon::protocol::EntityGroup< _Container, _ETy, T >.

Reimplemented in samchon::protocol::master::DistributedClientArrayMediator, samchon::protocol::master::ParallelClientArrayMediator, and samchon::protocol::master::DistributedClientArray.

Definition at line 21 of file ExternalClientArray.cpp.

References samchon::protocol::EntityGroup< _Container, _ETy, T >::construct(), myIP, and port.

Referenced by samchon::protocol::master::ParallelClientArrayMediator::construct().

Here is the call graph for this function:

Here is the caller graph for this function:

void ExternalClientArray::start ( )
overridevirtual

Start interaction.

An abstract method starting interaction with external systems.

If external systems are servers, starts connection to them, else clients, opens a server and accepts the external systems. You can addict your own procudures of starting drivers, but if you directly override method of abstract ExternalSystemArray, be careful about virtual inheritance.

Implements samchon::protocol::ExternalSystemArray.

Reimplemented in samchon::example::interaction::Master, samchon::protocol::master::DistributedClientArrayMediator, samchon::protocol::master::ParallelClientArrayMediator, and samchon::protocol::master::DistributedClientArray.

Definition at line 33 of file ExternalClientArray.cpp.

References samchon::protocol::IServer::open().

Referenced by samchon::protocol::master::ParallelClientArrayMediator::start().

Here is the call graph for this function:

Here is the caller graph for this function:

auto ExternalClientArray::PORT ( ) const -> int
protectedvirtual

Port number of the server.

Reimplemented from samchon::protocol::IServer.

Definition at line 41 of file ExternalClientArray.cpp.

References port.

auto ExternalClientArray::MY_IP ( ) const -> std::string
protectedvirtual

(optional) Server's IP

Reimplemented from samchon::protocol::IServer.

Definition at line 45 of file ExternalClientArray.cpp.

References myIP.

void ExternalClientArray::addClient ( Socket *  )
overrideprotectedvirtual
auto ExternalClientArray::toXML ( ) const -> std::shared_ptr<library::XML>
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.

[Inherited]
Get an XML object represents the Entity.

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>
Returns
An XML object representing the Entity.

Reimplemented from samchon::protocol::EntityGroup< _Container, _ETy, T >.

Reimplemented in samchon::protocol::master::DistributedClientArrayMediator, samchon::protocol::master::ParallelClientArrayMediator, and samchon::protocol::master::DistributedClientArray.

Definition at line 72 of file ExternalClientArray.cpp.

References myIP, and samchon::protocol::EntityGroup< _Container, _ETy, T >::toXML().

Referenced by samchon::protocol::master::ParallelClientArrayMediator::toXML().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::string samchon::protocol::ExternalClientArray::myIP
protected

A custom ip address of my system to bind.

Definition at line 30 of file ExternalClientArray.hpp.

Referenced by construct(), MY_IP(), and toXML().

int samchon::protocol::ExternalClientArray::port
protected

The documentation for this class was generated from the following files: