OutputChannel

interface OutputChannel<T : Any> : Channel<T>

A Channel a it.unibo.tuprolog.solve.Solver writes T-typed elements to, e.g. backing Prolog's write/1, a solver's standard output/error, or warning reporting.

Build one via the companion's stdOut/stdErr/warn (platform defaults), or of (wrapping a consumer function).

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val isClosed: Boolean

Whether this channel has been closed.

Link copied to clipboard
abstract val streamTerm: Struct

The Prolog $stream(Direction, Id)-like Struct term identifying this channel, e.g. for current_output/1.

Functions

Link copied to clipboard
abstract fun addListener(listener: Listener<T?>)

Registers listener to be invoked with every element subsequently transiting this channel.

Link copied to clipboard
abstract fun clearListeners()

Unregisters every currently-registered Listener.

Link copied to clipboard
abstract fun close()

Closes this channel; further reads/writes on it are expected to fail.

Link copied to clipboard
abstract fun flush()

Flushes any buffered output on this channel.

Link copied to clipboard
abstract fun removeListener(listener: Listener<T?>)

Unregisters listener, previously added via addListener.

Link copied to clipboard
open fun <R> use(function: OutputChannel<T>.() -> R): R

Runs function against this channel, closeing it once function returns normally (not on exceptions).

Link copied to clipboard
abstract fun write(value: T)

Writes value to this channel, notifying every registered Listener.