25 #include "DspWireBus.h"
26 #include "DspComponent.h"
31 DspWireBus::DspWireBus(
bool isLinkedComponentReceivingSignals )
32 : _isLinkedComponentReceivingSignals( isLinkedComponentReceivingSignals ) {}
36 DspWireBus::~DspWireBus()
43 bool DspWireBus::AddWire(
DspComponent* linkedComponent,
unsigned short fromSignalIndex,
unsigned short toSignalIndex )
45 for(
unsigned short i = 0; i < _wires.size(); i++ )
47 if( _wires[i].linkedComponent == linkedComponent &&
48 _wires[i].fromSignalIndex == fromSignalIndex &&
49 _wires[i].toSignalIndex == toSignalIndex )
55 for(
unsigned short i = 0; i < _wires.size(); i++ )
57 if( _isLinkedComponentReceivingSignals &&
58 _wires[i].linkedComponent == linkedComponent &&
59 _wires[i].toSignalIndex == toSignalIndex )
64 else if( !_isLinkedComponentReceivingSignals &&
65 _wires[i].toSignalIndex == toSignalIndex )
72 _wires.push_back(
DspWire( linkedComponent, fromSignalIndex, toSignalIndex ) );
79 bool DspWireBus::RemoveWire(
DspComponent* linkedComponent,
unsigned short fromSignalIndex,
unsigned short toSignalIndex )
81 for(
unsigned short i = 0; i < _wires.size(); i++ )
83 if( _wires[i].linkedComponent == linkedComponent &&
84 _wires[i].fromSignalIndex == fromSignalIndex &&
85 _wires[i].toSignalIndex == toSignalIndex )
97 bool DspWireBus::RemoveWire(
unsigned short wireIndex )
99 if( wireIndex > _wires.size() )
104 for(
unsigned short j = wireIndex; j < ( _wires.size() - 1 ); j++ )
106 _wires[j] = _wires[j + 1];
115 void DspWireBus::RemoveAllWires()
117 for(
unsigned short i = 0; i < _wires.size(); i++ )
125 DspWire* DspWireBus::GetWire(
unsigned short wireIndex )
127 if( wireIndex < _wires.size() )
129 return &_wires[wireIndex];
139 unsigned short DspWireBus::GetWireCount()
const
141 return _wires.size();