Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
value_channel_set.hpp
Go to the documentation of this file.
1#pragma once
2
34
35#include <cstddef>
36#include <cstdint>
37#include <functional>
38#include <memory>
39#include <string>
40#include <string_view>
41#include <vector>
42
44
45namespace pulp::dataplane {
46
47class ValueChannelSet;
48
52using ValueChannelVisitor = std::function<void(ValueChannelSet*)>;
53using ValueChannelAccess = std::function<void(const ValueChannelVisitor&)>;
54
62 public:
63 ValueChannelSet() = default;
68
72 std::uint64_t generation_identity() const noexcept;
73
83
86 ScalarSource* declare_scalar(std::string name, std::string unit = {}, float neutral = 0.0f,
87 DeclareError* error = nullptr);
89 MeterSource* declare_meter(std::string name, std::string unit = {}, float neutral = 0.0f,
90 DeclareError* error = nullptr);
92 VectorSource* declare_vector(std::string name, std::string unit = {}, float neutral = 0.0f,
93 DeclareError* error = nullptr);
95 EventSource* declare_events(std::string name, std::string unit = {},
96 DeclareError* error = nullptr);
97
101 ScalarSource* scalar(std::string_view name) const;
102 MeterSource* meter(std::string_view name) const;
103 VectorSource* vector(std::string_view name) const;
104 EventSource* events(std::string_view name) const;
105
108 const std::vector<ValueChannelInfo>& infos() const noexcept {
109 return infos_;
110 }
111
116
117 bool empty() const noexcept {
118 return infos_.empty();
119 }
120 std::size_t size() const noexcept {
121 return infos_.size();
122 }
123
125 static const char* describe(DeclareError e) noexcept;
126
127 private:
130 struct Entry {
131 std::shared_ptr<detail::ValueChannelTelemetryState> telemetry;
132 std::unique_ptr<ScalarSource> scalar;
133 std::unique_ptr<MeterSource> meter;
134 std::unique_ptr<VectorSource> vector;
135 std::unique_ptr<EventSource> events;
136 };
137
139 Entry* add_entry(std::string name, std::string unit, float neutral, ValueChannelShape shape,
140 DeclareError* error);
143 std::ptrdiff_t index_of(std::string_view name, ValueChannelShape shape) const;
144
148 std::vector<std::unique_ptr<Entry>> entries_;
149 std::vector<ValueChannelInfo> infos_;
150 // Keep the public object layout stable. The setup-only name index lives on
151 // this existing opaque control sidecar.
152 std::shared_ptr<detail::ValueChannelTelemetryControl> telemetry_control_;
153};
154
155} // namespace pulp::dataplane
Lock-free event channel: the writer publishes the occurrences from one audio block and the view reads...
Definition value_source.hpp:179
Lock-free meter channel: the host publishes a MeterFrame from the audio/host thread; the view reads t...
Definition value_source.hpp:80
Lock-free scalar channel: a single paint-safe cached number (a readout value, a modulation ring's bas...
Definition value_source.hpp:201
A processor's declared channels.
Definition value_channel_set.hpp:61
EventSource * events(std::string_view name) const
ValueChannelTelemetryAttachment attach_telemetry() const
Claim the transport-free telemetry sidecars.
ScalarSource * declare_scalar(std::string name, std::string unit={}, float neutral=0.0f, DeclareError *error=nullptr)
Declare a scalar channel.
VectorSource * declare_vector(std::string name, std::string unit={}, float neutral=0.0f, DeclareError *error=nullptr)
Declare a block channel for a scope-style display.
ValueChannelSet & operator=(const ValueChannelSet &)=delete
bool empty() const noexcept
Definition value_channel_set.hpp:117
std::size_t size() const noexcept
Definition value_channel_set.hpp:120
ValueChannelSet(ValueChannelSet &&)=delete
static const char * describe(DeclareError e) noexcept
Human-readable reason, for diagnostics and test failure messages.
std::uint64_t generation_identity() const noexcept
Process-local identity assigned with the first declaration in this exact set lifetime.
MeterSource * meter(std::string_view name) const
const std::vector< ValueChannelInfo > & infos() const noexcept
Every declared channel, in declaration order.
Definition value_channel_set.hpp:108
ValueChannelSet & operator=(ValueChannelSet &&)=delete
EventSource * declare_events(std::string name, std::string unit={}, DeclareError *error=nullptr)
Declare occurrences carrying frame offsets and values.
MeterSource * declare_meter(std::string name, std::string unit={}, float neutral=0.0f, DeclareError *error=nullptr)
Declare a multi-channel meter.
ScalarSource * scalar(std::string_view name) const
Look up a declared channel by its exact name.
VectorSource * vector(std::string_view name) const
DeclareError
Why a declaration was refused.
Definition value_channel_set.hpp:77
@ reserved_character
contains ':', reserved for the "value:" JS prefix
Definition value_channel_set.hpp:81
@ ok
Definition value_channel_set.hpp:78
@ duplicate_name
Definition value_channel_set.hpp:80
@ empty_name
Definition value_channel_set.hpp:79
ValueChannelSet(const ValueChannelSet &)=delete
Exclusive reader attachment for every telemetry sidecar in one channel set.
Definition value_channel_telemetry.hpp:88
Lock-free vector channel: the writer publishes a block of samples, the view reads the latest block pa...
Definition value_source.hpp:154
Transport-free fan-out for UI-consumed value-channel snapshots and ordered producer event batches.
Definition audio_bridge.hpp:9
std::function< void(ValueChannelSet *)> ValueChannelVisitor
Runs a value-channel operation while the hosting processor guarantees that the exposed set and all of...
Definition value_channel_set.hpp:52
std::function< void(const ValueChannelVisitor &)> ValueChannelAccess
Definition value_channel_set.hpp:53
ValueChannelShape
The shape of a channel's payload.
Definition value_channel_telemetry.hpp:21