ChannelStore

interface ChannelStore<T : Any, C : Channel<T>, Self : ChannelStore<T, C, Self>> : Map<String, C>

An immutable map of Channels keyed by alias, allowing a it.unibo.tuprolog.solve.Solver to hold several named I/O channels at once (e.g. to support Prolog's stream terms for format/3-style I/O redirection), rather than assuming a single channel per direction.

Every mutating-looking operation (plus/minus/setCurrent/close) returns a new Self instance rather than altering the receiver, consistent with the rest of 2P-Kt's immutable data structures. See InputStore and OutputStore for the two concrete specializations used by it.unibo.tuprolog.solve.Solver.

Type Parameters

T

the type of element carried by the stored channels.

C

the concrete Channel subtype stored.

Self

the concrete ChannelStore subtype, for covariant-returning methods.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val current: C?

The channel aliased as CURRENT in this store, or null if none is set.

Link copied to clipboard

Every alias, other than CURRENT itself, under which current is also reachable.

Link copied to clipboard
abstract val entries: Set<Map.Entry<String, C>>
Link copied to clipboard
abstract val keys: Set<String>
Link copied to clipboard
expect abstract val size: Int
Link copied to clipboard
abstract val values: Collection<C>

Functions

Link copied to clipboard
abstract fun aliasesOf(channel: C): Sequence<String>

Returns every alias under which channel is reachable in this store, excluding CURRENT.

Link copied to clipboard
open fun close(channel: C): Self

Channel.closes channel and returns a copy of this store without any alias pointing to it.

Link copied to clipboard
abstract fun containsKey(key: String): Boolean
Link copied to clipboard
abstract fun containsValue(value: C): Boolean
Link copied to clipboard
abstract fun findByTerm(streamTerm: Term): Sequence<C>

Returns every channel in this store whose Channel.streamTerm unifies with streamTerm.

Link copied to clipboard
abstract operator fun get(key: String): C?
Link copied to clipboard
expect abstract fun isEmpty(): Boolean
Link copied to clipboard
open operator fun minus(other: String): Self

Returns a copy of this store without the entry aliased other (if any).

open operator fun minus(others: Iterable<String>): Self
abstract operator fun minus(others: Sequence<String>): Self

Returns a copy of this store without the entries aliased in others.

open fun minus(other: String, vararg others: String): Self

Returns a copy of this store without the entries aliased other or in others.

Link copied to clipboard
open operator fun plus(other: Pair<String, C>): Self

Returns a copy of this store with other added (overriding an existing entry with the same alias).

open operator fun plus(others: Iterable<Pair<String, C>>): Self
abstract operator fun plus(others: Map<String, C>): Self
open operator fun plus(others: Sequence<Pair<String, C>>): Self

Returns a copy of this store with every entry of others added (overriding same-named existing ones).

open fun plus(first: Pair<String, C>, vararg others: Pair<String, C>): Self

Returns a copy of this store with first and others added (overriding same-named existing entries).

Link copied to clipboard
abstract fun setCurrent(channel: C): Self

Returns a copy of this store with CURRENT pointing to channel.

abstract fun setCurrent(alias: String): Self

Returns a copy of this store with CURRENT pointing to the channel already aliased as alias.