SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
CellsSelect.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_bkr_req_CellsSelect_h
7 #define swcdb_db_protocol_bkr_req_CellsSelect_h
8 
9 
13 
14 
15 namespace SWC { namespace Comm { namespace Protocol {
16 namespace Bkr { namespace Req {
17 
18 
19 template<typename DataT>
21  public:
22 
23  typedef std::shared_ptr<CellsSelect> Ptr;
24  DataT data;
25 
26  template<typename... DataArgsT>
28  static Ptr make(
29  const Params::CellsSelectReqRef& params,
30  const uint32_t timeout,
31  DataArgsT&&... args) {
32  return Ptr(new CellsSelect(params, timeout, args...));
33  }
34 
35  template<typename... DataArgsT>
37  static void request(
38  const Params::CellsSelectReqRef& params,
39  const uint32_t timeout,
40  DataArgsT&&... args) {
41  make(params, timeout, args...)->run();
42  }
43 
44  CellsSelect(CellsSelect&&) = delete;
45  CellsSelect(const CellsSelect&) = delete;
47  CellsSelect& operator=(const CellsSelect&) = delete;
48 
49  virtual ~CellsSelect() noexcept { }
50 
51  bool run() override {
52  return data.get_clients()->brokers.put(req(), _bkr_idx);
53  }
54 
55  bool valid() override {
56  return data.valid() && !data.get_clients()->stopping();
57  }
58 
59  void handle_no_conn() override {
60  if(data.valid() && !_bkr_idx.turn_around(data.get_clients()->brokers)) {
61  run();
62  } else {
64  data.callback(req(), rsp);
65  }
66  }
67 
68  void handle(ConnHandlerPtr, const Event::Ptr& ev) override {
70  ev->error, ev->data.base, ev->data.size, ev->data_ext);
71  data.callback(req(), rsp);
72  }
73 
74 
75  protected:
76 
77  template<typename... DataArgsT>
80  const uint32_t timeout,
81  DataArgsT&&... args)
82  : client::ConnQueue::ReqBase(
83  Buffers::make(params, 0, CELLS_SELECT, timeout)
84  ),
85  data(args...),
86  _bkr_idx() {
87  }
88 
89  private:
91 
92 };
93 
94 
95 
96 
97 
98 
114 typedef Common::Req::function<
115  std::function<void(
116  void*,
119  )>
121 
122 
123 
124 }}}}}
125 
126 
127 
128 #endif // swcdb_db_protocol_bkr_req_CellsSelect_h
SWC::Comm::Protocol::Bkr::CELLS_SELECT
@ CELLS_SELECT
Definition: Commands.h:106
SWC::Comm::client::ConnQueueReqBase::req
SWC_CAN_INLINE Ptr req() noexcept
Definition: ClientConnQueue.h:39
SWC::client::Brokers::BrokerIdx
Definition: Brokers.h:23
SWC::Comm::Protocol::Bkr::Req::CellsSelect
Definition: CellsSelect.h:20
SWC::Comm::Protocol::Bkr::Req::CellsSelect::~CellsSelect
virtual ~CellsSelect() noexcept
Definition: CellsSelect.h:49
SWC::client::Query::ReqBase
Comm::client::ConnQueue::ReqBase ReqBase
Definition: Profiling.h:21
SWC::Comm::Protocol::Bkr::Req::CellsSelect::data
DataT data
Definition: CellsSelect.h:24
SWC::Comm::client::ConnQueueReqBase
Definition: ClientConnQueue.h:22
SWC::Comm::Protocol::Bkr::Req::CellsSelect::make
static SWC_CAN_INLINE Ptr make(const Params::CellsSelectReqRef &params, const uint32_t timeout, DataArgsT &&... args)
Definition: CellsSelect.h:28
SWC::Comm::Protocol::Bkr::Req::CellsSelect::handle
void handle(ConnHandlerPtr, const Event::Ptr &ev) override
Definition: CellsSelect.h:68
SWC::Comm::Protocol::Bkr::Params::CellsSelectReqRef
Definition: CellsSelect.h:48
SWC::Comm::Protocol::Bkr::Req::CellsSelect::handle_no_conn
void handle_no_conn() override
Definition: CellsSelect.h:59
handler_data.h
SWC::Comm::Protocol::Bkr::Req::CellsSelect::CellsSelect
CellsSelect(CellsSelect &&)=delete
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::Protocol::Bkr::Req::CellsSelect::_bkr_idx
SWC::client::Brokers::BrokerIdx _bkr_idx
Definition: CellsSelect.h:90
SWC::Comm::Protocol::Bkr::Req::CellsSelect::CellsSelect
SWC_CAN_INLINE CellsSelect(const Params::CellsSelectReqRef &params, const uint32_t timeout, DataArgsT &&... args)
Definition: CellsSelect.h:79
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::Protocol::Bkr::Req::CellsSelect::request
static SWC_CAN_INLINE void request(const Params::CellsSelectReqRef &params, const uint32_t timeout, DataArgsT &&... args)
Definition: CellsSelect.h:37
SWC::Comm::Protocol::Bkr::Req::CellsSelect::operator=
CellsSelect & operator=(const CellsSelect &)=delete
SWC::Comm::Protocol::Bkr::Req::CellsSelect::run
bool run() override
Definition: CellsSelect.h:51
SWC::Comm::Protocol::Bkr::Req::CellsSelect::Ptr
std::shared_ptr< CellsSelect > Ptr
Definition: CellsSelect.h:23
CellsSelect.h
SWC::Comm::Buffers
Definition: Buffers.h:20
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::client::Brokers::BrokerIdx::turn_around
bool turn_around(Brokers &brks) noexcept
Definition: Brokers.cc:152
SWC::Comm::Protocol::Common::Req::function
Definition: handler_data.h:19
SWC::Comm::Protocol::Bkr::Req::CellsSelect::operator=
CellsSelect & operator=(CellsSelect &&)=delete
SWC::Comm::Protocol::Bkr::Req::CellsSelect::valid
bool valid() override
Definition: CellsSelect.h:55
SWC::Comm::Protocol::Bkr::Params::CellsSelectRsp
Definition: CellsSelect.h:77
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::Bkr::Req::CellsSelect::CellsSelect
CellsSelect(const CellsSelect &)=delete
SWC::Comm::Protocol::Bkr::Req::Functional_CellsSelect
Common::Req::function< std::function< void(void *, const client::ConnQueue::ReqBase::Ptr &, Params::CellsSelectRsp &)>> Functional_CellsSelect
Definition: CellsSelect.h:120