DSPatch  v.7.0.1
Circuit.h
1 /******************************************************************************
2 DSPatch - The Refreshingly Simple C++ Dataflow Framework
3 Copyright (c) 2020, Marcus Tomlinson
4 
5 BSD 2-Clause License
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice, this
11  list of conditions and the following disclaimer.
12 
13 2. 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 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ******************************************************************************/
28 
29 #pragma once
30 
31 #include <dspatch/Component.h>
32 
33 namespace DSPatch
34 {
35 
36 namespace internal
37 {
38 class Circuit;
39 }
40 
42 
65 class DLLEXPORT Circuit final
66 {
67 public:
68  NONCOPYABLE( Circuit );
69  DEFINE_PTRS( Circuit );
70 
71  Circuit();
72  ~Circuit();
73 
74  int AddComponent( Component::SPtr const& component );
75 
76  void RemoveComponent( Component::SCPtr const& component );
77  void RemoveComponent( int componentIndex );
78  void RemoveAllComponents();
79 
80  int GetComponentCount() const;
81 
82  bool ConnectOutToIn( Component::SCPtr const& fromComponent, int fromOutput, Component::SCPtr const& toComponent, int toInput );
83  bool ConnectOutToIn( Component::SCPtr const& fromComponent, int fromOutput, int toComponent, int toInput );
84  bool ConnectOutToIn( int fromComponent, int fromOutput, Component::SCPtr const& toComponent, int toInput );
85  bool ConnectOutToIn( int fromComponent, int fromOutput, int toComponent, int toInput );
86 
87  void DisconnectComponent( Component::SCPtr const& component );
88  void DisconnectComponent( int componentIndex );
89 
90  void SetBufferCount( int bufferCount );
91  int GetBufferCount() const;
92 
93  void Tick( Component::TickMode mode = Component::TickMode::Parallel );
94 
95  void StartAutoTick( Component::TickMode mode = Component::TickMode::Parallel );
96  void StopAutoTick();
97  void PauseAutoTick();
98  void ResumeAutoTick();
99 
100 private:
101  std::unique_ptr<internal::Circuit> p;
102 };
103 
104 } // namespace DSPatch