FlagStore

data class FlagStore(flags: Map<String, Term>) : Map<String, Term>

An immutable storage for Prolog flags and their values, i.e. the String → Termmap a [it.unibo.tuprolog.solve.Solver] reads (via [it.unibo.tuprolog.solve.ExecutionContextAware.flags]) to answer current_prolog_flag/2` and similar. Keeping flags as data, rather than as scattered solver fields, makes the whole configurable surface of a solver enumerable and snapshot-able as part of an it.unibo.tuprolog.solve.ExecutionContext.

Every mutator (set, plus, minus) returns a new FlagStore rather than changing this one in place. Flags can be addressed either by plain String name, or by a NotableFlag (a typed, ISO-standard or implementation-defined flag such as Unknown or DoubleQuotes), which additionally validates the assigned value against NotableFlag.admissibleValues.

See also

Constructors

Link copied to clipboard
constructor(flags: Map<String, Term>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val entries: Set<Map.Entry<String, Term>>
Link copied to clipboard
open override val keys: Set<String>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: Collection<Term>

Functions

Link copied to clipboard
open override fun containsKey(key: String): Boolean
Link copied to clipboard
open override fun containsValue(value: Term): Boolean
Link copied to clipboard
operator fun get(notableFlag: NotableFlag): Term?

Looks up the value of notableFlag by its NotableFlag.name, or null if unset.

open operator override fun get(key: String): Term?
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
operator fun minus(flagName: String): FlagStore

Returns a copy of this store without the flag named flagName.

operator fun minus(flagNames: Iterable<String>): FlagStore

Returns a copy of this store without any of the flags named in flagNames.

Link copied to clipboard
operator fun plus(notableFlagValue: NotableFlag): FlagStore

Returns a copy of this store with notableFlagValue set to its NotableFlag.defaultValue.

operator fun plus(flagValue: Pair<String, Term>): FlagStore

Returns a copy of this store with the flag named flagValue's first component set to its second component.

operator fun plus(flags: Map<String, Term>): FlagStore

Returns a copy of this store with every entry of flags set (added, or overriding existing ones).

fun plus(name: String, value: Term): FlagStore

Same as set, as a regularly-named method rather than an operator.

Link copied to clipboard
fun set(notableFlag: NotableFlag): FlagStore

Returns a copy of this store with notableFlag set to its NotableFlag.defaultValue.

operator fun set(notableFlag: NotableFlag, value: Term): FlagStore

Returns a copy of this store with notableFlag set to value.

operator fun set(name: String, value: Term): FlagStore

Returns a copy of this store with the flag named name set to value (added, or replacing any previous value).