UniRec 3.3.2
|
A class for sending UniRec records through a Trap interface. More...
#include <outputInterface.hpp>
Public Member Functions | |
bool | send (UnirecRecord &unirecRecord) const |
Sends a UniRec record through the Trap interface. | |
bool | send (UnirecRecordView &unirecRecordView) const |
Sends a UniRec record view through the Trap interface. | |
void | sendFlush () const |
Flushes any pending UniRec records in the Trap interface. | |
void | setTimeout (int timeout) |
Sets the send timeout for the Trap interface. | |
void | setAutoflushTimeout (int timeout) |
Sets the autoflush timeout for the Trap interface. | |
void | changeTemplate (const std::string &templateFields="") |
Changes the UniRec template for the Trap interface. | |
void | doNotsendEoFOnExit () |
Disables sending an end-of-file marker on exit. | |
ur_template_t * | getTemplate () const noexcept |
Gets the Unirec template used by the output interface. | |
~UnirecOutputInterface () | |
Destructor for the UnirecOutputInterface class. | |
UnirecRecord & | getUnirecRecord () noexcept |
Gets a reference to the pre-allocated UniRec record for efficient use. | |
UnirecRecord | createUnirecRecord (size_t maxVariableFieldsSize=UR_MAX_SIZE) |
Creates a new UniRec record with the specified maximum variable fields size. | |
Private Member Functions | |
UnirecOutputInterface (uint8_t interfaceID) | |
bool | handleSendErrorCodes (int errorCode) const |
void | sendEoF () const |
Private Attributes | |
ur_template_t * | m_template = nullptr |
uint8_t | m_interfaceID |
bool | m_sendEoFonExit |
bool | m_isInitialized |
UnirecRecord | m_unirecRecord |
Friends | |
class | Unirec |
A class for sending UniRec records through a Trap interface.
Definition at line 24 of file outputInterface.hpp.
Nemea::UnirecOutputInterface::~UnirecOutputInterface | ( | ) |
Destructor for the UnirecOutputInterface class.
Sends an end-of-file marker if m_sendEoFonExit is true, then frees the memory allocated for the UniRec template.
Definition at line 24 of file outputInterface.cpp.
|
private |
Definition at line 16 of file outputInterface.cpp.
Changes the UniRec template for the Trap interface.
Format: "uint64 BYTES, string SNI" (unirecDataType NAME)
templateFields | A string containing the UniRec template fields. |
std::runtime_error | if the template could not be created. |
Definition at line 96 of file outputInterface.cpp.
UnirecRecord Nemea::UnirecOutputInterface::createUnirecRecord | ( | size_t | maxVariableFieldsSize = UR_MAX_SIZE | ) |
Creates a new UniRec record with the specified maximum variable fields size.
This function generates a fresh UniRec record instance, ready to be populated with data before sending it through the TRAP interface. The maximum size of variable fields can be specified to suit your data insertion needs. Unlike using the pre-allocated record with the getUnirecRecord
function, this function involves memory allocation and may have a slightly higher overhead.
maxVariableFieldsSize | The maximum size for variable fields in the new UniRec record. |
Definition at line 124 of file outputInterface.cpp.
void Nemea::UnirecOutputInterface::doNotsendEoFOnExit | ( | ) |
Disables sending an end-of-file marker on exit.
Definition at line 75 of file outputInterface.cpp.
|
inlinenoexcept |
Gets the Unirec template used by the output interface.
This method returns a pointer to the Unirec template used by the output interface.
Definition at line 91 of file outputInterface.hpp.
|
inlinenoexcept |
Gets a reference to the pre-allocated UniRec record for efficient use.
This function provides access to the UniRec record instance that has already been pre-allocated within the UnirecOutputInterface. It allows direct modification of the record's fields before sending it through the TRAP interface. Using the pre-allocated record can be faster compared to creating a new record, as there is no memory allocation involved. However, please note that using the same record in a multithreaded context may not be thread-safe.
Definition at line 116 of file outputInterface.hpp.
Definition at line 45 of file outputInterface.cpp.
bool Nemea::UnirecOutputInterface::send | ( | UnirecRecord & | unirecRecord | ) | const |
Sends a UniRec record through the Trap interface.
unirecRecord | the Unirec record to send |
std::runtime_error | if an error occurs while sending the record |
Definition at line 33 of file outputInterface.cpp.
bool Nemea::UnirecOutputInterface::send | ( | UnirecRecordView & | unirecRecordView | ) | const |
Sends a UniRec record view through the Trap interface.
unirecRecordView | The UniRec record view to send. |
std::runtime_error | if an error occurs while sending the record |
Definition at line 39 of file outputInterface.cpp.
|
private |
Definition at line 90 of file outputInterface.cpp.
void Nemea::UnirecOutputInterface::sendFlush | ( | ) | const |
Flushes any pending UniRec records in the Trap interface.
Definition at line 70 of file outputInterface.cpp.
Sets the autoflush timeout for the Trap interface.
timeout | The timeout value in microseconds.
|
Definition at line 85 of file outputInterface.cpp.
Sets the send timeout for the Trap interface.
timeout | The timeout value in microseconds.
|
Definition at line 80 of file outputInterface.cpp.
Definition at line 143 of file outputInterface.hpp.
|
private |
Definition at line 138 of file outputInterface.hpp.
|
private |
Definition at line 140 of file outputInterface.hpp.
|
private |
Definition at line 139 of file outputInterface.hpp.
|
private |
Definition at line 137 of file outputInterface.hpp.
|
private |
Definition at line 141 of file outputInterface.hpp.