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

A role belongs to an external system. More...

#include <ExternalSystemRole.hpp>

Collaboration diagram for samchon::protocol::ExternalSystemRole:

Public Member Functions

 ExternalSystemRole (ExternalSystem *)
 Construct from external system driver. More...
 
virtual void construct (std::shared_ptr< library::XML >) override
 Construct data of the Entity from an XML object. More...
 
auto getSystem () const -> ExternalSystem *
 Get an external system driver. More...
 
virtual auto key () const -> std::string override
 Get a key that can identify the Entity uniquely. More...
 
auto hasSendListener (const std::string &) const -> bool
 Test whether has a listener for send in the role. More...
 
auto hasReplyListener (const std::string &) const -> bool
 Test whether has a listener for reply in the role. More...
 
virtual void sendData (std::shared_ptr< Invoke >) override
 Send a message. More...
 
virtual auto TAG () const -> std::string override
 A tag name when represented by XML. More...
 
virtual auto toXML () const -> std::shared_ptr< library::XML > override
 Get an XML object represents the Entity. More...
 
- Public Member Functions inherited from samchon::protocol::Entity
 Entity ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
 IProtocol ()
 Default Constructor. More...
 
virtual void replyData (std::shared_ptr< Invoke >)
 Reply a message. More...
 

Protected Attributes

std::string name
 A name representing the role. More...
 
std::set< std::string > replyListeners
 Listeners to reply in the role. More...
 
std::set< std::string > sendListeners
 Listeners to send in the role. More...
 

Private Attributes

ExternalSystemsystem
 A driver of external system containing the ExternalSystemRole. More...
 

Detailed Description

A role belongs to an external system.

ExternalSystemRole is a 'control' class groupping methods, handling Invoke messages interacting with an external system that the ExternalSystemRole is belonged to, by a subject or unit of a module.

ExternalSystemRole can be a "logical proxy" for an ExternalSystem which is containing the 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, 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.

protocol_external_system.png
See also
samchon::protocol
Author
Jeongho Nam http://samchon.org

Definition at line 39 of file ExternalSystemRole.hpp.

Constructor & Destructor Documentation

ExternalSystemRole::ExternalSystemRole ( ExternalSystem system)

Construct from external system driver.

Parameters
systemA driver of external system the ExternalSystemRole is belonged to.

Definition at line 11 of file ExternalSystemRole.cpp.

References system.

Member Function Documentation

void ExternalSystemRole::construct ( std::shared_ptr< library::XML )
overridevirtual

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

Implements samchon::protocol::Entity.

Reimplemented in samchon::protocol::master::DistributedSystemRole.

Definition at line 17 of file ExternalSystemRole.cpp.

References name, replyListeners, and sendListeners.

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

Here is the caller graph for this function:

auto ExternalSystemRole::getSystem ( ) const -> ExternalSystem*

Get an external system driver.

Definition at line 38 of file ExternalSystemRole.cpp.

References system.

auto ExternalSystemRole::key ( ) const -> std::string
overridevirtual

Get a key that can identify the Entity uniquely.

If identifier of the Entity is not atomic value, returns a string represents the composite identifier. If identifier of the Entity is not string, converts the identifier to string and returns the string.

Returns
An identifier

Reimplemented from samchon::protocol::Entity.

Definition at line 42 of file ExternalSystemRole.cpp.

References name.

Referenced by hasReplyListener(), and hasSendListener().

Here is the caller graph for this function:

auto ExternalSystemRole::hasSendListener ( const std::string &  ) const -> bool

Test whether has a listener for send in the role.

Definition at line 47 of file ExternalSystemRole.cpp.

References key(), and sendListeners.

Here is the call graph for this function:

auto ExternalSystemRole::hasReplyListener ( const std::string &  ) const -> bool

Test whether has a listener for reply in the role.

Definition at line 51 of file ExternalSystemRole.cpp.

References key(), and replyListeners.

Here is the call graph for this function:

void ExternalSystemRole::sendData ( std::shared_ptr< Invoke )
overridevirtual

Send a message.

Sends Invoke message to a network system or shifts the responsibility to related chain.

Parameters
invokeAn Invoke message to send to a network system

Reimplemented from samchon::protocol::IProtocol.

Reimplemented in samchon::protocol::master::DistributedSystemRole.

Definition at line 59 of file ExternalSystemRole.cpp.

References samchon::protocol::IClient::sendData(), and system.

Referenced by samchon::protocol::ExternalSystemArray::sendData().

Here is the call graph for this function:

Here is the caller graph for this function:

auto ExternalSystemRole::TAG ( ) const -> std::string
overridevirtual

A tag name when represented by XML.

Returns
A tag name

Implements samchon::protocol::Entity.

Definition at line 67 of file ExternalSystemRole.cpp.

auto ExternalSystemRole::toXML ( ) const -> std::shared_ptr<library::XML>
overridevirtual

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::Entity.

Reimplemented in samchon::protocol::master::DistributedSystemRole.

Definition at line 72 of file ExternalSystemRole.cpp.

References name, replyListeners, sendListeners, and samchon::protocol::Entity::toXML().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

ExternalSystem* samchon::protocol::ExternalSystemRole::system
private

A driver of external system containing the ExternalSystemRole.

Definition at line 50 of file ExternalSystemRole.hpp.

Referenced by ExternalSystemRole(), getSystem(), and sendData().

std::string samchon::protocol::ExternalSystemRole::name
protected

A name representing the role.

Definition at line 56 of file ExternalSystemRole.hpp.

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

std::set<std::string> samchon::protocol::ExternalSystemRole::replyListeners
protected

Listeners to reply in the role.

Definition at line 61 of file ExternalSystemRole.hpp.

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

std::set<std::string> samchon::protocol::ExternalSystemRole::sendListeners
protected

Listeners to send in the role.

Definition at line 66 of file ExternalSystemRole.hpp.

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


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