A class for sending UniRec records through a Trap interface.
More...
#include <outputInterface.hpp>
A class for sending UniRec records through a Trap interface.
Definition at line 24 of file outputInterface.hpp.
◆ ~UnirecOutputInterface()
NemeaPlusPlus::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 23 of file outputInterface.cpp.
◆ UnirecOutputInterface()
NemeaPlusPlus::UnirecOutputInterface::UnirecOutputInterface |
( |
uint8_t |
interfaceID | ) |
|
|
private |
◆ changeTemplate()
void NemeaPlusPlus::UnirecOutputInterface::changeTemplate |
( |
const std::string & |
templateFields = "" | ) |
|
Changes the UniRec template for the Trap interface.
Format: "uint64 BYTES, string SNI" (unirecDataType NAME)
- Parameters
-
templateFields | A string containing the UniRec template fields. |
- Exceptions
-
std::runtime_error | if the template could not be created. |
Definition at line 95 of file outputInterface.cpp.
◆ createUnirecRecord()
UnirecRecord NemeaPlusPlus::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.
- Parameters
-
maxVariableFieldsSize | The maximum size for variable fields in the new UniRec record. |
- Returns
- A newly created UnirecRecord instance.
Definition at line 121 of file outputInterface.cpp.
◆ doNotsendEoFOnExit()
void NemeaPlusPlus::UnirecOutputInterface::doNotsendEoFOnExit |
( |
| ) |
|
◆ getTemplate()
ur_template_t* NemeaPlusPlus::UnirecOutputInterface::getTemplate |
( |
| ) |
const |
|
inlinenoexcept |
Gets the Unirec template used by the output interface.
This method returns a pointer to the Unirec template used by the output interface.
- Returns
- A pointer to the Unirec template used by the output interface.
Definition at line 91 of file outputInterface.hpp.
◆ getUnirecRecord()
UnirecRecord& NemeaPlusPlus::UnirecOutputInterface::getUnirecRecord |
( |
| ) |
|
|
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.
- Note
- The record accessed through this function is specific to this instance of the UnirecOutputInterface and should not be shared across multiple instances or threads.
- Returns
- A reference to the pre-allocated UniRec record.
Definition at line 116 of file outputInterface.hpp.
◆ handleSendErrorCodes()
bool NemeaPlusPlus::UnirecOutputInterface::handleSendErrorCodes |
( |
int |
errorCode | ) |
const |
|
private |
◆ send() [1/2]
bool NemeaPlusPlus::UnirecOutputInterface::send |
( |
UnirecRecord & |
unirecRecord | ) |
const |
Sends a UniRec record through the Trap interface.
- Parameters
-
unirecRecord | the Unirec record to send |
- Exceptions
-
std::runtime_error | if an error occurs while sending the record |
- Returns
- true if the record was sent successfully, false if a timeout occurred
Definition at line 32 of file outputInterface.cpp.
◆ send() [2/2]
bool NemeaPlusPlus::UnirecOutputInterface::send |
( |
UnirecRecordView & |
unirecRecordView | ) |
const |
Sends a UniRec record view through the Trap interface.
- Parameters
-
unirecRecordView | The UniRec record view to send. |
- Exceptions
-
std::runtime_error | if an error occurs while sending the record |
- Returns
- true if the record was sent successfully, false if a timeout occurred
Definition at line 38 of file outputInterface.cpp.
◆ sendEoF()
void NemeaPlusPlus::UnirecOutputInterface::sendEoF |
( |
| ) |
const |
|
private |
◆ sendFlush()
void NemeaPlusPlus::UnirecOutputInterface::sendFlush |
( |
| ) |
const |
Flushes any pending UniRec records in the Trap interface.
Definition at line 69 of file outputInterface.cpp.
◆ setAutoflushTimeout()
void NemeaPlusPlus::UnirecOutputInterface::setAutoflushTimeout |
( |
int |
timeout | ) |
|
Sets the autoflush timeout for the Trap interface.
- Parameters
-
timeout | The timeout value in microseconds.
TRAP_NO_AUTO_FLUSH : Do not autoflush trap buffers
|
Definition at line 84 of file outputInterface.cpp.
◆ setTimeout()
void NemeaPlusPlus::UnirecOutputInterface::setTimeout |
( |
int |
timeout | ) |
|
Sets the send timeout for the Trap interface.
- Parameters
-
timeout | The timeout value in microseconds.
TRAP_WAIT : Blocking mode, wait for client's connection, for message transport to/from internal system buffer.
TRAP_HALFWAIT : Blocking only if any client is connected.
TRAP_NO_WAIT : Non-Blocking mode, do not wait ever.
timeout : Wait max for specific time.
|
Definition at line 79 of file outputInterface.cpp.
◆ Unirec
◆ m_interfaceID
uint8_t NemeaPlusPlus::UnirecOutputInterface::m_interfaceID |
|
private |
◆ m_sendEoFonExit
bool NemeaPlusPlus::UnirecOutputInterface::m_sendEoFonExit |
|
private |
◆ m_template
ur_template_t* NemeaPlusPlus::UnirecOutputInterface::m_template = nullptr |
|
private |
◆ m_unirecRecord
UnirecRecord NemeaPlusPlus::UnirecOutputInterface::m_unirecRecord |
|
private |
The documentation for this class was generated from the following files: