summaryrefslogtreecommitdiff
path: root/DecoderOutputFramer.hpp
blob: 3b520afd9905e6c2a1d0ba65b2a2932debc68ff2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef DECODER_OUTPUT_FRAMER_HPP
#define DECODER_OUTPUT_FRAMER_HPP

#include <functional>

#include <QByteArray>

#include "DecoderIpc.hpp"

class QIODevice;

class DecoderOutputFramer
{
public:
  enum class EventType
  {
    Ready,
    Error,
    Started,
    Rejected,
    Record,
    Finished,
    Malformed
  };

  struct Event
  {
    EventType type;
    qint32 generation;
    QByteArray rawLine;
    DecoderIpc::Completion completion;
    qint32 protocolVersion {0};
    QByteArray errorStatus {};
  };

  using EventHandler = std::function<void (Event const&)>;

  void drain (QIODevice& device, EventHandler const& handler);
  void reset ();
  qint32 currentGeneration () const;

private:
  qint32 generation_ {0};
};

#endif