UniRec 3.3.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends
Nemea::UnirecInputInterface Class Reference

A class that provides an interface for receiving data in the Unirec format using the TRAP library. More...

#include <inputInterface.hpp>

Public Member Functions

std::optional< UnirecRecordViewreceive ()
 Receives data from the interface and returns an optional UnirecRecordView object.
 
void changeTemplate ()
 Changes the Unirec template used by the input interface.
 
void setRequieredFormat (const std::string &templateSpecification)
 Sets the required Unirec format specification.
 
void setTimeout (int timeout)
 Sets the receive timeout for the interface. This method sets the timeout for receiving UniRec records on the interface. If no record is received within the specified timeout, the receive method returns an empty optional.
 
 ~UnirecInputInterface ()
 Destructor for UnirecInputInterface class. This method frees the memory used by the Unirec template.
 
ur_template_tgetTemplate () const noexcept
 Gets the Unirec template used by the input interface.
 
InputInteraceStats getInputInterfaceStats () const
 Gets the statistics for the input interface.
 

Private Member Functions

 UnirecInputInterface (uint8_t interfaceID)
 
void handleReceiveErrorCodes (int errorCode) const
 
void changeInternalTemplate (const std::string &templateSpecification)
 

Private Attributes

ur_template_tm_template = nullptr
 
uint8_t m_interfaceID
 
uint64_t m_sequenceNumber
 
const void * m_prioritizedDataPointer
 

Friends

class Unirec
 

Detailed Description

A class that provides an interface for receiving data in the Unirec format using the TRAP library.

Definition at line 25 of file inputInterface.hpp.

Constructor & Destructor Documentation

◆ ~UnirecInputInterface()

Nemea::UnirecInputInterface::~UnirecInputInterface ( )

Destructor for UnirecInputInterface class. This method frees the memory used by the Unirec template.

Definition at line 15 of file inputInterface.cpp.

◆ UnirecInputInterface()

Nemea::UnirecInputInterface::UnirecInputInterface ( uint8_t  interfaceID)
private

Definition at line 20 of file inputInterface.cpp.

Member Function Documentation

◆ changeInternalTemplate()

void Nemea::UnirecInputInterface::changeInternalTemplate ( const std::string &  templateSpecification)
private

Definition at line 105 of file inputInterface.cpp.

◆ changeTemplate()

void Nemea::UnirecInputInterface::changeTemplate ( )

Changes the Unirec template used by the input interface.

This method should be called every time when the FormatChangeException is thrown.

This method changes the UniRec record template used for decoding records received on the interface.

Exceptions
std::runtime_errorif the data format was not loaded or the template could not be edited.

Definition at line 90 of file inputInterface.cpp.

◆ getInputInterfaceStats()

InputInteraceStats Nemea::UnirecInputInterface::getInputInterfaceStats ( ) const

Gets the statistics for the input interface.

This method returns the actual statistics for the input interface.

Returns
The statistics for the input interface.

Definition at line 125 of file inputInterface.cpp.

◆ getTemplate()

ur_template_t * Nemea::UnirecInputInterface::getTemplate ( ) const
inlinenoexcept

Gets the Unirec template used by the input interface.

This method returns a pointer to the Unirec template used by the input interface.

Returns
A pointer to the Unirec template used by the input interface.

Definition at line 90 of file inputInterface.hpp.

◆ handleReceiveErrorCodes()

void Nemea::UnirecInputInterface::handleReceiveErrorCodes ( int  errorCode) const
private

Definition at line 56 of file inputInterface.cpp.

◆ receive()

std::optional< UnirecRecordView > Nemea::UnirecInputInterface::receive ( )

Receives data from the interface and returns an optional UnirecRecordView object.

If data is received successfully, an UnirecRecordView object is returned that provides a view into the received data. If no data is available or a timeout occurs, std::nullopt is returned.

Returns
An optional UnirecRecordView object.
Exceptions
EoFExceptionif the end of the input stream is reached.
FormatChangeExceptionif the record format changes.

Definition at line 28 of file inputInterface.cpp.

◆ setRequieredFormat()

void Nemea::UnirecInputInterface::setRequieredFormat ( const std::string &  templateSpecification)

Sets the required Unirec format specification.

This method sets the required Unirec format specification for the input interface. Format: "uint64 BYTES, string SNI" (unirecDataType NAME)

Parameters
templateSpecificationThe required Unirec format specification.
Exceptions
std::runtime_errorif the required format could not be set.

Definition at line 78 of file inputInterface.cpp.

◆ setTimeout()

void Nemea::UnirecInputInterface::setTimeout ( int  timeout)

Sets the receive timeout for the interface. This method sets the timeout for receiving UniRec records on the interface. If no record is received within the specified timeout, the receive method returns an empty optional.

Parameters
timeoutThe timeout value in microseconds.
  • TRAP_WAIT: Blocking mode, wait for client's connection, for message transport to/from internal system buffer.
  • TRAP_NO_WAIT: Non-Blocking mode, do not wait ever.
  • timeout: Wait max for specific time.

Definition at line 120 of file inputInterface.cpp.

Friends And Related Symbol Documentation

◆ Unirec

friend class Unirec
friend

Definition at line 111 of file inputInterface.hpp.

Field Documentation

◆ m_interfaceID

uint8_t Nemea::UnirecInputInterface::m_interfaceID
private

Definition at line 107 of file inputInterface.hpp.

◆ m_prioritizedDataPointer

const void* Nemea::UnirecInputInterface::m_prioritizedDataPointer
private

Definition at line 109 of file inputInterface.hpp.

◆ m_sequenceNumber

uint64_t Nemea::UnirecInputInterface::m_sequenceNumber
private

Definition at line 108 of file inputInterface.hpp.

◆ m_template

ur_template_t* Nemea::UnirecInputInterface::m_template = nullptr
private

Definition at line 106 of file inputInterface.hpp.


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