SWC-DB  v0.5.9 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  virtual ~RangeLocate() noexcept { }
53 
54  bool valid() override {
55  return data.valid();
56  }
57 
58  void handle_no_conn() override {
59  data.callback(
60  req(),
62  );
63  }
64 
65  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
66  data.callback(
67  req(),
68  Params::RangeLocateRsp(ev->error, ev->data.base, ev->data.size)
69  );
70  }
71 
72  protected:
73 
74  template<typename... DataArgsT>
77  const Params::RangeLocateReq& params,
78  const uint32_t timeout,
79  DataArgsT&&... args)
80  : client::ConnQueue::ReqBase(
81  Buffers::make(params, 0, RANGE_LOCATE, timeout)
82  ),
83  data(args...) {
84  }
85 
86 };
87 
88 
89 
105 typedef Common::Req::function<
106  std::function<void(
107  void*,
110  )>
112 
113 
114 
115 }}}}}
116 
117 
118 #endif // swcdb_db_protocol_rgr_req_RangeLocate_h
SWC::Comm::Protocol::Rgr::Req::RangeLocate::valid
bool valid() override
Definition: RangeLocate.h:54
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:57
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:52
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:111
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:76
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::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: RangeLocate.h:65
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:29
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:58
SWC::Comm::Protocol::Rgr::Req::RangeLocate
Definition: RangeLocate.h:22