UniRec 3.0.0
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends
NemeaPlusPlus::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.
 

Private Member Functions

 UnirecInputInterface (uint8_t interfaceID)
 
void handleReceiveErrorCodes (int errorCode) const
 
bool isEoFReceived () const noexcept
 

Private Attributes

ur_template_tm_template = nullptr
 
uint8_t m_interfaceID
 
const void * m_prioritizedDataPointer
 
bool m_EoFOnNextReceive
 

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 24 of file inputInterface.hpp.

Constructor & Destructor Documentation

◆ ~UnirecInputInterface()

NemeaPlusPlus::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()

NemeaPlusPlus::UnirecInputInterface::UnirecInputInterface ( uint8_t  interfaceID)
private

Definition at line 20 of file inputInterface.cpp.

Member Function Documentation

◆ changeTemplate()

void NemeaPlusPlus::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 102 of file inputInterface.cpp.

◆ getTemplate()

ur_template_t * NemeaPlusPlus::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 89 of file inputInterface.hpp.

◆ handleReceiveErrorCodes()

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

Definition at line 65 of file inputInterface.cpp.

◆ isEoFReceived()

bool NemeaPlusPlus::UnirecInputInterface::isEoFReceived ( ) const
privatenoexcept

Definition at line 60 of file inputInterface.cpp.

◆ receive()

std::optional< UnirecRecordView > NemeaPlusPlus::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 NemeaPlusPlus::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 87 of file inputInterface.cpp.

◆ setTimeout()

void NemeaPlusPlus::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 97 of file inputInterface.cpp.

Friends And Related Function Documentation

◆ Unirec

friend class Unirec
friend

Definition at line 101 of file inputInterface.hpp.

Field Documentation

◆ m_EoFOnNextReceive

bool NemeaPlusPlus::UnirecInputInterface::m_EoFOnNextReceive
private

Definition at line 99 of file inputInterface.hpp.

◆ m_interfaceID

uint8_t NemeaPlusPlus::UnirecInputInterface::m_interfaceID
private

Definition at line 97 of file inputInterface.hpp.

◆ m_prioritizedDataPointer

const void* NemeaPlusPlus::UnirecInputInterface::m_prioritizedDataPointer
private

Definition at line 98 of file inputInterface.hpp.

◆ m_template

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

Definition at line 96 of file inputInterface.hpp.


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