SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeQueryUpdate.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_rgr_req_RangeQueryUpdate_h
7 #define swcdb_db_protocol_rgr_req_RangeQueryUpdate_h
8 
9 
14 
15 
16 namespace SWC { namespace Comm { namespace Protocol {
17 namespace Rgr { namespace Req {
18 
19 
20 template<typename DataT>
22  public:
23 
24  typedef std::shared_ptr<RangeQueryUpdate> Ptr;
25  DataT data;
26 
27  template<typename... DataArgsT>
29  static Ptr make(
30  const Params::RangeQueryUpdateReq& params,
31  StaticBuffer& snd_buf,
32  const uint32_t timeout,
33  DataArgsT&&... args) {
34  return Ptr(new RangeQueryUpdate(
35  Buffers::make(params, snd_buf, 0, RANGE_QUERY_UPDATE, timeout),
36  args...
37  ));
38  }
39 
40  template<typename... DataArgsT>
42  static Ptr make(
43  const Params::RangeQueryUpdateReq& params,
44  const DynamicBuffer& buffer,
45  const uint32_t timeout,
46  DataArgsT&&... args) {
47  StaticBuffer snd_buf(buffer.base, buffer.fill(), false);
48  return make(params, snd_buf, timeout, args...);
49  }
50 
52  static void request(const Ptr& req, const EndPoints& endpoints) {
53  req->data.get_clients()->get_rgr_queue(endpoints)->put(req);
54  }
55 
56  template<typename... DataArgsT>
58  static void request(
59  const Params::RangeQueryUpdateReq& params,
60  StaticBuffer& snd_buf,
61  const uint32_t timeout,
62  const EndPoints& endpoints,
63  DataArgsT&&... args) {
64  request(make(params, snd_buf, timeout, args...), endpoints);
65  }
66 
67  template<typename... DataArgsT>
69  static void request(
70  const Params::RangeQueryUpdateReq& params,
71  const DynamicBuffer& buffer,
72  const uint32_t timeout,
73  const EndPoints& endpoints,
74  DataArgsT&&... args) {
75  request(make(params, buffer, timeout, args...), endpoints);
76  }
77 
82 
83  virtual ~RangeQueryUpdate() noexcept { }
84 
85  bool valid() override {
86  return data.valid();
87  }
88 
89  void handle_no_conn() override {
90  data.callback(
91  req(),
93  );
94  }
95 
96  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
97  data.callback(
98  req(),
99  Params::RangeQueryUpdateRsp(ev->error, ev->data.base, ev->data.size)
100  );
101  }
102 
103  protected:
104 
105  template<typename... DataArgsT>
107  RangeQueryUpdate(Buffers::Ptr&& a_cbp, DataArgsT&&... args)
108  : client::ConnQueue::ReqBase(std::move(a_cbp)),
109  data(args...) {
110  }
111 
112 };
113 
114 
115 
131 typedef Common::Req::function<
132  std::function<void(
133  void*,
136  )>
138 
139 
140 
141 
142 }}}}}
143 
144 
145 #endif // swcdb_db_protocol_rgr_req_RangeQueryUpdate_h
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::~RangeQueryUpdate
virtual ~RangeQueryUpdate() noexcept
Definition: RangeQueryUpdate.h:83
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::make
static SWC_CAN_INLINE Ptr make(const Params::RangeQueryUpdateReq &params, StaticBuffer &snd_buf, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:29
SWC::Comm::client::ConnQueueReqBase::req
SWC_CAN_INLINE Ptr req() noexcept
Definition: ClientConnQueue.h:39
SWC::Comm::Buffers::Ptr
std::shared_ptr< Buffers > Ptr
Definition: Buffers.h:23
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: RangeQueryUpdate.h:96
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::Functional_RangeQueryUpdate
Common::Req::function< std::function< void(void *, const client::ConnQueue::ReqBase::Ptr &, const Params::RangeQueryUpdateRsp &)>> Functional_RangeQueryUpdate
Definition: RangeQueryUpdate.h:137
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::make
static SWC_CAN_INLINE Ptr make(const Params::RangeQueryUpdateReq &params, const DynamicBuffer &buffer, const uint32_t timeout, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:42
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::handle_no_conn
void handle_no_conn() override
Definition: RangeQueryUpdate.h:89
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::Ptr
std::shared_ptr< RangeQueryUpdate > Ptr
Definition: RangeQueryUpdate.h:24
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::RangeQueryUpdate
SWC_CAN_INLINE RangeQueryUpdate(Buffers::Ptr &&a_cbp, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:107
SWC::Comm::Protocol::Rgr::Params::RangeQueryUpdateRsp
Definition: RangeQueryUpdate.h:48
handler_data.h
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
RangeQueryUpdate.h
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::valid
bool valid() override
Definition: RangeQueryUpdate.h:85
SWC::Core::BufferDyn< StaticBuffer >
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::RangeQueryUpdate
RangeQueryUpdate(RangeQueryUpdate &&)=delete
SWC::Core::Buffer
Definition: Buffer.h:18
ClientConnQueue.h
Commands.h
SWC::Error::COMM_NOT_CONNECTED
@ COMM_NOT_CONNECTED
Definition: Error.h:64
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Core::Vector< EndPoint >
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::RangeQueryUpdate
RangeQueryUpdate(const RangeQueryUpdate &)=delete
SWC::Comm::Protocol::Common::Req::function
Definition: handler_data.h:19
SWC::Core::BufferDyn::fill
constexpr SWC_CAN_INLINE size_t fill() const noexcept
Definition: Buffer.h:192
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::operator=
RangeQueryUpdate & operator=(RangeQueryUpdate &&)=delete
SWC::Comm::Buffers::make
static SWC_CAN_INLINE Ptr make(uint32_t reserve=0)
Definition: Buffers.h:27
SWC::Comm::Protocol::Rgr::RANGE_QUERY_UPDATE
@ RANGE_QUERY_UPDATE
Definition: Commands.h:34
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate
Definition: RangeQueryUpdate.h:21
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Ptr &req, const EndPoints &endpoints)
Definition: RangeQueryUpdate.h:52
SWC::Comm::Protocol::Rgr::Params::RangeQueryUpdateReq
Definition: RangeQueryUpdate.h:18
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Params::RangeQueryUpdateReq &params, const DynamicBuffer &buffer, const uint32_t timeout, const EndPoints &endpoints, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:69
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::Rgr::Req::RangeQueryUpdate::request
static SWC_CAN_INLINE void request(const Params::RangeQueryUpdateReq &params, StaticBuffer &snd_buf, const uint32_t timeout, const EndPoints &endpoints, DataArgsT &&... args)
Definition: RangeQueryUpdate.h:58
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::data
DataT data
Definition: RangeQueryUpdate.h:25
SWC::Comm::Protocol::Rgr::Req::RangeQueryUpdate::operator=
RangeQueryUpdate & operator=(const RangeQueryUpdate &)=delete