// Copyright Epic Games, Inc. All Rights Reserved.
using System;
namespace UnrealBuildTool
{
///
/// Represents a layer within the rules hierarchy. Any module is created within a certain scope, and may only reference modules in an equal or parent scope (eg. engine modules cannot reference project modules).
///
class RulesScope
{
///
/// Name of this scope
///
public string Name;
///
/// The parent scope
///
public RulesScope? Parent;
///
/// Constructor
///
/// Name of this scope
/// The parent scope
public RulesScope(string Name, RulesScope? Parent)
{
this.Name = Name;
this.Parent = Parent;
}
///
/// Checks whether this scope contains another scope
///
/// The other scope to check
/// True if this scope contains the other scope
public bool Contains(RulesScope Other)
{
for (RulesScope? Scope = this; Scope != null; Scope = Scope.Parent)
{
if (Scope == Other)
{
return true;
}
}
return false;
}
///
/// Formats the hierarchy of scopes
///
/// String representing the hierarchy of scopes
public string FormatHierarchy()
{
if (Parent == null)
{
return Name;
}
else
{
return String.Format("{0} -> {1}", Name, Parent.FormatHierarchy());
}
}
}
}