ngscopeclient v0.1-rc1
FlowGraphNode.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
36#ifndef FlowGraphNode_h
37#define FlowGraphNode_h
38
40class WaveformBase;
42
43#include "FilterParameter.h"
44#include "Waveform.h"
45#include "Stream.h"
46#include "SerializableObject.h"
47
55{
56public:
58 virtual ~FlowGraphNode();
59
60 void DetachInputs();
61
62 //Inputs
63public:
64 size_t GetInputCount();
65 std::string GetInputName(size_t i);
66
67 void SetInput(size_t i, StreamDescriptor stream, bool force = false);
68 void SetInput(const std::string& name, StreamDescriptor stream, bool force = false);
69 virtual bool ValidateChannel(size_t i, StreamDescriptor stream);
70
71 StreamDescriptor GetInput(size_t i);
72
73protected:
74 virtual void OnInputChanged(size_t i);
75
76 //Parameters
77public:
78 FilterParameter& GetParameter(std::string s);
79
81 typedef std::map<std::string, FilterParameter> ParameterMapType;
82
90 bool HasParameter(std::string s)
91 { return (m_parameters.find(s) != m_parameters.end()); }
92
94 ParameterMapType::iterator GetParamBegin()
95 { return m_parameters.begin(); }
96
98 ParameterMapType::iterator GetParamEnd()
99 { return m_parameters.end(); }
100
103 { return m_parameters.size(); }
104
110 virtual YAML::Node SerializeConfiguration(IDTable& table);
111
115 virtual void LoadParameters(const YAML::Node& node, IDTable& table);
116 virtual void LoadInputs(const YAML::Node& node, IDTable& table);
117
118 bool IsDownstreamOf(std::set<FlowGraphNode*> nodes);
119
121 // Accelerated waveform accessors
122
123 enum DataLocation
124 {
125 LOC_CPU,
126 LOC_GPU,
127 LOC_DONTCARE
128 };
129
130 virtual DataLocation GetInputLocation();
131
133 // Filter evaluation
134 [[deprecated]]
135 virtual void Refresh();
136
137 //Filter evaluation (GPU accelerated)
138 virtual void Refresh(vk::raii::CommandBuffer& cmdBuf, std::shared_ptr<QueueHandle> queue);
139
140 //Input handling helpers
141protected:
142
148 WaveformBase* GetInputWaveform(size_t i); //implementation in FlowGraphNode_inlines.h
149
152 { return dynamic_cast<SparseAnalogWaveform*>(GetInputWaveform(i)); }
153
156 { return dynamic_cast<UniformAnalogWaveform*>(GetInputWaveform(i)); }
157
160 { return dynamic_cast<SparseDigitalWaveform*>(GetInputWaveform(i)); }
161
164 { return dynamic_cast<UniformDigitalWaveform*>(GetInputWaveform(i)); }
165
168 { return dynamic_cast<SparseDigitalBusWaveform*>(GetInputWaveform(i)); }
169
170 void CreateInput(const std::string& name);
171
172 std::string GetInputDisplayName(size_t i);
173
174protected:
176 std::vector<std::string> m_signalNames;
177
179 std::vector<StreamDescriptor> m_inputs;
180
181 //Parameters
182 ParameterMapType m_parameters;
183
184public:
185
186 sigc::signal<void()> signal_parametersChanged()
187 { return m_parametersChangedSignal; }
188
189 sigc::signal<void()> signal_inputsChanged()
190 { return m_inputsChangedSignal; }
191
192protected:
193
195 sigc::signal<void()> m_parametersChangedSignal;
196
198 sigc::signal<void()> m_inputsChangedSignal;
199};
200
201#endif
Declaration of FilterParameter.
Declaration of SerializableObject.
Declaration of Stream.
Declaration of WaveformBase, SparseWaveformBase, UniformWaveformBase.
A parameter to a filter.
Definition: FilterParameter.h:86
Abstract base class for a node in the signal flow graph.
Definition: FlowGraphNode.h:55
void CreateInput(const std::string &name)
Creates and names an input signal.
Definition: FlowGraphNode.cpp:279
StreamDescriptor GetInput(size_t i)
Gets the descriptor for one of our inputs.
Definition: FlowGraphNode.cpp:249
bool HasParameter(std::string s)
Checks if we have a parameter with a given name.
Definition: FlowGraphNode.h:90
ParameterMapType::iterator GetParamEnd()
Returns an iterator to the end of our parameter map.
Definition: FlowGraphNode.h:98
ParameterMapType::iterator GetParamBegin()
Returns an iterator to the beginning of our parameter map.
Definition: FlowGraphNode.h:94
virtual YAML::Node SerializeConfiguration(IDTable &table)
Serializes this trigger's configuration to a YAML string.
Definition: FlowGraphNode.cpp:317
std::vector< StreamDescriptor > m_inputs
The channel (if any) connected to each of our inputs.
Definition: FlowGraphNode.h:179
sigc::signal< void()> m_parametersChangedSignal
Signal emitted when the set of parameters changes.
Definition: FlowGraphNode.h:195
SparseAnalogWaveform * GetSparseAnalogInputWaveform(size_t i)
Gets the analog waveform attached to the specified input.
Definition: FlowGraphNode.h:151
size_t GetParamCount()
Returns the number of parameter we have.
Definition: FlowGraphNode.h:102
SparseDigitalWaveform * GetSparseDigitalInputWaveform(size_t i)
Gets the digital waveform attached to the specified input.
Definition: FlowGraphNode.h:159
std::string GetInputDisplayName(size_t i)
Gets the display name for one of our inputs.
Definition: FlowGraphNode.cpp:265
WaveformBase * GetInputWaveform(size_t i)
Gets the waveform attached to the specified input.
Definition: FlowGraphNode_inlines.h:51
bool IsDownstreamOf(std::set< FlowGraphNode * > nodes)
Determines if this node is downstream of any of the specified other nodes.
Definition: FlowGraphNode.cpp:298
sigc::signal< void()> m_inputsChangedSignal
Signal emitted when the set of inputs changes.
Definition: FlowGraphNode.h:198
std::map< std::string, FilterParameter > ParameterMapType
Short name for a map of strings to parameters.
Definition: FlowGraphNode.h:81
std::vector< std::string > m_signalNames
Names of signals we take as input.
Definition: FlowGraphNode.h:176
UniformAnalogWaveform * GetUniformAnalogInputWaveform(size_t i)
Gets the analog waveform attached to the specified input.
Definition: FlowGraphNode.h:155
virtual void Refresh()
Evaluates a filter graph node.
Definition: FlowGraphNode.cpp:87
virtual void OnInputChanged(size_t i)
Called when a new input is connected to the node.
Definition: FlowGraphNode.cpp:149
void SetInput(size_t i, StreamDescriptor stream, bool force=false)
Connects a stream to the input of this node.
Definition: FlowGraphNode.cpp:161
virtual DataLocation GetInputLocation()
Gets the desired location of the nodes's input data.
Definition: FlowGraphNode.cpp:110
SparseDigitalBusWaveform * GetSparseDigitalBusInputWaveform(size_t i)
Gets the digital bus waveform attached to the specified input.
Definition: FlowGraphNode.h:167
UniformDigitalWaveform * GetUniformDigitalInputWaveform(size_t i)
Gets the digital waveform attached to the specified input.
Definition: FlowGraphNode.h:163
void DetachInputs()
Disconnects all inputs from the node without releasing them.
Definition: FlowGraphNode.cpp:72
virtual void LoadParameters(const YAML::Node &node, IDTable &table)
Load configuration from a save file.
Definition: FlowGraphNode.cpp:350
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition: IDTable.h:51
A single channel on an oscilloscope.
Definition: OscilloscopeChannel.h:49
Definition: SerializableObject.h:40
A waveform sampled at irregular intervals.
Definition: Waveform.h:469
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
A waveform sampled at uniform intervals.
Definition: Waveform.h:371
Base class for all Waveform specializations.
Definition: Waveform.h:59