DSPatch v.9.7.5
Loading...
Searching...
No Matches
Component.h
1/******************************************************************************
2DSPatch - The Refreshingly Simple C++ Dataflow Framework
3Copyright (c) 2023, 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 Component;
42} // namespace internal
43
45
72class DLLEXPORT Component
73{
74public:
75 NONCOPYABLE( Component );
76
77 using SPtr = std::shared_ptr<Component>;
78
79 enum class ProcessOrder
80 {
81 InOrder,
82 OutOfOrder
83 };
84
85 Component( ProcessOrder processOrder = ProcessOrder::InOrder );
86 virtual ~Component();
87
88 bool ConnectInput( const Component::SPtr& fromComponent, int fromOutput, int toInput );
89
90 void DisconnectInput( int inputNo );
91 void DisconnectInput( const Component::SPtr& fromComponent );
92 void DisconnectAllInputs();
93
94 int GetInputCount() const;
95 int GetOutputCount() const;
96
97 std::string GetInputName( int inputNo ) const;
98 std::string GetOutputName( int outputNo ) const;
99
100 void SetBufferCount( int bufferCount, int startBuffer = 0 );
101 int GetBufferCount() const;
102
103 void Tick( int bufferNo = 0 );
104 void Reset( int bufferNo = 0 );
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:73
Signal container.
Definition SignalBus.h:57