SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RgrGet.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 #ifndef swcdb_db_protocol_req_RgrGet_h
7 #define swcdb_db_protocol_req_RgrGet_h
8 
9 
12 
13 
14 namespace SWC { namespace Comm { namespace Protocol {
15 namespace Mngr { namespace Req {
16 
17 
18 template<typename DataT>
19 class RgrGet final : public RgrGet_Base {
20  public:
21 
22  typedef std::shared_ptr<RgrGet> Ptr;
23  DataT data;
24 
25  template<typename... DataArgsT>
27  static Ptr make(
28  const Params::RgrGetReq& params,
29  const uint32_t timeout,
30  DataArgsT&&... args) {
31  return Ptr(new RgrGet(params, timeout, args...));
32  }
33 
34  template<typename... DataArgsT>
36  static void request(
37  const Params::RgrGetReq& params,
38  const uint32_t timeout,
39  DataArgsT&&... args) {
40  make(params, timeout, args...)->run();
41  }
42 
43  template<typename... DataArgsT>
45  static void request(
46  cid_t cid, rid_t rid, bool next_range,
47  const uint32_t timeout,
48  DataArgsT&&... args) {
49  request(Params::RgrGetReq(cid, rid, next_range), timeout, args...);
50  }
51 
52  virtual ~RgrGet() noexcept { }
53 
54  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
55  Params::RgrGetRsp rsp(ev->error, ev->data.base, ev->data.size);
56  data.callback(req(), rsp);
57  }
58 
59  protected:
60 
61  template<typename... DataArgsT>
64  const Params::RgrGetReq& params,
65  const uint32_t timeout,
66  DataArgsT&&... args)
67  : RgrGet_Base(params, timeout),
68  data(args...) {
69  }
70 
71  SWC::client::Clients::Ptr& get_clients() noexcept override {
72  return data.get_clients();
73  }
74 
75  bool valid() override {
76  return data.valid();
77  }
78 
79  void callback(Params::RgrGetRsp& rsp) override {
80  data.callback(req(), rsp);
81  }
82 
83 };
84 
85 
86 
102 typedef Common::Req::function<
103  std::function<void(
104  void*,
107  )>
109 
110 
111 }}}}}
112 
113 
114 #endif // swcdb_db_protocol_req_RgrGet_h
SWC::Comm::Protocol::Mngr::Params::RgrGetReq
Definition: RgrGet.h:20
SWC::Comm::Protocol::Mngr::Req::RgrGet::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: RgrGet.h:54
SWC::Comm::Protocol::Mngr::Params::RgrGetRsp
Definition: RgrGet.h:53
SWC::Comm::client::ConnQueueReqBase::req
SWC_CAN_INLINE Ptr req() noexcept
Definition: ClientConnQueue.h:39
SWC::Comm::Protocol::Mngr::Req::RgrGet_Base
Definition: RgrGet_Base.h:19
RgrGet_Base.h
SWC::client::Clients::Ptr
ClientsPtr Ptr
Definition: Clients.h:58
handler_data.h
SWC::Comm::Protocol::Mngr::Req::RgrGet::make
static SWC_CAN_INLINE Ptr make(const Params::RgrGetReq &params, const uint32_t timeout, DataArgsT &&... args)
Definition: RgrGet.h:27
SWC::Comm::Protocol::Mngr::Req::RgrGet::request
static SWC_CAN_INLINE void request(cid_t cid, rid_t rid, bool next_range, const uint32_t timeout, DataArgsT &&... args)
Definition: RgrGet.h:45
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Mngr::Req::Functional_RgrGet
Common::Req::function< std::function< void(void *, const client::ConnQueue::ReqBase::Ptr &, Params::RgrGetRsp &)>> Functional_RgrGet
Definition: RgrGet.h:108
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::cid_t
uint64_t cid_t
Definition: Identifiers.h:16
SWC::Comm::Protocol::Mngr::Req::RgrGet::RgrGet
SWC_CAN_INLINE RgrGet(const Params::RgrGetReq &params, const uint32_t timeout, DataArgsT &&... args)
Definition: RgrGet.h:63
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::Protocol::Common::Req::function
Definition: handler_data.h:19
SWC::Comm::Protocol::Mngr::Req::RgrGet::callback
void callback(Params::RgrGetRsp &rsp) override
Definition: RgrGet.h:79
SWC::Comm::Protocol::Mngr::Req::RgrGet::Ptr
std::shared_ptr< RgrGet > Ptr
Definition: RgrGet.h:22
SWC::Comm::Protocol::Mngr::Req::RgrGet::get_clients
SWC::client::Clients::Ptr & get_clients() noexcept override
Definition: RgrGet.h:71
SWC::rid_t
uint64_t rid_t
Definition: Identifiers.h:17
SWC::Comm::Protocol::Mngr::Req::RgrGet
Definition: RgrGet.h:19
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::client::ConnQueueReqBase::Ptr
std::shared_ptr< ConnQueueReqBase > Ptr
Definition: ClientConnQueue.h:25
SWC::Comm::Protocol::Mngr::Req::RgrGet_Base::cid
cid_t cid
Definition: RgrGet_Base.h:46
SWC::Comm::Protocol::Mngr::Req::RgrGet::data
DataT data
Definition: RgrGet.h:23
SWC::Comm::Protocol::Mngr::Req::RgrGet::request
static SWC_CAN_INLINE void request(const Params::RgrGetReq &params, const uint32_t timeout, DataArgsT &&... args)
Definition: RgrGet.h:36
SWC::Comm::Protocol::Mngr::Req::RgrGet::~RgrGet
virtual ~RgrGet() noexcept
Definition: RgrGet.h:52
SWC::Comm::Protocol::Mngr::Req::RgrGet::valid
bool valid() override
Definition: RgrGet.h:75