25 #ifndef DSPCOMPONENT_H
26 #define DSPCOMPONENT_H
30 #include "DspSignalBus.h"
31 #include "DspWireBus.h"
32 #include "DspComponentThread.h"
67 void SetComponentName( std::string componentName );
68 std::string GetComponentName()
const;
70 void SetParentCircuit(
DspCircuit* parentCircuit );
73 template<
class FromOutputType,
class ToInputType >
74 bool ConnectInput(
DspComponent* fromComponent, FromOutputType fromOutput, ToInputType toInput );
76 template<
class FromOutputType,
class ToInputType >
77 bool ConnectInput(
DspComponent& fromComponent, FromOutputType fromOutput, ToInputType toInput );
79 template<
class FromOutputType,
class ToInputType >
80 void DisconnectInput(
DspComponent* fromComponent, FromOutputType fromOutput, ToInputType toInput );
82 template<
class FromOutputType,
class ToInputType >
83 void DisconnectInput(
DspComponent& fromComponent, FromOutputType fromOutput, ToInputType toInput );
85 void DisconnectInput(
unsigned short inputIndex );
86 void DisconnectInput( std::string inputName );
88 void DisconnectInputs();
90 unsigned short GetInputCount()
const;
91 unsigned short GetOutputCount()
const;
93 bool FindInput( std::string signalName,
unsigned short& returnIndex )
const;
94 bool FindInput(
unsigned short signalIndex,
unsigned short& returnIndex )
const;
95 bool FindOutput( std::string signalName,
unsigned short& returnIndex )
const;
96 bool FindOutput(
unsigned short signalIndex,
unsigned short& returnIndex )
const;
101 virtual void StartAutoTick();
102 virtual void StopAutoTick();
103 virtual void PauseAutoTick();
104 virtual void ResumeAutoTick();
109 void SetBufferCount(
unsigned short bufferCount );
110 unsigned short GetBufferCount()
const;
112 void ThreadTick(
unsigned short threadNo );
113 void ThreadReset(
unsigned short threadNo );
115 bool SetInputSignal(
unsigned short inputIndex,
const DspSignal* newSignal );
116 bool SetInputSignal(
unsigned short inputIndex,
unsigned short threadIndex,
const DspSignal* newSignal );
117 DspSignal* GetOutputSignal(
unsigned short outputIndex );
118 DspSignal* GetOutputSignal(
unsigned short outputIndex,
unsigned short threadIndex );
123 bool AddInput_( std::string inputName =
"" );
124 bool AddOutput_( std::string outputName =
"" );
127 void ClearOutputs_();
132 unsigned short _bufferCount;
137 std::vector< DspSignalBus > _inputBuses;
138 std::vector< DspSignalBus > _outputBuses;
140 std::string _componentName;
141 bool _isAutoTickRunning;
142 bool _isAutoTickPaused;
150 std::vector< bool* > _hasTickeds;
151 std::vector< bool > _gotReleases;
152 std::vector< DspMutex > _releaseMutexes;
153 std::vector< DspWaitCondition > _releaseCondts;
155 void _WaitForRelease(
unsigned short threadNo );
156 void _ReleaseThread(
unsigned short threadNo );
161 template<
class FromOutputType,
class ToInputType >
162 bool DspComponent::ConnectInput(
DspComponent* fromComponent, FromOutputType fromOutput, ToInputType toInput )
164 unsigned short fromOutputIndex;
165 unsigned short toInputIndex;
167 if( !fromComponent->_outputBus.FindSignal( fromOutput, fromOutputIndex ) ||
168 !_inputBus.FindSignal( toInput, toInputIndex ) )
174 _inputWires.AddWire( fromComponent, fromOutputIndex, toInputIndex );
182 template<
class FromOutputType,
class ToInputType >
183 bool DspComponent::ConnectInput(
DspComponent& fromComponent, FromOutputType fromOutput, ToInputType toInput )
185 return ConnectInput( &fromComponent, fromOutput, toInput );
190 template<
class FromOutputType,
class ToInputType >
191 void DspComponent::DisconnectInput(
DspComponent* fromComponent, FromOutputType fromOutput, ToInputType toInput )
193 unsigned short fromOutputIndex;
194 unsigned short toInputIndex;
196 if( !fromComponent->_outputBus.FindSignal( fromOutput, fromOutputIndex ) ||
197 !_inputBus.FindSignal( toInput, toInputIndex ) )
203 _inputWires.RemoveWire( fromComponent, fromOutputIndex, toInputIndex );
209 template<
class FromOutputType,
class ToInputType >
210 void DspComponent::DisconnectInput(
DspComponent& fromComponent, FromOutputType fromOutput, ToInputType toInput )
212 DisconnectInput( &fromComponent, fromOutput, toInput );
217 #endif // DSPCOMPONENT_H