getReferencingInstances method

  1. @override
List<InstanceHandle> getReferencingInstances(
  1. IInstance inst
)

Gets all instances that reference the specified instance.

This method performs an inverse relationship query to find all instances in the model that contain references to the specified inst.

The method is useful for:

  • Dependency analysis before deleting instances
  • Understanding how an instance is used throughout the model
  • Identifying relationships that might be affected by instance modifications
  • Debugging reference integrity issues

Parameters:

  • inst: The target instance to find references for. Must be a valid instance handle in the current model.

Returns a list of InstanceHandle objects representing all instances that reference the specified inst.

Implementation

@override
List<InstanceHandle> getReferencingInstances(IInstance inst) {
  if (inst.isNull || inst is! PIInstance) {
    return [];
  }
  final struct = _getReferencingInstances(projectPtr, ptr, inst.ptr);
  if (struct.instancePtr == nullptr) {
    return [];
  }
  final handleInst = PIInstance.fromInstanceStruct(struct);
  return instanceToHandles(handleInst);
}