SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
ResponseCallback.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_core_comm_ResponseCallback_h
7 #define swcdb_core_comm_ResponseCallback_h
8 
10 
11 
12 namespace SWC { namespace Comm {
13 
14 class ResponseCallback: public std::enable_shared_from_this<ResponseCallback> {
15 
16  public:
17 
18  typedef std::shared_ptr<ResponseCallback> Ptr;
19 
20  ResponseCallback(const ConnHandlerPtr& conn, const Event::Ptr& ev)
21  : m_conn(conn), m_ev(ev) {
22  }
23 
24  virtual ~ResponseCallback() noexcept { };
25 
26  virtual void run() { }
27 
28  virtual bool expired(int64_t within=0) const noexcept;
29 
30  virtual void response(int& err);
31 
32  virtual void response_ok() {
33  m_conn->response_ok(m_ev);
34  }
35 
36  virtual void send_error(int err, const std::string &msg) {
37  m_conn->send_error(err , msg, m_ev);
38  }
39 
40  protected:
43 
44 };
45 
46 
47 }} // namespace SWC::Comm
48 
49 
50 
51 #ifdef SWC_IMPL_SOURCE
53 #endif
54 
55 #endif // swcdb_core_comm_ResponseCallback_h
SWC::Comm::ResponseCallback::send_error
virtual void send_error(int err, const std::string &msg)
Definition: ResponseCallback.h:36
SWC::Comm::ResponseCallback::response
virtual void response(int &err)
Definition: ResponseCallback.cc:18
SWC::Comm::ResponseCallback::~ResponseCallback
virtual ~ResponseCallback() noexcept
Definition: ResponseCallback.h:24
ResponseCallback.cc
SWC::Comm::ResponseCallback::m_ev
Event::Ptr m_ev
Definition: ResponseCallback.h:42
ConnHandler.h
SWC::Comm::ResponseCallback::ResponseCallback
ResponseCallback(const ConnHandlerPtr &conn, const Event::Ptr &ev)
Definition: ResponseCallback.h:20
SWC::Comm::ResponseCallback::m_conn
ConnHandlerPtr m_conn
Definition: ResponseCallback.h:41
SWC::Comm::ResponseCallback::run
virtual void run()
Definition: ResponseCallback.h:26
SWC::Comm::ResponseCallback::response_ok
virtual void response_ok()
Definition: ResponseCallback.h:32
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::ResponseCallback::Ptr
std::shared_ptr< ResponseCallback > Ptr
Definition: ResponseCallback.h:18
SWC::Comm::ResponseCallback
Definition: ResponseCallback.h:14
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Comm::ResponseCallback::expired
virtual bool expired(int64_t within=0) const noexcept
Definition: ResponseCallback.cc:13
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33