SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
CommonMeta.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_ranger_queries_update_CommonMeta_h
7 #define swcdb_ranger_queries_update_CommonMeta_h
8 
9 
10 namespace SWC { namespace Ranger { namespace Query { namespace Update {
11 
12 
13 class CommonMeta : public BaseMeta {
14  public:
15  typedef std::shared_ptr<CommonMeta> Ptr;
16  typedef std::function<void(const Ptr&)> Cb_t;
17 
19  static Ptr make(const RangePtr& range, Cb_t&& cb) {
20  return Ptr(new CommonMeta(range, std::move(cb)));
21  }
22 
23  const Cb_t cb;
24 
26  CommonMeta(const RangePtr& a_range, Cb_t&& a_cb)
27  : BaseMeta(a_range), cb(std::move(a_cb)) {
28  }
29 
30  virtual ~CommonMeta() noexcept { }
31 
32  virtual void response(int err=Error::OK) override {
33  struct Task {
34  Ptr hdlr;
36  Task(Ptr&& a_hdlr) noexcept : hdlr(std::move(a_hdlr)) { }
38  Task(Task&& other) noexcept : hdlr(std::move(other.hdlr)) { }
39  Task(const Task&) = delete;
40  Task& operator=(Task&&) = delete;
41  Task& operator=(const Task&) = delete;
42  ~Task() noexcept { }
43  void operator()() { hdlr->cb(hdlr); }
44  };
45  if(is_last_rsp(err)) {
47  Task(std::dynamic_pointer_cast<CommonMeta>(shared_from_this())));
48  }
49  }
50 
51  virtual void callback() override {
52  cb(std::dynamic_pointer_cast<CommonMeta>(shared_from_this()));
53  }
54 
55 };
56 
57 
58 }}}}
59 
60 
61 #endif // swcdb_ranger_queries_update_CommonMeta_h
SWC::Ranger::Query::Update::CommonMeta::response
virtual void response(int err=Error::OK) override
Definition: CommonMeta.h:32
SWC::client::Query::Update::Handlers::Base::Ptr
std::shared_ptr< Base > Ptr
Definition: Base.h:27
SWC::Ranger::Query::Update::CommonMeta::Cb_t
std::function< void(const Ptr &)> Cb_t
Definition: CommonMeta.h:16
SWC::client::Query::Update::Handlers::Base::operator=
Base & operator=(const Base &)=delete
SWC::Ranger::Query::Update::BaseMeta::is_last_rsp
bool is_last_rsp(int err)
Definition: BaseMeta.cc:31
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC::Ranger::RangePtr
std::shared_ptr< Range > RangePtr
Definition: Columns.h:15
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Ranger::Query::Update::CommonMeta::Ptr
std::shared_ptr< CommonMeta > Ptr
Definition: CommonMeta.h:15
SWC::Ranger::Query::Update::BaseMeta
Definition: BaseMeta.h:27
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Ranger::Query::Update::CommonMeta::callback
virtual void callback() override
Definition: CommonMeta.h:51
SWC::Ranger::Query::Update::CommonMeta
Definition: CommonMeta.h:13
SWC::Ranger::Query::Update::CommonMeta::CommonMeta
SWC_CAN_INLINE CommonMeta(const RangePtr &a_range, Cb_t &&a_cb)
Definition: CommonMeta.h:26
SWC::Env::Rgr::post
static SWC_CAN_INLINE void post(T_Handler &&handler)
Definition: RangerEnv.h:114
SWC::Ranger::Query::Update::BaseMeta::range
RangePtr range
Definition: BaseMeta.h:31
SWC::Ranger::Query::Update::CommonMeta::cb
const Cb_t cb
Definition: CommonMeta.h:23
SWC::Ranger::Query::Update::CommonMeta::~CommonMeta
virtual ~CommonMeta() noexcept
Definition: CommonMeta.h:30
SWC::Ranger::Query::Update::CommonMeta::make
static SWC_CAN_INLINE Ptr make(const RangePtr &range, Cb_t &&cb)
Definition: CommonMeta.h:19