summaryrefslogtreecommitdiff
path: root/DecoderOutputFramer.hpp
blob: ef0202261b39e39b40d4546326772f850e6a3d66 (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
#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
  {
    Started,
    Record,
    Finished,
    Malformed
  };

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

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

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

private:
  qint32 generation_ {0};
};

#endif