UniRec  3.2.0
inputInterface.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "interfaceStats.hpp"
12 #include "unirecException.hpp"
13 #include "unirecRecordView.hpp"
14 
15 #include <optional>
16 #include <string>
17 #include <unirec/unirec.h>
18 
19 namespace Nemea {
20 
26 public:
38  std::optional<UnirecRecordView> receive();
39 
51  void changeTemplate();
52 
62  void setRequieredFormat(const std::string& templateSpecification);
63 
75  void setTimeout(int timeout);
76 
82 
90  ur_template_t* getTemplate() const noexcept { return m_template; }
91 
100 
101 private:
102  UnirecInputInterface(uint8_t interfaceID);
103  void handleReceiveErrorCodes(int errorCode) const;
104  void changeInternalTemplate(const std::string& templateSpecification);
105 
107  uint8_t m_interfaceID;
110 
111  friend class Unirec;
112 };
113 
114 } // namespace Nemea
A class that provides an interface for receiving data in the Unirec format using the TRAP library.
UnirecInputInterface(uint8_t interfaceID)
void handleReceiveErrorCodes(int errorCode) const
void setRequieredFormat(const std::string &templateSpecification)
Sets the required Unirec format specification.
void changeTemplate()
Changes the Unirec template used by the input interface.
InputInteraceStats getInputInterfaceStats() const
Gets the statistics for the input interface.
void setTimeout(int timeout)
Sets the receive timeout for the interface. This method sets the timeout for receiving UniRec records...
~UnirecInputInterface()
Destructor for UnirecInputInterface class. This method frees the memory used by the Unirec template.
ur_template_t * getTemplate() const noexcept
Gets the Unirec template used by the input interface.
std::optional< UnirecRecordView > receive()
Receives data from the interface and returns an optional UnirecRecordView object.
void changeInternalTemplate(const std::string &templateSpecification)
This file contains the declarations of the interface stats structure.
Structure to store statistics related to an input interface.
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