Samchon Framework for CPP  1.0.0
samchon::example::interaction::Slave Class Reference

A slave system for optimizing something. More...

#include <Slave.hpp>

Collaboration diagram for samchon::example::interaction::Slave:

Public Member Functions

 Slave (const string &ip, int port)
 Construct from ip address and port number of master. More...
 
- Public Member Functions inherited from samchon::protocol::slave::ParallelClient
 ParallelClient ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::slave::ParallelSystem
 ParallelSystem ()
 Default Constructor. More...
 
virtual void replyPieceData (std::shared_ptr< Invoke >, size_t, size_t)=0
 Handle requested processes which are segmented. More...
 
- Public Member Functions inherited from samchon::protocol::slave::SlaveSystem
 SlaveSystem ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::ExternalSystem
 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...
 
- 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...
 
- Public Member Functions inherited from samchon::protocol::IEntityGroup
 IEntityGroup ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::IClient
 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...
 
- Public Member Functions inherited from samchon::protocol::IProtocol
 IProtocol ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::slave::SlaveClient
 SlaveClient ()
 Default Constructor. More...
 
- Public Member Functions inherited from samchon::protocol::ExternalServer
 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...
 
- Public Member Functions inherited from samchon::protocol::ServerConnector
 ServerConnector ()
 Default Constructor. More...
 
virtual void connect ()
 Connect to a server. More...
 

Protected Member Functions

virtual void optimize (shared_ptr< XML > xml, size_t index, size_t size)
 Optimize something and report the result. More...
 
void sendOptimization (shared_ptr< XML > xml)
 Send (report) optimization result to its master system. More...
 
- Protected Member Functions inherited from samchon::protocol::slave::ParallelSystem
virtual auto createChild (std::shared_ptr< library::XML >) -> ExternalSystemRole *override
 Factory method of a child Entity. More...
 
virtual void _replyData (std::shared_ptr< Invoke >) override
 Pre-processor for segmented processes and reporting elapsed time. More...
 
- Protected Member Functions inherited from samchon::protocol::IClient
virtual auto BUFFER_SIZE () const -> size_t
 Buffer size of network I/O. More...
 

Additional Inherited Members

- Protected Attributes inherited from samchon::protocol::ExternalSystem
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...
 
- Protected Attributes inherited from samchon::protocol::IClient
Socket * socket
 Socket for network I/O. More...
 
std::mutex * sendMtx
 A mutex for sending message. More...
 
- Protected Attributes inherited from samchon::protocol::ExternalServer
std::string myIP
 A custom ip address of my system to bind. More...
 
- Protected Attributes inherited from samchon::protocol::ServerConnector
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...
 

Detailed Description

A slave system for optimizing something.

Slave is an abstract and example class, for providing guidance of realizing parallel processsing system for useres, within framework of slave. The Slave class represents a slave system literally. You can study how to utilize the slave module in protocol.

A slave system (represented by Slave and SlaveDriver) is associated with a master (represented by Master and MasterSlave) or mediator (PackerMediator) system. When slave system gets order of optimization with its basic data, slave system calculates and derives the best solution and reports it to the master system.

example_interaction.png
example_interaction_network_diagram.png
[Inherited]
See also
protocol::slave
Author
Jeongho Nam http://samchon.org

Definition at line 43 of file Slave.hpp.

Constructor & Destructor Documentation

samchon::example::interaction::Slave::Slave ( const string &  ip,
int  port 
)
inline

Construct from ip address and port number of master.

Parameters
ipIP address of master.
portPort number of master.

Definition at line 59 of file Slave.hpp.

Member Function Documentation

virtual void samchon::example::interaction::Slave::optimize ( shared_ptr< XML xml,
size_t  index,
size_t  size 
)
inlineprotectedvirtual

Optimize something and report the result.

Parameters
xmlXML object representing a Travel.
indexStarting index of a segmentation allocated to the Slave.
sizeSize of the segmentation.

Reimplemented in samchon::example::interaction::PackerSlave, and samchon::example::interaction::TSPSlave.

Definition at line 89 of file Slave.hpp.

void samchon::example::interaction::Slave::sendOptimization ( shared_ptr< XML xml)
inlineprotected

Send (report) optimization result to its master system.

Parameters
xmlXML object representing the best solution.

Definition at line 101 of file Slave.hpp.


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