SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
AppContext.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_AppContext_h
7 #define swcdb_core_comm_AppContext_h
8 
9 
10 #include "swcdb/core/comm/Event.h"
12 
13 
14 namespace SWC { namespace Comm {
15 
16 // forward declarations
17 class ConnHandler;
18 typedef std::shared_ptr<ConnHandler> ConnHandlerPtr;
19 
20 
21 class AppContext : public std::enable_shared_from_this<AppContext> {
22  public:
23  typedef std::shared_ptr<AppContext> Ptr;
24 
26 
29  : cfg_encoder(a_cfg_encoder) {
30  }
31 
32  AppContext(AppContext&&) = delete;
33  AppContext(const AppContext&) = delete;
35  AppContext& operator=(const AppContext&) = delete;
36 
37  virtual void init(const std::string&, const EndPoints&) { }
38 
39  virtual void stop();
40 
41  virtual void handle_established(ConnHandlerPtr conn) = 0;
42 
43  virtual void handle_disconnect(ConnHandlerPtr conn) noexcept = 0;
44 
45  virtual void handle(ConnHandlerPtr conn, const Event::Ptr& ev) = 0;
46 
47  virtual void net_bytes_sent(const ConnHandlerPtr&, size_t) noexcept { }
48 
49  virtual void net_bytes_received(const ConnHandlerPtr&, size_t) noexcept { }
50 
51  virtual void net_accepted(const EndPoint&, bool) noexcept { }
52 
53  protected:
54 
55  virtual ~AppContext() noexcept { };
56 
57 };
58 
59 
60 }} // namespace SWC::Comm
61 
62 
63 
64 #ifdef SWC_IMPL_SOURCE
66 #endif
67 
68 #endif // swcdb_core_comm_AppContext_h
SWC::Comm::AppContext::cfg_encoder
const Config::Property::Value_enum_g::Ptr cfg_encoder
Definition: AppContext.h:25
SWC::Comm::AppContext::handle_established
virtual void handle_established(ConnHandlerPtr conn)=0
SWC::Comm::AppContext::init
virtual void init(const std::string &, const EndPoints &)
Definition: AppContext.h:37
SWC::Comm::AppContext::net_bytes_received
virtual void net_bytes_received(const ConnHandlerPtr &, size_t) noexcept
Definition: AppContext.h:49
SWC::Comm::EndPoint
asio::ip::tcp::endpoint EndPoint
Definition: Resolver.h:19
SWC::Comm::AppContext::net_accepted
virtual void net_accepted(const EndPoint &, bool) noexcept
Definition: AppContext.h:51
SWC::Comm::AppContext::~AppContext
virtual ~AppContext() noexcept
Definition: AppContext.h:55
SWC::Comm::AppContext::Ptr
std::shared_ptr< AppContext > Ptr
Definition: AppContext.h:23
Resolver.h
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::Comm::AppContext::handle
virtual void handle(ConnHandlerPtr conn, const Event::Ptr &ev)=0
Definition: AppContext.cc:14
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Comm::AppContext::AppContext
AppContext(const AppContext &)=delete
SWC::Comm::AppContext
Definition: AppContext.h:21
Event.h
SWC::Comm::AppContext::net_bytes_sent
virtual void net_bytes_sent(const ConnHandlerPtr &, size_t) noexcept
Definition: AppContext.h:47
SWC::Comm::AppContext::handle_disconnect
virtual void handle_disconnect(ConnHandlerPtr conn) noexcept=0
SWC::Comm::ConnHandlerPtr
std::shared_ptr< ConnHandler > ConnHandlerPtr
Definition: AppContext.h:17
SWC::Config::Property::Value_enum_g
Definition: Property.h:662
SWC::Comm::AppContext::stop
virtual void stop()
Definition: AppContext.cc:20
SWC::Core::Vector< EndPoint >
AppContext.cc
SWC::Comm::AppContext::AppContext
AppContext(AppContext &&)=delete
SWC::Comm::AppContext::operator=
AppContext & operator=(const AppContext &)=delete
SWC::Comm::AppContext::AppContext
SWC_CAN_INLINE AppContext(Config::Property::Value_enum_g::Ptr a_cfg_encoder) noexcept
Definition: AppContext.h:28
SWC::Comm::Event::Ptr
std::shared_ptr< Event > Ptr
Definition: Event.h:33
SWC::Comm::AppContext::operator=
AppContext & operator=(AppContext &&)=delete