// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace AutomationTool { /// /// Stores a list of nodes which can be executed on a single agent /// [DebuggerDisplay("{Name}")] class Agent { /// /// Name of this agent. Used for display purposes in a build system. /// public string Name; /// /// Array of valid agent types that these nodes may run on. When running in the build system, this determines the class of machine that should /// be selected to run these nodes. The first defined agent type for this branch will be used. /// public string[] PossibleTypes; /// /// List of nodes in this agent group. /// public List Nodes = new List(); /// /// Constructor /// /// Name of this agent group /// Array of valid agent types. See comment for AgentTypes member. public Agent(string InName, string[] InPossibleTypes) { Name = InName; PossibleTypes = InPossibleTypes; } /// /// Writes this agent group out to a file, filtering nodes by a controlling trigger /// /// The XML writer to output to /// The controlling trigger to filter by public void Write(XmlWriter Writer, ManualTrigger ControllingTrigger) { if (Nodes.Any(x => x.ControllingTrigger == ControllingTrigger)) { Writer.WriteStartElement("Agent"); Writer.WriteAttributeString("Name", Name); Writer.WriteAttributeString("Type", String.Join(";", PossibleTypes)); foreach (Node Node in Nodes) { if (Node.ControllingTrigger == ControllingTrigger) { Node.Write(Writer); } } Writer.WriteEndElement(); } } } }