Samchon Framework for CPP  1.0.0
PInvoke.hpp
1 #pragma once
2 #include <samchon/API.hpp>
3 
4 #include <samchon/protocol/Invoke.hpp>
5 
6 #include <samchon/templates/slave/InvokeHistory.hpp>
7 #include <samchon/protocol/IProtocol.hpp>
8 
9 namespace samchon
10 {
11 namespace templates
12 {
13 namespace slave
14 {
15  class PInvoke : public protocol::Invoke
16  {
17  private:
18  typedef protocol::Invoke super;
19 
20  std::shared_ptr<InvokeHistory> history_;
21  protocol::IProtocol *master_driver_;
22 
23  bool hold_;
24 
25  public:
26  /* ---------------------------------------------------------
27  CONSTRUCTORS AND PROCEDURES
28  --------------------------------------------------------- */
36  PInvoke(const std::shared_ptr<protocol::Invoke> &invoke, std::shared_ptr<InvokeHistory> history, protocol::IProtocol *masterDriver)
37  : super(invoke->getListener()) // COPY LISTENER
38  {
39  // ASSIGN PARAMETERS
40  assign(invoke->begin(), invoke->end());
41 
42  // MEMBERS
43  this->history_ = history;
44  this->master_driver_ = masterDriver;
45 
46  // DEFAULT IS NOT BEING HOLD
47  this->hold_ = false;
48  };
49 
50  void hold()
51  {
52  hold_ = true;
53  };
54 
55  void complete()
56  {
57  history_->complete();
58 
59  master_driver_->sendData(history_->toInvoke());
60  };
61 
62  /* ---------------------------------------------------------
63  ACCESSORS
64  --------------------------------------------------------- */
65  auto getHistory() const -> std::shared_ptr<InvokeHistory>
66  {
67  return history_;
68  };
69  auto isHold() const -> bool
70  {
71  return hold_;
72  };
73  };
74 };
75 };
76 };
auto getListener() const -> std::string
Get listener.
Definition: Invoke.hpp:142