using System; using System.Collections.Generic; using JetBrains.Annotations; using Robust.Shared.GameObjects; namespace Robust.Server.Bql { [Flags] [PublicAPI] public enum QuerySelectorArgument { Integer = 0b00000001, Float = 0b00000010, String = 0b00000100, Percentage = 0b00001000, Component = 0b00010000, //SubQuery = 0b00100000, EntityId = 0b01000000, } [PublicAPI] public abstract class BqlQuerySelector { /// /// The token name for the given QuerySelector, for example `when`. /// public virtual string Token => throw new NotImplementedException(); /// /// Arguments for the given QuerySelector, presented as "what arguments are permitted in what spot". /// public virtual QuerySelectorArgument[] Arguments => throw new NotImplementedException(); /// /// Performs a transform over it's input entity list, whether that be filtering (selecting) or expanding the /// input on some criteria like what entities are nearby. /// /// Input entity list. /// Parsed selector arguments. /// Whether the query is inverted. /// The entity manager. /// New list of entities /// someone is a moron if this happens. public abstract IEnumerable DoSelection(IEnumerable input, IReadOnlyList arguments, bool isInverted, IEntityManager entityManager); /// /// Performs selection as the first selector in the query. Allows for optimizing when you can be more efficient /// than just querying every entity. /// /// /// /// /// public virtual IEnumerable DoInitialSelection(IReadOnlyList arguments, bool isInverted, IEntityManager entityManager) { return DoSelection(entityManager.GetEntities(), arguments, isInverted, entityManager); } [UsedImplicitly] protected BqlQuerySelector() {} } }