UniRec  3.0.0
inputInterface.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "unirecException.hpp"
12 #include "unirecRecordView.hpp"
13 
14 #include <optional>
15 #include <string>
16 #include <unirec/unirec.h>
17 
18 namespace NemeaPlusPlus {
19 
25 public:
37  std::optional<UnirecRecordView> receive();
38 
50  void changeTemplate();
51 
61  void setRequieredFormat(const std::string& templateSpecification);
62 
74  void setTimeout(int timeout);
75 
81 
89  ur_template_t* getTemplate() const noexcept { return m_template; }
90 
91 private:
92  UnirecInputInterface(uint8_t interfaceID);
93  void handleReceiveErrorCodes(int errorCode) const;
94  bool isEoFReceived() const noexcept;
95 
97  uint8_t m_interfaceID;
100 
101  friend class Unirec;
102 };
103 
104 } // namespace NemeaPlusPlus
A class that provides an interface for receiving data in the Unirec format using the TRAP library.
void changeTemplate()
Changes the Unirec template used by the input interface.
void handleReceiveErrorCodes(int errorCode) const
void setTimeout(int timeout)
Sets the receive timeout for the interface. This method sets the timeout for receiving UniRec records...
ur_template_t * getTemplate() const noexcept
Gets the Unirec template used by the input interface.
UnirecInputInterface(uint8_t interfaceID)
void setRequieredFormat(const std::string &templateSpecification)
Sets the required Unirec format specification.
~UnirecInputInterface()
Destructor for UnirecInputInterface class. This method frees the memory used by the Unirec template.
std::optional< UnirecRecordView > receive()
Receives data from the interface and returns an optional UnirecRecordView object.
Defines custom exception classes.
Provides a view into a UniRec record.
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