DSPatch v.10.2.3
Loading...
Searching...
No Matches
Component.h
1/******************************************************************************
2DSPatch - The Refreshingly Simple C++ Dataflow Framework
3Copyright (c) 2024, Marcus Tomlinson
4
5BSD 2-Clause License
6
7Redistribution and use in source and binary forms, with or without
8modification, are permitted provided that the following conditions are met:
9
101. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27******************************************************************************/
28
29#pragma once
30
31#include <dspatch/SignalBus.h>
32
33#include <string>
34#include <vector>
35
36namespace DSPatch
37{
38
39namespace internal
40{
41class Circuit;
42class Component;
43class ParallelCircuitThread;
44} // namespace internal
45
47
68class DLLEXPORT Component
69{
70public:
71 NONCOPYABLE( Component );
72
73 using SPtr = std::shared_ptr<Component>;
74
75 enum class ProcessOrder
76 {
77 InOrder,
78 OutOfOrder
79 };
80
81 Component( ProcessOrder processOrder = ProcessOrder::InOrder );
82 virtual ~Component();
83
84 bool ConnectInput( const Component::SPtr& fromComponent, int fromOutput, int toInput );
85
86 void DisconnectInput( int inputNo );
87 void DisconnectInput( const Component::SPtr& fromComponent );
88 void DisconnectAllInputs();
89
90 int GetInputCount() const;
91 int GetOutputCount() const;
92
93 std::string GetInputName( int inputNo ) const;
94 std::string GetOutputName( int outputNo ) const;
95
96 void SetBufferCount( int bufferCount, int startBuffer );
97 int GetBufferCount() const;
98
99 void TickSeries( int bufferNo );
100 void TickParallel( int bufferNo );
101
102 void ScanSeries( std::vector<Component*>& components );
103 void ScanParallel( std::vector<std::vector<DSPatch::Component*>>& componentsMap, int& scanPosition );
104 void EndScan();
105
106protected:
107 virtual void Process_( SignalBus&, SignalBus& ) = 0;
108
109 void SetInputCount_( int inputCount, const std::vector<std::string>& inputNames = {} );
110 void SetOutputCount_( int outputCount, const std::vector<std::string>& outputNames = {} );
111
112private:
113 internal::Component* p;
114};
115
116} // namespace DSPatch
Abstract base class for DSPatch components.
Definition Component.h:69
Signal container.
Definition SignalBus.h:55