All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.it.unibo.tuprolog.solve.channel.ChannelStore.kt Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.solve.channel

import it.unibo.tuprolog.core.Term
import kotlin.js.JsName

interface ChannelStore, Self : ChannelStore> : Map {
    companion object {
        const val CURRENT = "\$current"
    }

    @JsName("current")
    val current: C?
        get() = this[CURRENT]

    @JsName("currentAliases")
    val currentAliases: Sequence
        get() = current?.let { aliasesOf(it) } ?: emptySequence()

    @JsName("setCurrentAlias")
    fun setCurrent(alias: String): Self

    @JsName("setCurrentChannel")
    fun setCurrent(channel: C): Self

    @JsName("findByTerm")
    fun findByTerm(streamTerm: Term): Sequence

    @JsName("aliasesOf")
    fun aliasesOf(channel: C): Sequence

    @JsName("plusMap")
    operator fun plus(others: Map): Self

    @JsName("plus")
    operator fun plus(other: Pair): Self = plus(mapOf(other))

    @JsName("plusIterable")
    operator fun plus(others: Iterable>): Self = plus(others.toMap())

    @JsName("plusSequence")
    operator fun plus(others: Sequence>): Self = plus(others.toMap())

    @JsName("plusMany")
    fun plus(
        first: Pair,
        vararg others: Pair,
    ): Self = plus(mapOf(first, *others))

    @JsName("minus")
    operator fun minus(other: String): Self = minus(sequenceOf(other))

    @JsName("minusIterable")
    operator fun minus(others: Iterable): Self = minus(others.asSequence())

    @JsName("minusSequence")
    operator fun minus(others: Sequence): Self

    @JsName("minusMany")
    fun minus(
        other: String,
        vararg others: String,
    ): Self = minus(sequenceOf(other, *others))

    @JsName("close")
    fun close(channel: C): Self = this - aliasesOf(channel.also { it.close() })
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy