2 #include <samchon/templates/parallel/ParallelSystem.hpp> 3 #include <samchon/examples/interaction/base/SystemBase.hpp> 5 #include <samchon/examples/interaction/base/MasterBase.hpp> 6 #include <samchon/examples/interaction/base/MonitorBase.hpp> 7 #include <samchon/examples/interaction/TSPRequest.hpp> 8 #include <samchon/examples/interaction/PackerRequest.hpp> 17 :
public templates::parallel::ParallelSystem,
18 public base::SystemBase
21 typedef templates::parallel::ParallelSystem super;
24 SlaveDriver(base::MasterBase *master, std::shared_ptr<protocol::ClientDriver> driver)
25 : super(master, driver)
29 if (master->getUID() != -1)
30 sendData(std::make_shared<protocol::Invoke>(
"set_master_uid", master->getUID()));
32 virtual ~SlaveDriver()
34 std::cout <<
"A slave has disconnected" << std::endl;
37 getSystemArray<base::MasterBase>()->getMonitor()->sendSystemStructure();
40 virtual void construct(std::shared_ptr<library::XML> xml)
override 42 setUID(xml->getProperty<
int>(
"uid"));
48 virtual auto createChild(std::shared_ptr<library::XML>) -> templates::external::ExternalSystemRole*
54 virtual void sendData(std::shared_ptr<protocol::Invoke> invoke)
override 59 getSystemArray<base::MasterBase>()->getMonitor()->reportSendData(getUID(), invoke);
62 virtual void replyData(std::shared_ptr<protocol::Invoke> invoke)
override 64 if (invoke->getListener() ==
"construct")
65 construct(invoke->front()->getValueAsXML());
66 else if (invoke->getListener() ==
"replyPackerOptimization")
67 getSystemArray<base::MasterBase>()->getPacker()->replyOptimization(invoke->front()->getValueAsXML());
68 else if (invoke->getListener() ==
"replyTSPOptimization")
69 getSystemArray<base::MasterBase>()->getTSP()->replyOptimization(invoke->front()->getValueAsXML());
72 virtual auto TAG() const ->
std::
string
virtual void replyData(std::shared_ptr< Invoke >)=0
virtual void construct(std::shared_ptr< library::XML > xml) override
Construct data of the Entity from an XML object.
virtual void sendData(std::shared_ptr< Invoke >)=0
virtual void sendData(std::shared_ptr< protocol::Invoke > invoke) override