/// <summary> /// Tries to resolve the given name to one or more node outputs. Checks for aggregates, and actual nodes. /// </summary> /// <param name="Name">The name to search for</param> /// <param name="OutOutputs">If the name is a match, receives an array of nodes and their output names</param> /// <returns>True if the name was found, false otherwise.</returns> public bool TryResolveInputReference(string Name, out NodeOutput[] OutOutputs) { // Check if it's a tag reference or node reference if (Name.StartsWith("#")) { // Check if it's a regular node or output name NodeOutput Output; if (TagNameToNodeOutput.TryGetValue(Name, out Output)) { OutOutputs = new NodeOutput[] { Output }; return(true); } } else { // Check if it's a regular node or output name Node Node; if (NameToNode.TryGetValue(Name, out Node)) { OutOutputs = Node.Outputs.Union(Node.Inputs).ToArray(); return(true); } // Check if it's an aggregate name Node[] Nodes; if (AggregateNameToNodes.TryGetValue(Name, out Nodes)) { OutOutputs = Nodes.SelectMany(x => x.Outputs.Union(x.Inputs)).Distinct().ToArray(); return(true); } } // Otherwise fail OutOutputs = null; return(false); }
/// <summary> /// Constructor /// </summary> /// <param name="InName">The name of this node</param> /// <param name="InInputs">Inputs that this node depends on</param> /// <param name="InOutputNames">Names of the outputs that this node produces</param> /// <param name="InInputDependencies">Nodes which this node is dependent on for its inputs</param> /// <param name="InOrderDependencies">Nodes which this node needs to run after. Should include all input dependencies.</param> /// <param name="InControllingTrigger">The trigger which this node is behind</param> /// <param name="InRequiredTokens">Optional tokens which must be required for this node to run</param> public Node(string InName, NodeOutput[] InInputs, string[] InOutputNames, Node[] InInputDependencies, Node[] InOrderDependencies, ManualTrigger InControllingTrigger, FileReference[] InRequiredTokens) { Name = InName; Inputs = InInputs; List<NodeOutput> AllOutputs = new List<NodeOutput>(); AllOutputs.Add(new NodeOutput(this, "#" + Name)); AllOutputs.AddRange(InOutputNames.Where(x => String.Compare(x, Name, StringComparison.InvariantCultureIgnoreCase) != 0).Select(x => new NodeOutput(this, x))); Outputs = AllOutputs.ToArray(); InputDependencies = InInputDependencies; OrderDependencies = InOrderDependencies; ControllingTrigger = InControllingTrigger; RequiredTokens = InRequiredTokens; }
/// <summary> /// Tries to resolve the given name to one or more node outputs. Checks for aggregates, and actual nodes. /// </summary> /// <param name="Name">The name to search for</param> /// <param name="OutOutputs">If the name is a match, receives an array of nodes and their output names</param> /// <returns>True if the name was found, false otherwise.</returns> public bool TryResolveInputReference(string Name, out NodeOutput[] OutOutputs) { // Check if it's a tag reference or node reference if(Name.StartsWith("#")) { // Check if it's a regular node or output name NodeOutput Output; if(TagNameToNodeOutput.TryGetValue(Name, out Output)) { OutOutputs = new NodeOutput[]{ Output }; return true; } } else { // Check if it's a regular node or output name Node Node; if(NameToNode.TryGetValue(Name, out Node)) { OutOutputs = Node.Outputs.Union(Node.Inputs).ToArray(); return true; } // Check if it's an aggregate name Node[] Nodes; if(AggregateNameToNodes.TryGetValue(Name, out Nodes)) { OutOutputs = Nodes.SelectMany(x => x.Outputs.Union(x.Inputs)).Distinct().ToArray(); return true; } } // Otherwise fail OutOutputs = null; return false; }