punchDownTo method
Creates a copy of this interface in a submodule.
This "punches down" the interface from this module to subModule,
creating a new interface with the same role and automatically connecting
it to this interface.
The newIntfName parameter allows renaming the interface in the
submodule. If allowNameUniquification is true, automatic name collision
resolution will be applied if needed.
This operation is intended for passing interfaces down the module hierarchy.
The subModule must be a child of this interface's module.
Implementation
InterfaceReference punchDownTo(
BridgeModule subModule, {
String? newIntfName,
bool allowNameUniquification = false,
Set<String>? exceptPorts,
String Function(String logical)? portUniquify,
}) {
// TODO(mkorbel1): remove restriction that it must be adjacent (https://github.com/intel/rohd-bridge/issues/13)
if (subModule.parent != module) {
throw RohdBridgeException(
'The subModule must be a direct child of this module.');
}
_connectAllPortMaps(exceptPorts: exceptPorts);
final newRef = subModule.addInterface(
interface._cloneExcept(exceptPorts: exceptPorts),
name: newIntfName ?? name,
role: role,
allowNameUniquification: allowNameUniquification,
portUniquify: portUniquify,
);
connectDownTo(newRef, exceptPorts: exceptPorts);
return newRef;
}