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

commonMain.it.unibo.tuprolog.solve.channel.OutputStore.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.solve.channel.impl.OutputStoreImpl
import it.unibo.tuprolog.solve.exception.Warning
import kotlin.js.JsName
import kotlin.jvm.JvmOverloads
import kotlin.jvm.JvmStatic

interface OutputStore : ChannelStore, OutputStore> {
    @JsName("stdOut")
    val stdOut: OutputChannel

    @JsName("setStdOut")
    fun setStdOut(channel: OutputChannel): OutputStore

    @JsName("stdErr")
    val stdErr: OutputChannel

    @JsName("setStdErr")
    fun setStdErr(channel: OutputChannel): OutputStore

    @JsName("warnings")
    val warnings: OutputChannel

    @JsName("setWarnings")
    fun setWarnings(channel: OutputChannel): OutputStore

    companion object {
        const val STDOUT = "stdout"

        const val STDERR = "stderr"

        @JsName("fromStandard")
        @JvmStatic
        @JvmOverloads
        fun fromStandard(
            output: OutputChannel = OutputChannel.stdOut(),
            error: OutputChannel = OutputChannel.stdErr(),
            warnings: OutputChannel = OutputChannel.warn(),
        ): OutputStore = OutputStoreImpl(output, error, warnings, mapOf("user_output" to output))

        @JsName("of")
        @JvmStatic
        @JvmOverloads
        fun of(
            channels: Map>,
            warnings: OutputChannel = OutputChannel.warn(),
        ): OutputStore {
            val stdOut = channels[STDOUT] ?: OutputChannel.stdOut()
            val stdErr = channels[STDERR] ?: OutputChannel.stdErr()
            return OutputStoreImpl(stdOut, stdErr, warnings, channels)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy