RESTinio
Toggle main menu visibility
Loading...
Searching...
No Matches
restinio
tcp_connection_ctx_base.hpp
Go to the documentation of this file.
1
/*
2
restinio
3
*/
4
5
/*!
6
A base class for all classes that deal with connection context.
7
*/
8
9
#
pragma
once
10
11
#
include
<
memory
>
12
13
#
include
<
restinio
/
connection_state_listener
.
hpp
>
14
15
namespace
restinio
16
{
17
18
//
19
// tcp_connection_ctx_base_t
20
//
21
22
//! TCP connection base.
23
/*!
24
Class serves as a root class for all connection context wrappers,
25
that can be passed in asio callbacks.
26
*/
27
class
tcp_connection_ctx_base_t
28
:
public
std
::
enable_shared_from_this
<
tcp_connection_ctx_base_t
>
29
{
30
public
:
31
tcp_connection_ctx_base_t
(
connection_id_t
id )
32
:
m_connection_id
{ id }
33
{}
34
35
virtual
~
tcp_connection_ctx_base_t
() =
default
;
36
37
//! Get connection id.
38
connection_id_t
connection_id
()
const
noexcept
{
return
m_connection_id
; }
39
40
//! Check timeouts for all activities.
41
virtual
void
42
check_timeout
(
43
//! A handle to itself (eliminates one shared_ptr instantiation).
44
std::shared_ptr<
tcp_connection_ctx_base_t
> & self ) = 0;
45
46
protected
:
47
48
//! Cast self to derived class.
49
template
<
typename
Derived >
50
std::shared_ptr< Derived >
51
shared_from_concrete
()
52
{
53
return
std::static_pointer_cast< Derived >( shared_from_this() );
54
}
55
56
private
:
57
//! Id of a connection.
58
const
connection_id_t
m_connection_id
;
59
};
60
61
//! Alias for http connection handle.
62
using
tcp_connection_ctx_handle_t
= std::shared_ptr<
tcp_connection_ctx_base_t
>;
63
64
//! Alias for http connection weak handle.
65
using
tcp_connection_ctx_weak_handle_t
= std::weak_ptr<
tcp_connection_ctx_base_t
>;
66
67
}
/* namespace restinio */
restinio::tcp_connection_ctx_base_t
TCP connection base.
Definition
tcp_connection_ctx_base.hpp:29
restinio::tcp_connection_ctx_base_t::check_timeout
virtual void check_timeout(std::shared_ptr< tcp_connection_ctx_base_t > &self)=0
Check timeouts for all activities.
restinio::tcp_connection_ctx_base_t::m_connection_id
const connection_id_t m_connection_id
Id of a connection.
Definition
tcp_connection_ctx_base.hpp:58
restinio::tcp_connection_ctx_base_t::tcp_connection_ctx_base_t
tcp_connection_ctx_base_t(connection_id_t id)
Definition
tcp_connection_ctx_base.hpp:31
restinio::tcp_connection_ctx_base_t::connection_id
connection_id_t connection_id() const noexcept
Get connection id.
Definition
tcp_connection_ctx_base.hpp:38
restinio::tcp_connection_ctx_base_t::shared_from_concrete
std::shared_ptr< Derived > shared_from_concrete()
Cast self to derived class.
Definition
tcp_connection_ctx_base.hpp:51
restinio::tcp_connection_ctx_base_t::~tcp_connection_ctx_base_t
virtual ~tcp_connection_ctx_base_t()=default
restinio
Definition
sendfile_operation_default.ipp:12
restinio::tcp_connection_ctx_weak_handle_t
std::weak_ptr< tcp_connection_ctx_base_t > tcp_connection_ctx_weak_handle_t
Alias for http connection weak handle.
Definition
tcp_connection_ctx_base.hpp:65
restinio::connection_id_t
std::uint64_t connection_id_t
Type for ID of connection.
Definition
common_types.hpp:174
restinio::tcp_connection_ctx_handle_t
std::shared_ptr< tcp_connection_ctx_base_t > tcp_connection_ctx_handle_t
Alias for http connection handle.
Definition
tcp_connection_ctx_base.hpp:62
Generated by
1.17.0