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

commonMain.it.unibo.tuprolog.solve.channel.InputChannel.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.Struct
import it.unibo.tuprolog.solve.channel.impl.InputChannelFromFunction
import kotlin.js.JsName
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic

interface InputChannel : Channel {
    companion object {
        @JvmStatic
        @JsName("stdIn")
        fun stdIn(): InputChannel = stdin()

        @JvmStatic
        @JsName("ofWithAvailabilityChecker")
        fun  of(
            generator: () -> X?,
            availabilityChecker: () -> Boolean,
        ): InputChannel = InputChannelFromFunction(generator, availabilityChecker)

        @JvmStatic
        @JsName("of")
        fun  of(generator: () -> X?): InputChannel = InputChannelFromFunction(generator, { true })

        @JvmStatic
        @JsName("ofString")
        fun of(string: String): InputChannel = stringInputChannel(string)

        @JvmStatic
        @JvmOverloads
        @JsName("streamTerm")
        fun streamTerm(id: String? = null): Struct = Channel.streamTerm(input = true, id)
    }

    @JsName("available")
    val available: Boolean

    @JsName("isOver")
    val isOver: Boolean

    @JsName("read")
    fun read(): T?

    @JsName("peek")
    fun peek(): T?

    @JsName("use")
    fun  use(function: InputChannel.() -> R): R = this.function().also { close() }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy