qb
2.0.0.0
C++17 Actor Framework
|
Abstract base class for I/O-component-aware protocols (CRTP). More...
#include <protocol.h>
Protected Member Functions | |
AProtocol ()=delete | |
Default constructor is deleted to ensure an I/O component is always associated. | |
AProtocol (_IO_ &io) noexcept | |
Constructor that associates the protocol with an I/O component. | |
virtual | ~AProtocol ()=default |
Virtual destructor. | |
virtual std::size_t | getMessageSize () noexcept=0 |
Determines the size of the next complete message in the input buffer of the associated I/O component. | |
virtual void | onMessage (std::size_t size) noexcept=0 |
Processes a complete message from the input buffer of the associated I/O component. | |
virtual void | reset () noexcept=0 |
Resets the internal parsing state of the protocol. |
Protected Attributes | |
_IO_ & | _io |
Reference to the I/O component instance that this protocol is associated with. |
Additional Inherited Members | |
Public Member Functions inherited from qb::io::async::IProtocol | |
virtual | ~IProtocol ()=default |
Virtual destructor. | |
bool | ok () const noexcept |
Checks if the protocol is in a valid operational state. | |
void | not_ok () noexcept |
Marks the protocol as being in an invalid or non-operational state. | |
void | set_should_flush (bool should_flush) noexcept |
Sets the flag indicating whether the protocol should flush the input buffer after processing a message. | |
bool | should_flush () const noexcept |
Gets the flag indicating whether the protocol should flush the input buffer after processing a message. |
Abstract base class for I/O-component-aware protocols (CRTP).
This template class extends the IProtocol interface and is designed to be used with the Curiously Recurring Template Pattern (CRTP). It provides the protocol implementation with a reference (_io) to its associated I/O component (_IO_), allowing the protocol to interact with the I/O component's buffers and dispatch parsed messages to its handlers.
_IO_ | The I/O component type (e.g., MyTcpSession) that this protocol works with. This _IO_ type is expected to provide access to input/output buffers (e.g., _io.in(), _io.out()) and an on(typename ProtocolType::message&&) handler for received messages. |
|
inlineprotectednoexcept |
Constructor that associates the protocol with an I/O component.
io | Reference to the I/O component (_IO_&) that will use this protocol instance. |
|
protectedpure virtualnoexcept |
Determines the size of the next complete message in the input buffer of the associated I/O component.
Concrete protocols must implement this to define their message framing logic by inspecting this->_io.in().
Implements qb::io::async::IProtocol.
Implemented in qb::io::protocol::accept< _IO_, _Socket >, qb::io::protocol::accept< acceptor, typename _Prot::socket_type >, qb::io::protocol::handshake< _IO_ >, qb::protocol::base::byte_terminated< _IO_, _EndByte >, qb::protocol::base::byte_terminated< _IO_, '\0' >, qb::protocol::base::byte_terminated< IO_, '\0'>, qb::protocol::base::bytes_terminated< _IO_, _Trait >, qb::protocol::base::size_as_header< _IO_, _Size >, and qb::protocol::base::size_as_header< _IO_, uint16_t >.
|
protectedpure virtualnoexcept |
Processes a complete message from the input buffer of the associated I/O component.
size | The size of the complete message to process. |
Concrete protocols must implement this to parse the message and typically call this->_io.on(typename ConcreteProtocol::message{...}).
Implements qb::io::async::IProtocol.
Implemented in qb::io::protocol::accept< _IO_, _Socket >, qb::io::protocol::accept< acceptor, typename _Prot::socket_type >, qb::io::protocol::handshake< _IO_ >, qb::protocol::json< IO_ >, qb::protocol::json_packed< IO_ >, qb::protocol::text::basic_text< _IO_, _StringTrait, _Sep >, qb::protocol::text::basic_text< _IO_, const std::string_view, '\0'>, qb::protocol::text::basic_text< _IO_, const std::string_view, '\n'>, qb::protocol::text::basic_text< _IO_, std::string, '\0'>, and qb::protocol::text::basic_text< _IO_, std::string, '\n'>.
|
protectedpure virtualnoexcept |
Resets the internal parsing state of the protocol.
Implements qb::io::async::IProtocol.
Implemented in qb::io::protocol::accept< _IO_, _Socket >, qb::io::protocol::accept< acceptor, typename _Prot::socket_type >, qb::io::protocol::handshake< _IO_ >, qb::protocol::base::byte_terminated< _IO_, _EndByte >, qb::protocol::base::byte_terminated< _IO_, '\0' >, qb::protocol::base::byte_terminated< IO_, '\0'>, qb::protocol::base::bytes_terminated< _IO_, _Trait >, qb::protocol::base::size_as_header< _IO_, _Size >, and qb::protocol::base::size_as_header< _IO_, uint16_t >.