direction property

  1. @override
PortDirection get direction
override

The effective direction of this port based on interface role and port tags.

This resolves the actual port direction by considering:

  • The interface role (provider or consumer)
  • The port's direction tags (fromProvider, fromConsumer, etc.)

For example, a port tagged as PairDirection.fromProvider will be an output when the interface role is PairRole.provider, but an input when the role is PairRole.consumer.

Implementation

@override
PortDirection get direction {
  if (_isSharedInput) {
    return PortDirection.input;
  }

  if (_isFromCommonInOut) {
    return PortDirection.inOut;
  }

  if (interfaceReference.role == PairRole.provider) {
    if (_isFromProvider) {
      return PortDirection.output;
    } else if (_isFromConsumer) {
      return PortDirection.input;
    }
  } else if (interfaceReference.role == PairRole.consumer) {
    if (_isFromProvider) {
      return PortDirection.input;
    } else if (_isFromConsumer) {
      return PortDirection.output;
    }
  }

  throw RohdBridgeException('Port $this is directionless.');
}