2 #include <samchon/templates/parallel/ParallelClientArrayMediator.hpp>     3 #include <samchon/examples/interaction/SlaveDriver.hpp>     4 #include <samchon/examples/interaction/base/MasterBase.hpp>     6 #include <samchon/examples/interaction/MasterDriver.hpp>     7 #include <samchon/examples/interaction/MonitorDriver.hpp>     8 #include <samchon/examples/interaction/ChiefDriver.hpp>    10 #include <samchon/examples/interaction/TSPRequest.hpp>    11 #include <samchon/examples/interaction/PackerRequest.hpp>    20         : 
public virtual templates::parallel::ParallelClientArrayMediator<SlaveDriver>,
    21         public base::MasterBase
    24         typedef templates::parallel::ParallelClientArrayMediator<SlaveDriver> super;
    26         std::unique_ptr<ChiefDriver> chief;
    35         Mediator(
int masterPort) : super()
    37             this->name = 
"Mediator";
    38             this->master_port = masterPort;
    40             chief.reset(
new ChiefDriver(
this));
    41             monitor.reset(
new MonitorDriver(
this));
    43             tsp.reset(
new TSPRequest(
this));
    44             packer.reset(
new PackerRequest(
this));
    46         virtual ~Mediator() = 
default;
    48         virtual void construct(std::shared_ptr<library::XML> xml)
 override    50             setUID(xml->getProperty<
int>(
"uid"));
    51             name = xml->getProperty<std::string>(
"name");
    57         virtual auto createMediator() -> templates::parallel::MediatorSystem*
    59             return new MasterDriver(
this, master_port);
    62         virtual auto createExternalClient(std::shared_ptr<protocol::ClientDriver> driver) -> SlaveDriver*
    64             return new SlaveDriver(
this, driver);
    71         virtual auto getParent() const -> protocol::IProtocol*
    79         virtual void sendData(std::shared_ptr<protocol::Invoke> invoke)
    84         virtual void replyData(std::shared_ptr<protocol::Invoke> invoke)
    86             if (invoke->getListener() == 
"set_uid")
    87                 set_uid(invoke->front()->getValue<
int>());
    96             sendData(std::make_shared<protocol::Invoke>(
"set_master_uid", val));
   103                 xml->setTag(
"system");
   105             getParent()->sendData(std::make_shared<protocol::Invoke>(
"construct", xml));
   112         virtual auto TAG() const -> 
std::
string   117         virtual auto toXML() const -> 
std::shared_ptr<library::XML>
   120             xml->setProperty(
"uid", getUID());
   121             xml->setProperty(
"name", name);
   129         static void main(
int masterPort, 
int myPort)
   131             Mediator mediator(masterPort);
   132             mediator.open(myPort);
 virtual void construct(std::shared_ptr< library::XML > xml)
Construct data of the Entity from an XML object. 
 
virtual void replyData(std::shared_ptr< Invoke >)=0
 
virtual void sendData(std::shared_ptr< protocol::Invoke > invoke)
 
virtual void sendData(std::shared_ptr< Invoke >)=0
 
virtual auto toXML() const  -> std::shared_ptr< library::XML >
Get an XML object represents the EntityGroup.