/// <summary> /// Tests equality with a target</summary> /// <param name="other">Object compared to</param> /// <returns>True iff other object binds to the same leaf node and pin index. Instancing node is not checked.</returns> public bool Equals(PinTarget other) { if (other == null) { return(false); } return(LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex); }
/// <summary> /// Determines whether the specified pin target is equal to the current pin target, including the instancing node</summary> /// <param name="other">Pin target compared to</param> /// <returns>True iff other pin target binds to the same leaf node, pin index, and same instancing node</returns> public bool FullyEquals(PinTarget other) { if (other == null) { return(false); } return(LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex && InstancingNode == other.InstancingNode); }
/// <summary> /// Updates LeafDomNode and LeafPinIndex from the ultimate DomNode this group pin binds to /// by recursively going down the nested group hierarchy</summary> /// <param name="inputSide">True if this is an input-side group pin, false if output-side</param> public void SetPinTarget(bool inputSide) { m_inputSide = inputSide; DomNode instancingNode; DomNode leafNode = GetLeafDomNode(inputSide, out instancingNode); if (m_pinTarget != null && m_pinTarget.InstancingNode != null) { instancingNode = m_pinTarget.InstancingNode;// try keep the original instancingNode } PinTarget = new PinTarget(leafNode, GetLeafPinIndex(inputSide), instancingNode); }
/// <summary> /// Finds the element and pin that matched the pin target for this circuit container.</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public override Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide) { if (pinTarget.InstancingNode != DomNode) { return(new Pair <Element, ICircuitPin>()); // look no farthur } var result = Element.MatchPinTarget(pinTarget, inputSide); if (result.First != null) { result.First = this; } return(result); }
/// <summary> /// Finds the element and pin that matched the pin target for this circuit container</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public virtual Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide) { var result = new Pair <Element, ICircuitPin>(); if (pinTarget != null && pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circuit hierarchy { var pin = inputSide ? Type.GetInputPin(pinTarget.LeafPinIndex) : Type.GetOutputPin(pinTarget.LeafPinIndex); if (pin != null) { result.First = this; result.Second = pin; } } return(result); }
/// <summary> /// Finds the element and pin that fully matched the pin target for this circuit container, /// including the template instance node</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public Pair <Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide) { var result = new Pair <Element, ICircuitPin>(); foreach (var module in Elements) { result = module.FullyMatchPinTarget(pinTarget, inputSide); if (result.First != null) { break; } } return(result); }
/// <summary> /// Finds the element and pin that matched the pin target for this circuit container</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public virtual Pair <Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide) { var result = new Pair <Element, ICircuitPin>(); if (pinTarget != null && pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circuit hierarchy { bool validPinIndex = inputSide ? pinTarget.LeafPinIndex < Type.Inputs.Count : pinTarget.LeafPinIndex < Type.Outputs.Count; if (validPinIndex) { result.First = this; result.Second = inputSide ? Type.Inputs[pinTarget.LeafPinIndex] : Type.Outputs[pinTarget.LeafPinIndex]; } } return(result); }
/// <summary> /// Finds the element and pin that fully matched the pin target for this circuit container, /// including the template instance node</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public virtual Pair<Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide) { return MatchPinTarget(pinTarget, inputSide); }
/// <summary> /// Finds the element and pin that matched the pin target for this circuit container</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public virtual Pair<Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide) { var result = new Pair<Element, ICircuitPin>(); if (pinTarget != null && pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circut hiearchy { bool validPinIndex = inputSide ? pinTarget.LeafPinIndex < Type.Inputs.Count : pinTarget.LeafPinIndex < Type.Outputs.Count; if (validPinIndex) { result.First = this; result.Second = inputSide ? Type.Inputs[pinTarget.LeafPinIndex] : Type.Outputs[pinTarget.LeafPinIndex]; } } return result; }
/// <summary> /// Tests equality with a target</summary> /// <param name="other">Object compared to</param> /// <returns>True iff other object binds to the same leaf node and pin index. Instancing node is not checked.</returns> public bool Equals(PinTarget other) { if (other == null) return false; return (LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex); }
/// <summary> /// Determines whether the specified pin target is equal to the current pin target, including the instancing node</summary> /// <param name="other">Pin target compared to</param> /// <returns>True iff other pin target binds to the same leaf node, pin index, and same instancing node</returns> public bool FullyEquals(PinTarget other) { if (other == null) return false; return (LeafDomNode == other.LeafDomNode && LeafPinIndex == other.LeafPinIndex && InstancingNode == other.InstancingNode); }
/// <summary> /// Finds the element and pin that fully matched the pin target for this circuit container, /// including the template instance node</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public override Pair <Element, ICircuitPin> FullyMatchPinTarget(PinTarget pinTarget, bool inputSide) { return(MatchPinTarget(pinTarget, inputSide)); }
/// <summary> /// Finds the element and pin that matched the pin target for this circuit container</summary> /// <param name="pinTarget">Contains pin's element and pin index</param> /// <param name="inputSide">True for input pin, false for output pin</param> /// <returns>Return a pair of element and pin. As an element instance method, if there is a match, the element is self, /// and pin is one of its pins defined in Type. If there is no match, both are null.</returns> public virtual Pair<Element, ICircuitPin> MatchPinTarget(PinTarget pinTarget, bool inputSide) { var result = new Pair<Element, ICircuitPin>(); if (pinTarget != null && pinTarget.LeafDomNode == DomNode) // an element must be a leaf node in a circuit hierarchy { var pin = inputSide ? Type.GetInputPin(pinTarget.LeafPinIndex) : Type.GetOutputPin(pinTarget.LeafPinIndex); if (pin != null) { result.First = this; result.Second = pin; } } return result; }
/// <summary> /// Sets input and output PinTarget for this connection</summary> public void SetPinTarget() { if (InputPin != null) { bool isInputElementRef = InputElement.DomNode.Is <IReference <DomNode> >(); if (InputPin.Is <GroupPin>()) { if (isInputElementRef) { var pinTarget = InputPin.Cast <GroupPin>().PinTarget; InputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex, InputElement.DomNode); } else { InputPinTarget = InputPin.Cast <GroupPin>().PinTarget; } } else { if (isInputElementRef) { var reference = InputElement.As <IReference <DomNode> >(); InputPinTarget = new PinTarget(reference.Target, InputPin.Index, InputElement.DomNode); } else { InputPinTarget = new PinTarget(InputElement.DomNode, InputPin.Index, null); } } Debug.Assert(InputPinTarget != null, "sanity check"); } if (OutputPin != null) { bool isOutputElementRef = OutputElement.DomNode.Is <IReference <DomNode> >(); if (OutputPin.Is <GroupPin>()) { if (isOutputElementRef) { var pinTarget = OutputPin.Cast <GroupPin>().PinTarget; OutputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex, OutputElement.DomNode); } else { OutputPinTarget = OutputPin.Cast <GroupPin>().PinTarget; } } else { if (isOutputElementRef) { var reference = OutputElement.Cast <IReference <DomNode> >(); OutputPinTarget = new PinTarget(reference.Target, OutputPin.Index, OutputElement.DomNode); } else { OutputPinTarget = new PinTarget(OutputElement.DomNode, OutputPin.Index, null); } } Debug.Assert(OutputPinTarget != null, "sanity check"); } }