12#include <libtrap/trap.h>
23 , m_prioritizedDataPointer(
nullptr)
24 , m_sendEoFonExit(
true)
25 , m_isInitialized(
false)
73 throw std::runtime_error(
74 "UnirecBidirectionalInterface::receive() has failed. Trap interface is not "
78 throw std::runtime_error(
79 "UnirecBidirectionalInterface::receive() has failed. Trap interface is terminated.");
82 throw std::runtime_error(
83 "UnirecBidirectionalInterface::receive() has failed. Interface ID out of range.");
85 throw std::runtime_error(
86 "UnirecBidirectionalInterface::receive() has failed. Return code: "
94 throw std::runtime_error(
95 "UnirecBidirectionalInterface::setRequieredFormat() has failed. Unable to set required "
110 throw std::runtime_error(
111 "UnirecBidirectionalInterface::changeTemplate() has failed. Template could not be "
119 throw std::runtime_error(
"UnirecBidirectionalInterface::changeTemplate() has failed.");
124 throw std::runtime_error(
"UnirecBidirectionalInterface::changeTemplate() has failed.");
135 const char*
spec =
nullptr;
139 throw std::runtime_error(
140 "UnirecBidirectionalInterface::changeTemplate() has failed. Data format was not "
179 throw std::runtime_error(
180 "UnirecBidirectionalInterface::send() has failed. Trap interface is not initialized.");
183 throw std::runtime_error(
184 "UnirecBidirectionalInterface::send() has failed. Trap interface is terminated.");
187 throw std::runtime_error(
188 "UnirecBidirectionalInterface::send() has failed. Interface ID out of range.");
190 throw std::runtime_error(
191 "UnirecBidirectionalInterface::send() has failed. Return code: " + std::to_string(
errorCode)
217 char dummy[1] = { 0 };
Defines a bidirectional interface for sending and receiving unirec records using the TRAP interface p...
An exception that is thrown when the end of the input stream is reached.
ur_template_t * m_template
void setSendAutoflushTimeout(int timeout)
Sets the autoflush timeout for the output Trap interface.
~UnirecBidirectionalInterface()
Destructor for the UnirecBidirectionalInterface class.
bool handleSendErrorCodes(int errorCode) const
void handleReceiveErrorCodes(int errorCode) const
void sendFlush() const
Flushes any pending UniRec records in the Trap interface.
void changeTemplate()
Changes the Unirec template used by the bidirectional interface.
void changeInternalTemplate(const std::string &templateSpecification)
InputInteraceStats getInputInterfaceStats() const
Gets the statistics for the input interface.
void setReceiveTimeout(int timeout)
Sets the receive timeout for the interface. This method sets the timeout for receiving UniRec records...
const void * m_prioritizedDataPointer
UnirecRecord createUnirecRecord(size_t maxVariableFieldsSize=UR_MAX_SIZE)
Creates a new UniRec record with the specified maximum variable fields size.
UnirecRecord m_unirecRecord
void doNotsendEoFOnExit()
Disables sending an end-of-file marker on exit.
void setSendTimeout(int timeout)
Sets the send timeout for the Trap interface.
uint8_t m_inputInterfaceID
uint8_t m_outputInterfaceID
std::optional< UnirecRecordView > receive()
Receives data from the interface and returns an optional UnirecRecordView object.
void setRequieredFormat(const std::string &templateSpecification)
Sets the required Unirec format specification.
uint64_t m_sequenceNumber
bool send(UnirecRecord &unirecRecord) const
Sends a UniRec record through the Trap interface.
UnirecBidirectionalInterface(uint8_t inputInterfaceID, uint8_t outputInterfaceID)
Provides a view into a UniRec record.
A class for working with UniRec records and their fields.
ur_template_t * ur_define_fields_and_update_template(const char *ifc_data_fmt, ur_template_t *tmplt)
Defined new fields and expand an UniRec template Define new fields (function ur_define_set_of_fields)...
#define ur_set_output_template(ifc, tmplt)
Set UniRec template to ouput interface.
void ur_free_template(ur_template_t *tmplt)
Destroy UniRec template Free all memory allocated for a template created previously by ur_create_temp...
#define ur_set_input_template(ifc, tmplt)
Set UniRec template to input interface.
constexpr ur_field_type_t getExpectedUnirecType()
Determines the expected UniRec field type for a given C++ type T.