![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Serializes outgoing protocol messages and primitive values. More...
#include <serializer.hpp>
Classes | |
struct | SpecialBytes |
Special byte constants used in the Simple Communication Protocol. More... | |
Static Public Member Functions | |
static internal::SerializedMessage | serialize (OutMessage &&msg) |
Serialize an irsol::protocol::OutMessage variant into a serialized protocol message. | |
template<typename T , std::enable_if_t< irsol::traits::is_type_in_variant_v< T, OutMessage >, int > = 0> | |
static internal::SerializedMessage | serialize (T &&msg) |
Serialize a specific irsol::protocol::OutMessage type into a serialized protocol message. | |
static std::string | serializeValue (irsol::types::protocol_value_t &&value) |
Serialize a protocol primitive value to a string. | |
template<typename T , std::enable_if_t< irsol::traits::is_type_in_variant< T, irsol::types::protocol_value_t >::value, int > = 0> | |
static std::string | serializeValue (T &&value) |
Serialize a specific primitive type to a string. | |
static std::string | serializeBinaryDataAttribute (irsol::protocol::BinaryDataAttribute &&att) |
Serialize a irsol::protocol::BinaryDataAttribute to a string. | |
Static Public Attributes | |
static constexpr const char * | message_termination = "\n" |
Message line termination sequence (newline character) used to "close" a serialized message. | |
Private Member Functions | |
Serializer ()=delete | |
This class cannot be instantiated. | |
Static Private Member Functions | |
static internal::SerializedMessage | serializeSuccess (Success &&msg) |
Serializes a irsol::protocol::Success message to a binary protocol message. | |
static internal::SerializedMessage | serializeBinaryDataBuffer (BinaryDataBuffer &&msg) |
Serializes a irsol::protocol::BinaryDataBuffer message to a binary protocol message. | |
static internal::SerializedMessage | serializeImageBinaryData (ImageBinaryData &&msg) |
Serializes a irsol::protocol::ImageBinaryData message to a binary protocol message. | |
static internal::SerializedMessage | serializeColorImageBinaryData (ColorImageBinaryData &&msg) |
Serializes a irsol::protocol::ColorImageBinaryData message to a binary protocol message. | |
static internal::SerializedMessage | serializeError (Error &&msg) |
Serializes a irsol::protocol::Error message to a binary protocol message. | |
Serializes outgoing protocol messages and primitive values.
This class offers a collection of static methods to serialize irsol::protocol::OutMessage variant types, as well as protocol primitive values such as integers, doubles, and strings (irsol::types::protocol_value_t), into irsol::protocol::internal::SerializedMessage instances or plain strings.
The class uses compile-time checks to ensure that only valid message types are serialized. It also provides utility constants for the special byte markers used in the protocol, following the Simple Communication Protocol specification used by irsol.
The serialization consumes the input message or value (via rvalue references), leaving the original object in a valid but unspecified state.
Definition at line 45 of file serializer.hpp.
|
privatedelete |
This class cannot be instantiated.
|
static |
Serialize an irsol::protocol::OutMessage variant into a serialized protocol message.
The message is consumed by this operation.
msg | The irsol::protocol::OutMessage to serialize. |
Definition at line 14 of file serializer.cpp.
|
inlinestatic |
Serialize a specific irsol::protocol::OutMessage type into a serialized protocol message.
Enabled only for types contained in the irsol::protocol::OutMessage variant. The method dispatches to specialized serialization functions based on message type.
T | The specific irsol::protocol::OutMessage type to serialize. |
msg | The message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 95 of file serializer.hpp.
|
static |
Serialize a irsol::protocol::BinaryDataAttribute to a string.
att | The irsol::protocol::BinaryDataAttribute to serialize. |
Definition at line 131 of file serializer.cpp.
|
staticprivate |
Serializes a irsol::protocol::BinaryDataBuffer message to a binary protocol message.
msg | The BinaryDataBuffer message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 63 of file serializer.cpp.
|
staticprivate |
Serializes a irsol::protocol::ColorImageBinaryData message to a binary protocol message.
msg | The ColorImageBinaryData message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 116 of file serializer.cpp.
|
staticprivate |
Serializes a irsol::protocol::Error message to a binary protocol message.
msg | The Error message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 124 of file serializer.cpp.
|
staticprivate |
Serializes a irsol::protocol::ImageBinaryData message to a binary protocol message.
This method serializes the image data into a binary buffer suitable for transmission. The image data is assumed to be in unpacked Mono12 format (2 bytes per pixel). During serialization, the bytes for each pixel are swapped (i.e., the order of the two bytes for each pixel is reversed) to match the IRSOL server protocol requirements. The resulting buffer contains the image data with swapped bytes, ready for network transfer.
msg | The ImageBinaryData message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 71 of file serializer.cpp.
|
staticprivate |
Serializes a irsol::protocol::Success message to a binary protocol message.
msg | The Success message to serialize. |
msg
is consumed by this function and is left in a valid but unspecified state after the call. Definition at line 37 of file serializer.cpp.
|
static |
Serialize a protocol primitive value to a string.
Supported types include int
, double
, and std::string
(see irsol::types::protocol_value_t).
value | The protocol value to serialize. |
Definition at line 26 of file serializer.cpp.
|
inlinestatic |
Serialize a specific primitive type to a string.
Enabled only for types contained in irsol::types::protocol_value_t.
T | The primitive type to serialize (int , double , or std::string ). |
value | The value to serialize. |
Definition at line 136 of file serializer.hpp.
|
staticconstexpr |
Message line termination sequence (newline character) used to "close" a serialized message.
Definition at line 65 of file serializer.hpp.