SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeLocate.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 #ifndef swcdb_db_protocol_rgr_req_RangeLocate_h
8 #define swcdb_db_protocol_rgr_req_RangeLocate_h
9 
10 
15 
16 
17 namespace SWC { namespace Comm { namespace Protocol {
18 namespace Rgr { namespace Req {
19 
20 
21 template<typename DataT>
23  public:
24 
25  typedef std::shared_ptr<RangeLocate> Ptr;
26  DataT data;
27 
28  template<typename... DataArgsT>
30  static Ptr make(
31  const Params::RangeLocateReq& params,
32  const uint32_t timeout,
33  DataArgsT&&... args) {
34  return Ptr(new RangeLocate(params, timeout, args...));
35  }
36 
38  static void request(const Ptr& req, const EndPoints& endpoints) {
39  req->data.get_clients()->get_rgr_queue(endpoints)->put(req);
40  }
41 
42  template<typename... DataArgsT>
44  static void request(
45  const Params::RangeLocateReq& params,
46  const EndPoints& endpoints,
47  const uint32_t timeout,
48  DataArgsT&&... args) {
49  request(make(params, timeout, args...), endpoints);
50  }
51 
52  RangeLocate(RangeLocate&&) = delete;
53  RangeLocate(const RangeLocate&) = delete;
55  RangeLocate& operator=(const RangeLocate&) = delete;
56 
57  virtual ~RangeLocate() noexcept { }
58 
59  bool valid() override {
60  return data.valid();
61  }
62 
63  void handle_no_conn() override {
64  data.callback(
65  req(),
67  );
68  }
69 
70  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
71  data.callback(
72  req(),
73  Params::RangeLocateRsp(ev->error, ev->data.base, ev->data.size)
74  );
75  }
76 
77  protected:
78 
79  template<typename... DataArgsT>
82  const Params::RangeLocateReq& params,
83  const uint32_t timeout,
84  DataArgsT&&... args)
85  : client::ConnQueue::ReqBase(
86  Buffers::make(params, 0, RANGE_LOCATE, timeout)
87  ),
88  data(args...) {
89  }
90 
91 };
92 
93 
94 
110 typedef Common::Req::function<
111  std::function<void(
112  void*,
115  )>
117 
118 
119 
120 }}}}}
121 
122 
123 #endif // swcdb_db_protocol_rgr_req_RangeLocate_h
SWC::Comm::Protocol::Rgr::Req::RangeLocate::valid
bool valid() override
Definition: RangeLocate.h:59
SWC::Comm::client::ConnQueueReqBase::req
SWC_CAN_INLINE Ptr req() noexcept
Definition: ClientConnQueue.h:39
SWC::Comm::Protocol::Rgr::Req::RangeLocate::request
static SWC_CAN_INLINE void request(const Ptr &req, const EndPoints &endpoints)
Definition: RangeLocate.h:38
SWC::Comm::Protocol::Rgr::Params::RangeLocateRsp
Definition: RangeLocate.h:59
SWC::Comm::Protocol::Rgr::Req::RangeLocate::RangeLocate
RangeLocate(const RangeLocate &)=delete
SWC::client::Query::ReqBase
Comm::client::ConnQueue::ReqBase ReqBase
Definition: Profiling.h:21
SWC::Comm::client::ConnQueueReqBase
Definition: ClientConnQueue.h:22
SWC::Comm::Protocol::Rgr::Req::RangeLocate::make
static SWC_CAN_INLINE Ptr make(const Params::RangeLocateReq &params, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeLocate.h:30
SWC::Comm::Protocol::Rgr::Req::RangeLocate::~RangeLocate
virtual ~RangeLocate() noexcept
Definition: RangeLocate.h:57
handler_data.h
SWC::Comm::Protocol::Rgr::RANGE_LOCATE
@ RANGE_LOCATE
Definition: Commands.h:33
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
RangeLocate.h
SWC::Comm::Protocol::Rgr::Req::Functional_RangeLocate
Common::Req::function< std::function< void(void *, const client::ConnQueue::ReqBase::Ptr &, const Params::RangeLocateRsp &)>> Functional_RangeLocate
Definition: RangeLocate.h:116
SWC::Comm::Protocol::Rgr::Req::RangeLocate::request
static SWC_CAN_INLINE void request(const Params::RangeLocateReq &params, const EndPoints &endpoints, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeLocate.h:44
SWC::Comm::Protocol::Rgr::Params::RangeLocateReq
Definition: RangeLocate.h:19
SWC::Comm::Protocol::Rgr::Req::RangeLocate::Ptr
std::shared_ptr< RangeLocate > Ptr
Definition: RangeLocate.h:25
ClientConnQueue.h
SWC::Comm::Buffers
Definition: Buffers.h:20
Commands.h
SWC::Error::COMM_NOT_CONNECTED
@ COMM_NOT_CONNECTED
Definition: Error.h:64
SWC::Comm::Protocol::Rgr::Req::RangeLocate::RangeLocate
SWC_CAN_INLINE RangeLocate(const Params::RangeLocateReq &params, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeLocate.h:81
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Core::Vector< EndPoint >
SWC::Comm::Protocol::Common::Req::function
Definition: handler_data.h:19
SWC::Comm::Protocol::Rgr::Req::RangeLocate::operator=
RangeLocate & operator=(const RangeLocate &)=delete
SWC::Comm::Protocol::Rgr::Req::RangeLocate::operator=
RangeLocate & operator=(RangeLocate &&)=delete
SWC::Comm::Protocol::Rgr::Req::RangeLocate::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: RangeLocate.h:70
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::Protocol::Rgr::Req::RangeLocate::RangeLocate
RangeLocate(RangeLocate &&)=delete
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::Comm::Protocol::Rgr::Req::RangeLocate::data
DataT data
Definition: RangeLocate.h:26
SWC::Comm::Protocol::Rgr::Req::RangeLocate::handle_no_conn
void handle_no_conn() override
Definition: RangeLocate.h:63
SWC::Comm::Protocol::Rgr::Req::RangeLocate
Definition: RangeLocate.h:22