// 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;
namespace AutomationTool
{
///
/// Defines a manual trigger; a fence behind which build nodes will only be built if explicitly activated in the job setup.
///
class ManualTrigger
{
///
/// The parent trigger
///
public readonly ManualTrigger Parent;
///
/// Name of this trigger
///
public readonly string Name;
///
/// List of users to notify about this trigger
///
public HashSet NotifyUsers = new HashSet(StringComparer.InvariantCultureIgnoreCase);
///
/// Constructor
///
/// The parent trigger
/// Name of this trigger
public ManualTrigger(ManualTrigger InParent, string InName)
{
Parent = InParent;
Name = InName;
}
///
/// Checks whether this trigger is upstream of another
///
/// The other trigger to check
/// True if this trigger is upstream of the given trigger
public bool IsUpstreamFrom(ManualTrigger Other)
{
for(ManualTrigger Ancestor = Other; Ancestor != null; Ancestor = Ancestor.Parent)
{
if(Ancestor == this)
{
return true;
}
}
return false;
}
///
/// Checks whether this trigger is downstream of another
///
/// The parent trigger to check
/// True if the trigger is downstream of the given trigger
public bool IsDownstreamFrom(ManualTrigger Other)
{
for(ManualTrigger Ancestor = Parent; Ancestor != null; Ancestor = Ancestor.Parent)
{
if(Ancestor == Other)
{
return true;
}
}
return false;
}
///
/// The qualified name of this trigger. For triggers which are nested more than one level deep, this consists of all the required triggers in order, separated by dot characters.
///
public string QualifiedName
{
get { return (Parent == null)? Name : (Parent.QualifiedName + "." + Name); }
}
///
/// Get the name of this trigger
///
/// The qualified name of this trigger
public override string ToString()
{
return QualifiedName;
}
}
}