qb
2.0.0.0
C++17 Actor Framework
|
Base interface for all message processing protocols. More...
#include <protocol.h>
Public Member Functions | |
virtual | ~IProtocol ()=default |
Virtual destructor. | |
virtual std::size_t | getMessageSize () noexcept=0 |
Determines the size of the next complete message in the input buffer. | |
virtual void | onMessage (std::size_t size) noexcept=0 |
Processes a complete message that has been identified in the input buffer. | |
virtual void | reset () noexcept=0 |
Resets the internal state of the protocol. | |
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. |
Base interface for all message processing protocols.
This interface defines the essential methods that all protocol implementations must provide for message framing (identifying message boundaries in a byte stream) and processing.
|
virtualdefault |
Virtual destructor.
Ensures proper cleanup for derived protocol classes.
|
pure virtualnoexcept |
Determines the size of the next complete message in the input buffer.
This method must be implemented by concrete protocols to examine the current input buffer (typically accessed via the associated I/O component) and determine if a complete message is available according to the protocol's framing rules.
Implemented in qb::io::async::AProtocol< _IO_ >, qb::io::async::AProtocol< IO_ >, 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 >.
|
pure virtualnoexcept |
Processes a complete message that has been identified in the input buffer.
This method is called by the framework when getMessageSize() has returned a non-zero size. The implementation should process the message of the given size starting from the beginning of the current input buffer. After processing, the derived I/O component is usually responsible for flushing these size bytes from its input buffer.
size | The size of the complete message to process, as determined by getMessageSize(). |
Implemented in qb::io::async::AProtocol< _IO_ >, qb::io::async::AProtocol< IO_ >, 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'>.
|
pure virtualnoexcept |
Resets the internal state of the protocol.
This method should be called to clear any partial parsing state, preparing the protocol to start parsing a new message from a fresh state. This is important after errors, disconnections, or when switching protocols.
Implemented in qb::io::async::AProtocol< _IO_ >, qb::io::async::AProtocol< IO_ >, 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 >.
|
inlinenodiscardnoexcept |
Checks if the protocol is in a valid operational state.
|
inlinenoexcept |
Marks the protocol as being in an invalid or non-operational state.
This method can be called by the protocol implementation (or externally) to indicate that it has encountered an unrecoverable parsing error or that the connection should be closed after processing any pending data. The I/O component might check this status via ok().
|
inlinenoexcept |
Sets the flag indicating whether the protocol should flush the input buffer after processing a message.
should_flush | true if the protocol should flush the input buffer after processing a message, false otherwise. |
|
inlinenoexcept |
Gets the flag indicating whether the protocol should flush the input buffer after processing a message.