DSPatch  v.6.01
Component.h
1 /************************************************************************
2 DSPatch - The Refreshingly Simple C++ Dataflow Framework
3 Copyright (c) 2012-2019 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  enum class TickMode
76  {
77  Series,
78  Parallel
79  };
80 
81  Component( ProcessOrder processOrder = ProcessOrder::InOrder );
82  virtual ~Component();
83 
84  bool ConnectInput( Component::SPtr const& fromComponent, int fromOutput, int toInput );
85 
86  void DisconnectInput( int inputNo );
87  void DisconnectInput( Component::SCPtr const& 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 );
97  int GetBufferCount() const;
98 
99  bool Tick( TickMode mode = TickMode::Parallel, int bufferNo = 0 );
100  void Reset( int bufferNo = 0 );
101 
102 protected:
103  virtual void Process_( SignalBus const&, SignalBus& ) = 0;
104 
105  void SetInputCount_( int inputCount, std::vector<std::string> const& inputNames = {} );
106  void SetOutputCount_( int outputCount, std::vector<std::string> const& outputNames = {} );
107 
108 private:
109  std::unique_ptr<internal::Component> p;
110 };
111 
112 } // namespace DSPatch
Abstract base class for DSPatch components.
Definition: Component.h:63
Signal container.
Definition: SignalBus.h:48