DSPatch  v.5.01
Component.h
1 /************************************************************************
2 DSPatch - The C++ Flow-Based Programming Framework
3 Copyright (c) 2012-2018 Marcus Tomlinson
4 
5 This file is part of DSPatch.
6 
7 GNU Lesser General Public License Usage
8 This file may be used under the terms of the GNU Lesser General Public
9 License version 3.0 as published by the Free Software Foundation and
10 appearing in the file LICENSE included in the packaging of this file.
11 Please review the following information to ensure the GNU Lesser
12 General Public License version 3.0 requirements will be met:
13 http://www.gnu.org/copyleft/lgpl.html.
14 
15 Other Usage
16 Alternatively, this file may be used in accordance with the terms and
17 conditions contained in a signed written agreement between you and
18 Marcus Tomlinson.
19 
20 DSPatch is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 ************************************************************************/
24 
25 #pragma once
26 
27 #include <dspatch/SignalBus.h>
28 
29 #include <string>
30 
31 namespace DSPatch
32 {
33 
34 namespace internal
35 {
36 class Component;
37 } // namespace internal
38 
40 
63 class DLLEXPORT Component
64 {
65 public:
66  NONCOPYABLE( Component );
67  DEFINE_PTRS( Component );
68 
69  enum class ProcessOrder
70  {
71  InOrder,
72  OutOfOrder
73  };
74 
75  Component( ProcessOrder processOrder = ProcessOrder::InOrder );
76  virtual ~Component();
77 
78  bool ConnectInput( Component::SPtr const& fromComponent, int fromOutput, int toInput );
79 
80  void DisconnectInput( int inputNo );
81  void DisconnectInput( Component::SCPtr const& fromComponent );
82  void DisconnectAllInputs();
83 
84  int GetInputCount() const;
85  int GetOutputCount() const;
86 
87  std::string GetInputName( int inputNo ) const;
88  std::string GetOutputName( int outputNo ) const;
89 
90  void SetBufferCount( int bufferCount );
91  int GetBufferCount() const;
92 
93  void Tick( int bufferNo = 0 );
94  void Reset( int bufferNo = 0 );
95 
96 protected:
97  virtual void Process_( SignalBus const&, SignalBus& ) = 0;
98 
99  void SetInputCount_( int inputCount, std::vector<std::string> const& inputNames = {} );
100  void SetOutputCount_( int outputCount, std::vector<std::string> const& outputNames = {} );
101 
102 private:
103  std::unique_ptr<internal::Component> p;
104 };
105 
106 } // namespace DSPatch
Abstract base class for DSPatch components.
Definition: Component.h:63
Signal container.
Definition: SignalBus.h:48