9 #include <libtrap/trap.h> 18 , m_interfaceID(interfaceID)
19 , m_sendEoFonExit(true)
20 , m_isInitialized(false)
47 if (errorCode == TRAP_E_TIMEOUT) {
50 if (errorCode == TRAP_E_OK) {
53 if (errorCode == TRAP_E_NOT_INITIALIZED) {
54 throw std::runtime_error(
55 "UnirecOutputInterface::send() has failed. Trap interface is not initialized.");
57 if (errorCode == TRAP_E_TERMINATED) {
58 throw std::runtime_error(
59 "UnirecOutputInterface::send() has failed. Trap interface is terminated.");
61 if (errorCode == TRAP_E_BAD_IFC_INDEX) {
62 throw std::runtime_error(
63 "UnirecOutputInterface::send() has failed. Interface ID out of range.");
65 throw std::runtime_error(
66 "UnirecOutputInterface::send() has failed. Return code: " + std::to_string(errorCode)
67 +
", msg: " + trap_last_error_msg);
82 trap_ifcctl(TRAPIFC_OUTPUT,
m_interfaceID, TRAPCTL_SETTIMEOUT, timeout);
87 trap_ifcctl(TRAPIFC_OUTPUT,
m_interfaceID, TRAPCTL_AUTOFLUSH_TIMEOUT, timeout);
92 char dummy[1] = { 0 };
99 throw std::runtime_error(
100 "UnirecOutputInterface::changeTemplate() has failed. Template fields could not be " 104 std::unique_ptr<char*> fieldNames
108 throw std::runtime_error(
109 "UnirecOutputInterface::changeTemplate() has failed. Field specs could not be " 115 throw std::runtime_error(
116 "UnirecOutputInterface::changeTemplate() has failed. Output template could not be " ~UnirecOutputInterface()
Destructor for the UnirecOutputInterface class.
int ur_define_set_of_fields(const char *ifc_data_fmt)
Define set of new UniRec fields Define new UniRec fields at run-time. It adds new fields into existin...
void sendFlush() const
Flushes any pending UniRec records in the Trap interface.
UnirecRecord m_unirecRecord
#define ur_create_output_template(ifc, fields, errstr)
Create UniRec template and set it to output interface Creates UniRec template (same like ur_create_te...
UnirecRecord createUnirecRecord(size_t maxVariableFieldsSize=UR_MAX_SIZE)
Creates a new UniRec record with the specified maximum variable fields size.
A class for working with UniRec records and their fields.
void changeTemplate(const std::string &templateFields="")
Changes the UniRec template for the Trap interface.
UnirecOutputInterface(uint8_t interfaceID)
void setAutoflushTimeout(int timeout)
Sets the autoflush timeout for the Trap interface.
bool handleSendErrorCodes(int errorCode) const
Defines the UnirecOutputInterface class.
const void * data() const noexcept
Returns a pointer to the data of the UniRec record.
void ur_free_template(ur_template_t *tmplt)
Destroy UniRec template Free all memory allocated for a template created previously by ur_create_temp...
bool send(UnirecRecord &unirecRecord) const
Sends a UniRec record through the Trap interface.
size_t size() const noexcept
Returns the size of the UniRec record.
const void * data() const noexcept
Returns a const pointer to the data of the UniRec record.
char * ur_ifc_data_fmt_to_field_names(const char *ifc_data_fmt)
Parses field names from data format Function parses field names from data format and returns pointer ...
void doNotsendEoFOnExit()
Disables sending an end-of-file marker on exit.
Provides a view into a UniRec record.
ur_template_t * m_template
size_t size() const noexcept
Returns the size of the UniRec record.
void setTimeout(int timeout)
Sets the send timeout for the Trap interface.