SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
SWC::Comm::Header Struct Referencefinal

#include <swcdb/core/comm/Header.h>

+ Collaboration diagram for SWC::Comm::Header:

Public Member Functions

 Header (uint64_t cmd=0, uint32_t timeout=0) noexcept
 
 Header (const Header &init_from_req_header) noexcept
 
 ~Header () noexcept
 
void reset () noexcept
 
void set (uint64_t cmd=0, uint32_t timeout=0) noexcept
 
uint8_t encoded_length () noexcept
 
void encode (uint8_t **bufp) const
 
void decode_prefix (const uint8_t **bufp, size_t *remainp)
 
void decode (const uint8_t **bufp, size_t *remainp)
 
void initialize_from_response (const Header &header)
 
void initialize_from_request (const Header &header)
 
void print (std::ostream &out) const
 

Public Attributes

uint8_t version
 Protocol version. More...
 
uint8_t header_len
 Length of header. More...
 
uint8_t flags
 Flags. More...
 
uint8_t buffers
 number of buffers from 0 to 2 (data+data_ext) More...
 
uint32_t id
 Request ID. More...
 
uint32_t timeout_ms
 Request timeout. More...
 
uint32_t checksum
 Header checksum (excl. it self) More...
 
uint16_t command
 Request command number. More...
 
BufferInfo data
 Data Buffer. More...
 
BufferInfo data_ext
 Data Extended Buffer. More...
 

Static Public Attributes

static const uint8_t PROTOCOL_VERSION = 1
 
static const uint8_t PREFIX_LENGTH = 2
 
static const uint8_t FIXED_LENGTH = PREFIX_LENGTH + 16
 
static const uint8_t MAX_LENGTH = FIXED_LENGTH + 15 * 2
 
static const uint8_t FLAG_REQUEST_BIT = 0x01
 
static const uint8_t FLAG_REQUEST_MASK = 0xFE
 
static const uint8_t FLAG_RESPONSE_IGNORE_BIT = 0x02
 
static const uint8_t FLAG_RESPONSE_PARTIAL_BIT = 0x04
 
static const uint8_t FLAG_RESPONSE_PARTIAL_MASK = 0xFB
 

Detailed Description

Definition at line 18 of file Header.h.

Constructor & Destructor Documentation

◆ Header() [1/2]

SWC::Comm::Header::Header ( uint64_t  cmd = 0,
uint32_t  timeout = 0 
)
inlinenoexcept

Definition at line 33 of file Header.h.

◆ Header() [2/2]

SWC::Comm::Header::Header ( const Header init_from_req_header)
inlineexplicitnoexcept

Definition at line 39 of file Header.h.

◆ ~Header()

SWC::Comm::Header::~Header ( )
inlinenoexcept

Definition at line 48 of file Header.h.

Member Function Documentation

◆ decode()

SWC_CAN_INLINE void SWC::Comm::Header::decode ( const uint8_t **  bufp,
size_t *  remainp 
)

Definition at line 149 of file Header.h.

References buffers, checksum, SWC::Core::checksum_i32_chk(), SWC::Error::COMM_HEADER_CHECKSUM_MISMATCH, command, data, data_ext, SWC::Comm::BufferInfo::decode(), SWC::Serialization::decode_i16(), SWC::Serialization::decode_i32(), SWC::Serialization::decode_i8(), flags, header_len, PREFIX_LENGTH, SWC_FMT_LD, SWC_THROWF, and timeout_ms.

+ Here is the call graph for this function:

◆ decode_prefix()

SWC_CAN_INLINE void SWC::Comm::Header::decode_prefix ( const uint8_t **  bufp,
size_t *  remainp 
)

Definition at line 138 of file Header.h.

References SWC::Error::COMM_BAD_HEADER, SWC::Serialization::decode_i8(), header_len, PREFIX_LENGTH, SWC_FMT_LU, SWC_THROWF, and version.

+ Here is the call graph for this function:

◆ encode()

SWC_CAN_INLINE void SWC::Comm::Header::encode ( uint8_t **  bufp) const

Definition at line 118 of file Header.h.

References buffers, SWC::Core::checksum_i32(), command, data, data_ext, SWC::Comm::BufferInfo::encode(), SWC::Serialization::encode_i16(), SWC::Serialization::encode_i32(), SWC::Serialization::encode_i8(), flags, header_len, SWC::Comm::BufferInfo::size, timeout_ms, and version.

Referenced by SWC::Comm::Buffers::get_buffers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encoded_length()

SWC_CAN_INLINE uint8_t SWC::Comm::Header::encoded_length ( )
noexcept

Definition at line 103 of file Header.h.

References buffers, data, data_ext, SWC::Comm::BufferInfo::encoded_length(), FIXED_LENGTH, header_len, and SWC::Comm::BufferInfo::size.

Referenced by SWC::Comm::Buffers::get_buffers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialize_from_request()

SWC_CAN_INLINE void SWC::Comm::Header::initialize_from_request ( const Header header)

Definition at line 182 of file Header.h.

References buffers, command, data, data_ext, flags, id, and SWC::Comm::BufferInfo::reset().

+ Here is the call graph for this function:

◆ initialize_from_response()

SWC_CAN_INLINE void SWC::Comm::Header::initialize_from_response ( const Header header)

Definition at line 172 of file Header.h.

References buffers, command, data, data_ext, flags, id, and SWC::Comm::BufferInfo::reset().

+ Here is the call graph for this function:

◆ print()

void SWC::Comm::Header::print ( std::ostream &  out) const

Definition at line 13 of file Header.cc.

References buffers, checksum, command, data, data_ext, flags, header_len, SWC::Comm::BufferInfo::print(), timeout_ms, and version.

Referenced by SWC::Comm::Event::print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

SWC_CAN_INLINE void SWC::Comm::Header::reset ( )
noexcept

Definition at line 89 of file Header.h.

References buffers, checksum, command, data, data_ext, flags, header_len, SWC::Comm::BufferInfo::reset(), timeout_ms, and version.

+ Here is the call graph for this function:

◆ set()

void SWC::Comm::Header::set ( uint64_t  cmd = 0,
uint32_t  timeout = 0 
)
inlinenoexcept

Definition at line 52 of file Header.h.

Member Data Documentation

◆ buffers

uint8_t SWC::Comm::Header::buffers

number of buffers from 0 to 2 (data+data_ext)

Definition at line 75 of file Header.h.

Referenced by decode(), SWC::Comm::Event::decode_buffers(), encode(), encoded_length(), initialize_from_request(), initialize_from_response(), print(), and reset().

◆ checksum

uint32_t SWC::Comm::Header::checksum

Header checksum (excl. it self)

Definition at line 78 of file Header.h.

Referenced by decode(), print(), and reset().

◆ command

uint16_t SWC::Comm::Header::command

Request command number.

Definition at line 79 of file Header.h.

Referenced by decode(), encode(), initialize_from_request(), initialize_from_response(), print(), and reset().

◆ data

◆ data_ext

◆ FIXED_LENGTH

const uint8_t SWC::Comm::Header::FIXED_LENGTH = PREFIX_LENGTH + 16
static

Definition at line 22 of file Header.h.

Referenced by encoded_length().

◆ FLAG_REQUEST_BIT

const uint8_t SWC::Comm::Header::FLAG_REQUEST_BIT = 0x01
static

◆ FLAG_REQUEST_MASK

const uint8_t SWC::Comm::Header::FLAG_REQUEST_MASK = 0xFE
static

◆ FLAG_RESPONSE_IGNORE_BIT

const uint8_t SWC::Comm::Header::FLAG_RESPONSE_IGNORE_BIT = 0x02
static

Definition at line 28 of file Header.h.

Referenced by SWC::Comm::ConnHandler::write().

◆ FLAG_RESPONSE_PARTIAL_BIT

◆ FLAG_RESPONSE_PARTIAL_MASK

const uint8_t SWC::Comm::Header::FLAG_RESPONSE_PARTIAL_MASK = 0xFB
static

Definition at line 30 of file Header.h.

◆ flags

uint8_t SWC::Comm::Header::flags

Flags.

Definition at line 74 of file Header.h.

Referenced by decode(), encode(), initialize_from_request(), initialize_from_response(), print(), and reset().

◆ header_len

uint8_t SWC::Comm::Header::header_len

Length of header.

Definition at line 72 of file Header.h.

Referenced by decode(), decode_prefix(), encode(), encoded_length(), print(), and reset().

◆ id

uint32_t SWC::Comm::Header::id

Request ID.

Definition at line 76 of file Header.h.

Referenced by initialize_from_request(), and initialize_from_response().

◆ MAX_LENGTH

const uint8_t SWC::Comm::Header::MAX_LENGTH = FIXED_LENGTH + 15 * 2
static

Definition at line 23 of file Header.h.

◆ PREFIX_LENGTH

const uint8_t SWC::Comm::Header::PREFIX_LENGTH = 2
static

◆ PROTOCOL_VERSION

const uint8_t SWC::Comm::Header::PROTOCOL_VERSION = 1
static

Definition at line 20 of file Header.h.

◆ timeout_ms

uint32_t SWC::Comm::Header::timeout_ms

Request timeout.

Definition at line 77 of file Header.h.

Referenced by decode(), encode(), print(), SWC::Comm::Event::received(), and reset().

◆ version

uint8_t SWC::Comm::Header::version

Protocol version.

Definition at line 71 of file Header.h.

Referenced by decode_prefix(), encode(), print(), and reset().


The documentation for this struct was generated from the following files: