connectIO method
- Module module,
- Interface srcInterface, {
- Iterable<
PairDirection> ? inputTags, - Iterable<
PairDirection> ? outputTags, - Iterable<
PairDirection> ? inOutTags, - String uniquify(
- String original
override
Calls Interface.connectIO for ports of this interface as well as hierarchically for all subInterfaces.
Implementation
@override
void connectIO(
Module module,
Interface<dynamic> srcInterface, {
Iterable<PairDirection>? inputTags,
Iterable<PairDirection>? outputTags,
Iterable<PairDirection>? inOutTags,
String Function(String original)? uniquify,
}) {
final inputTagSet = inputTags?.toSet();
final outputTagSet = outputTags?.toSet();
final inOutTagSet = inOutTags?.toSet();
final input = inputTagSet?.contains(PairDirection.fromProvider) ?? false;
final output = outputTagSet?.contains(PairDirection.fromProvider) ?? false;
if ((input || output) &&
(inOutTagSet?.contains(PairDirection.fromProvider) ?? false)) {
throw PortTypeException.forIntendedName(
data.name, 'Ready-only provider ports cannot also be inOut ports.');
}
if (input || output) {
final source = srcInterface.port(data.name);
if (!rohdPayloadsCompatible([data, source], ignoreConstantNames: true)) {
throw PortTypeException.forIntendedName(
data.name, 'Ready-only payload shape does not match.');
}
final name = uniquify?.call(data.name) ?? data.name;
if (input) {
final bridge = data.cloneTyped(name: '${data.name}_input_bridge')
..gets(source);
data <= module.addTypedInput(name, bridge);
}
if (output) {
final registered = addTypedPayloadOutput(module, name, data);
registered <= data;
source <= registered;
}
}
_suppressPayload = input || output;
try {
super.connectIO(module, srcInterface,
inputTags: inputTagSet,
outputTags: outputTagSet,
inOutTags: inOutTagSet,
uniquify: uniquify);
} finally {
_suppressPayload = false;
}
}