UniRec  3.0.0
outputInterface.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "unirecRecord.hpp"
15 #include "unirecRecordView.hpp"
16 
17 #include <string>
18 #include <unirec/unirec.h>
19 
20 namespace NemeaPlusPlus {
25 public:
33  bool send(UnirecRecord& unirecRecord) const;
34 
42  bool send(UnirecRecordView& unirecRecordView) const;
43 
47  void sendFlush() const;
48 
59  void setTimeout(int timeout);
60 
67  void setAutoflushTimeout(int timeout);
68 
77  void changeTemplate(const std::string& templateFields = "");
78 
82  void doNotsendEoFOnExit();
83 
91  ur_template_t* getTemplate() const noexcept { return m_template; }
92 
100 
117 
130  UnirecRecord createUnirecRecord(size_t maxVariableFieldsSize = UR_MAX_SIZE);
131 
132 private:
133  UnirecOutputInterface(uint8_t interfaceID);
134  bool handleSendErrorCodes(int errorCode) const;
135  void sendEoF() const;
136 
138  uint8_t m_interfaceID;
141 
142  friend class Unirec;
143 };
144 
145 } // namespace NemeaPlusPlus
A class for sending UniRec records through a Trap interface.
UnirecRecord & getUnirecRecord() noexcept
Gets a reference to the pre-allocated UniRec record for efficient use.
void changeTemplate(const std::string &templateFields="")
Changes the UniRec template for the Trap interface.
bool send(UnirecRecord &unirecRecord) const
Sends a UniRec record through the Trap interface.
bool handleSendErrorCodes(int errorCode) const
UnirecOutputInterface(uint8_t interfaceID)
UnirecRecord createUnirecRecord(size_t maxVariableFieldsSize=UR_MAX_SIZE)
Creates a new UniRec record with the specified maximum variable fields size.
void setTimeout(int timeout)
Sets the send timeout for the Trap interface.
void sendFlush() const
Flushes any pending UniRec records in the Trap interface.
void setAutoflushTimeout(int timeout)
Sets the autoflush timeout for the Trap interface.
~UnirecOutputInterface()
Destructor for the UnirecOutputInterface class.
ur_template_t * getTemplate() const noexcept
Gets the Unirec template used by the output interface.
void doNotsendEoFOnExit()
Disables sending an end-of-file marker on exit.
Provides a view into a UniRec record.
A class for working with UniRec records and their fields.
#define UR_MAX_SIZE
Definition: unirec.h:1013
Provides a view into a UniRec record.
Defines the UnirecRecord class.
Definition of UniRec structures and functions.
UniRec template. It contains a table mapping a field to its position in an UniRec record.
Definition: unirec.h:191