connectIO method

  1. @override
void connectIO(
  1. Module module,
  2. Interface srcInterface, {
  3. Iterable<PairDirection>? inputTags,
  4. Iterable<PairDirection>? outputTags,
  5. Iterable<PairDirection>? inOutTags,
  6. String uniquify(
    1. String original
    )?,
})
inherited

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 selectedInputs = inputTags?.toSet();
  final selectedOutputs = outputTags?.toSet();
  final selectedInOuts = inOutTags?.toSet();
  final inputs = selectedInputs == null
      ? <String>{}
      : getPorts(selectedInputs).keys.toSet();
  final outputs = selectedOutputs == null
      ? <String>{}
      : getPorts(selectedOutputs).keys.toSet();
  final inOuts = selectedInOuts == null
      ? <String>{}
      : getPorts(selectedInOuts).keys.toSet();
  for (final payload in _payloads) {
    if (inOuts.contains(payload.name) &&
        (inputs.contains(payload.name) || outputs.contains(payload.name))) {
      throw PortTypeException.forIntendedName(payload.name,
          'Cache payload cannot be both directional and an inOut port.');
    }
  }
  final handled = <String>{};
  for (final payload in _payloads) {
    final isInput = inputs.contains(payload.name);
    final isOutput = outputs.contains(payload.name);
    if (!isInput && !isOutput) {
      continue;
    }
    final source = srcInterface.port(payload.name);
    if (!rohdPayloadsCompatible([payload, source])) {
      throw PortTypeException.forIntendedName(
          payload.name, 'Cache payload shape does not match.');
    }
    final name = uniquify?.call(payload.name) ?? payload.name;
    connectTypedPayloadPorts<T>(module,
        name: name,
        local: payload,
        source: source,
        input: isInput,
        output: isOutput);
    handled.add(payload.name);
  }
  _handledPayloads = handled;
  try {
    super.connectIO(module, srcInterface,
        inputTags: selectedInputs,
        outputTags: selectedOutputs,
        inOutTags: selectedInOuts,
        uniquify: uniquify);
  } finally {
    _handledPayloads = {};
  }
}