MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Core::SerialReader Class Reference

One reading of a byte stream: the spec's framing and parsing, to values. More...

#include <SerialReader.hpp>

Collaboration diagram for MayaFlux::Core::SerialReader:

Classes

struct  MidiStream

Public Types

using FrameFilter = std::function<bool(Transitive::Protocol::Message message)>
using ValueCallback = std::function<void(const InputValue&)>

Public Member Functions

uint32_t id () const
SerialReader & operator= (const SerialReader &)=delete
SerialReader & operator= (SerialReader &&)=delete
void push (std::span< const uint8_t > chunk)
void reset ()
 Drop the partial message, the running MIDI status and a pending gap.
 SerialReader (const SerialReader &)=delete
 SerialReader (SerialReader &&)=delete
 SerialReader (uint32_t id, SerialSpec spec, ISerialLink &link)
void set_frame_filter (FrameFilter filter)
void set_value_callback (ValueCallback callback)
const SerialSpec & spec () const
SerialReaderStats stats () const
 ~SerialReader ()

Private Types

using Framer

Private Member Functions

void arm_gap ()
void cancel_gap ()
void deliver (std::optional< InputValue > value)
void handle_frame (Transitive::Protocol::Message frame)
void handle_gap ()
void parse_midi (std::span< const uint8_t > chunk)

Static Private Member Functions

static Framer make_framer (const SerialSpec &spec)

Private Attributes

std::atomic< uint64_t > m_dropped { 0 }
FrameFilter m_filter
Framer m_framer
std::atomic< uint64_t > m_frames { 0 }
std::atomic< ISerialLink::TimerToken > m_gap_timer { 0 }
uint32_t m_id
ISerialLink & m_link
MidiStream m_midi
ValueCallback m_on_value
SerialSpec m_spec
std::atomic< uint64_t > m_unparsed { 0 }

Detailed Description

One reading of a byte stream: the spec's framing and parsing, to values.

Bytes pushed in are cut into messages by the spec's framing and each message becomes an InputValue through its parser, stamped with the id and InputType::SERIAL and handed to the value callback. A frame filter sees each message first and a message it accepts is not parsed. Several readers over the same bytes read them independently.

The link is used only for the timer of an idle gap framing and must outlive the reader. push() and reset() belong to one thread, the link's.

Definition at line 33 of file SerialReader.hpp.


The documentation for this class was generated from the following files: