commonMain.it.unibo.tuprolog.solve.sideffects.impl.SideEffectsBuilderImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solve-jvm Show documentation
Show all versions of solve-jvm Show documentation
Resolution-agnostic API for logic solvers
package it.unibo.tuprolog.solve.sideffects.impl
import it.unibo.tuprolog.core.Clause
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.core.operators.Operator
import it.unibo.tuprolog.solve.channel.InputChannel
import it.unibo.tuprolog.solve.channel.OutputChannel
import it.unibo.tuprolog.solve.library.Library
import it.unibo.tuprolog.solve.library.Runtime
import it.unibo.tuprolog.solve.sideffects.SideEffect
import it.unibo.tuprolog.solve.sideffects.SideEffectFactory
import it.unibo.tuprolog.solve.sideffects.SideEffectsBuilder
internal data class SideEffectsBuilderImpl(
override val sideEffects: MutableList,
private val factory: SideEffectFactory = DefaultSideEffectFactory,
) : SideEffectsBuilder {
private fun adding(f: () -> T): T = f().also { sideEffects.add(it) }
override fun resetStaticKb(clauses: Iterable): SideEffect.ResetStaticKb =
adding {
factory.resetStaticKb(clauses)
}
override fun resetStaticKb(clauses: Sequence): SideEffect.ResetStaticKb =
adding {
factory.resetStaticKb(clauses)
}
override fun resetStaticKb(vararg clauses: Clause): SideEffect.ResetStaticKb =
adding {
factory.resetStaticKb(*clauses)
}
override fun addStaticClauses(
clauses: Iterable,
onTop: Boolean,
): SideEffect.AddStaticClauses = adding { factory.addStaticClauses(clauses, onTop) }
override fun addStaticClauses(
clauses: Sequence,
onTop: Boolean,
): SideEffect.AddStaticClauses = adding { factory.addStaticClauses(clauses, onTop) }
override fun addStaticClauses(
vararg clauses: Clause,
onTop: Boolean,
): SideEffect.AddStaticClauses = adding { factory.addStaticClauses(*clauses, onTop = onTop) }
override fun removeStaticClauses(clauses: Iterable): SideEffect.RemoveStaticClauses =
adding { factory.removeStaticClauses(clauses) }
override fun removeStaticClauses(clauses: Sequence): SideEffect.RemoveStaticClauses =
adding { factory.removeStaticClauses(clauses) }
override fun removeStaticClauses(vararg clauses: Clause): SideEffect.RemoveStaticClauses =
adding { factory.removeStaticClauses(*clauses) }
override fun resetDynamicKb(clauses: Iterable): SideEffect.ResetDynamicKb =
adding {
factory.resetDynamicKb(clauses)
}
override fun resetDynamicKb(clauses: Sequence): SideEffect.ResetDynamicKb =
adding {
factory.resetDynamicKb(clauses)
}
override fun resetDynamicKb(vararg clauses: Clause): SideEffect.ResetDynamicKb =
adding {
factory.resetDynamicKb(*clauses)
}
override fun addDynamicClauses(
clauses: Iterable,
onTop: Boolean,
): SideEffect.AddDynamicClauses = adding { factory.addDynamicClauses(clauses, onTop) }
override fun addDynamicClauses(
clauses: Sequence,
onTop: Boolean,
): SideEffect.AddDynamicClauses = adding { factory.addDynamicClauses(clauses, onTop) }
override fun addDynamicClauses(
vararg clauses: Clause,
onTop: Boolean,
): SideEffect.AddDynamicClauses = adding { factory.addDynamicClauses(*clauses, onTop = onTop) }
override fun removeDynamicClauses(clauses: Iterable): SideEffect.RemoveDynamicClauses =
adding { factory.removeDynamicClauses(clauses) }
override fun removeDynamicClauses(clauses: Sequence): SideEffect.RemoveDynamicClauses =
adding { factory.removeDynamicClauses(clauses) }
override fun removeDynamicClauses(vararg clauses: Clause): SideEffect.RemoveDynamicClauses =
adding { factory.removeDynamicClauses(*clauses) }
override fun setFlags(flags: Map): SideEffect.SetFlags = adding { factory.setFlags(flags) }
override fun setFlags(vararg flags: Pair): SideEffect.SetFlags = adding { factory.setFlags(*flags) }
override fun setFlag(
name: String,
value: Term,
): SideEffect.SetFlags = adding { factory.setFlag(name, value) }
override fun resetFlags(flags: Map): SideEffect.ResetFlags = adding { factory.resetFlags(flags) }
override fun resetFlags(vararg flags: Pair): SideEffect.ResetFlags =
adding {
factory.resetFlags(
*flags,
)
}
override fun clearFlags(names: Iterable): SideEffect.ClearFlags = adding { factory.clearFlags(names) }
override fun clearFlags(names: Sequence): SideEffect.ClearFlags = adding { factory.clearFlags(names) }
override fun clearFlags(vararg names: String): SideEffect.ClearFlags = adding { factory.clearFlags(*names) }
override fun loadLibrary(library: Library): SideEffect.LoadLibrary = adding { factory.loadLibrary(library) }
override fun updateLibrary(library: Library): SideEffect.UpdateLibrary = adding { factory.updateLibrary(library) }
override fun setOperators(operators: Iterable): SideEffect.SetOperators =
adding {
factory.setOperators(operators)
}
override fun setOperators(operators: Sequence): SideEffect.SetOperators =
adding {
factory.setOperators(operators)
}
override fun setOperators(vararg operators: Operator): SideEffect.SetOperators =
adding {
factory.setOperators(*operators)
}
override fun resetOperators(operators: Iterable): SideEffect.ResetOperators =
adding {
factory.resetOperators(operators)
}
override fun resetOperators(operators: Sequence): SideEffect.ResetOperators =
adding {
factory.resetOperators(operators)
}
override fun resetOperators(vararg operators: Operator): SideEffect.ResetOperators =
adding {
factory.resetOperators(*operators)
}
override fun removeOperators(operators: Iterable): SideEffect.RemoveOperators =
adding {
factory.removeOperators(operators)
}
override fun removeOperators(operators: Sequence): SideEffect.RemoveOperators =
adding {
factory.removeOperators(operators)
}
override fun removeOperators(vararg operators: Operator): SideEffect.RemoveOperators =
adding {
factory.removeOperators(*operators)
}
override fun openInputChannels(inputChannels: Map>): SideEffect.OpenInputChannels =
adding { factory.openInputChannels(inputChannels) }
override fun openInputChannels(
vararg inputChannels: Pair>,
): SideEffect.OpenInputChannels = adding { factory.openInputChannels(*inputChannels) }
override fun openInputChannel(
name: String,
inputChannel: InputChannel,
): SideEffect.OpenInputChannels = adding { factory.openInputChannel(name, inputChannel) }
override fun resetInputChannels(
vararg inputChannels: Pair>,
): SideEffect.ResetInputChannels = adding { factory.resetInputChannels(*inputChannels) }
override fun closeInputChannels(names: Iterable): SideEffect.CloseInputChannels =
adding {
factory.closeInputChannels(names)
}
override fun closeInputChannels(names: Sequence): SideEffect.CloseInputChannels =
adding {
factory.closeInputChannels(names)
}
override fun closeInputChannels(vararg names: String): SideEffect.CloseInputChannels =
adding {
factory.closeInputChannels(*names)
}
override fun openOutputChannels(outputChannels: Map>): SideEffect.OpenOutputChannels =
adding { factory.openOutputChannels(outputChannels) }
override fun openOutputChannels(
vararg outputChannels: Pair>,
): SideEffect.OpenOutputChannels = adding { factory.openOutputChannels(*outputChannels) }
override fun openOutputChannel(
name: String,
outputChannel: OutputChannel,
): SideEffect.OpenOutputChannels = adding { factory.openOutputChannel(name, outputChannel) }
override fun resetOutputChannels(
outputChannels: Map>,
): SideEffect.ResetOutputChannels = adding { factory.resetOutputChannels(outputChannels) }
override fun resetOutputChannels(
vararg outputChannels: Pair>,
): SideEffect.ResetOutputChannels = adding { factory.resetOutputChannels(*outputChannels) }
override fun closeOutputChannels(names: Iterable): SideEffect.CloseOutputChannels =
adding { factory.closeOutputChannels(names) }
override fun closeOutputChannels(names: Sequence): SideEffect.CloseOutputChannels =
adding { factory.closeOutputChannels(names) }
override fun closeOutputChannels(vararg names: String): SideEffect.CloseOutputChannels =
adding {
factory.closeOutputChannels(*names)
}
override fun unloadLibraries(aliases: Iterable): SideEffect.UnloadLibraries =
adding {
factory.unloadLibraries(aliases)
}
override fun unloadLibraries(aliases: Sequence): SideEffect.UnloadLibraries =
adding {
factory.unloadLibraries(aliases)
}
override fun unloadLibraries(vararg aliases: String): SideEffect.UnloadLibraries =
adding {
factory.unloadLibraries(*aliases)
}
override fun resetRuntime(libraries: Runtime): SideEffect.ResetRuntime = adding { factory.resetRuntime(libraries) }
override fun resetRuntime(libraries: Iterable): SideEffect.ResetRuntime =
adding {
factory.resetRuntime(libraries)
}
override fun resetRuntime(libraries: Sequence): SideEffect.ResetRuntime =
adding {
factory.resetRuntime(libraries)
}
override fun resetRuntime(vararg libraries: Library): SideEffect.ResetRuntime =
adding {
factory.resetRuntime(*libraries)
}
override fun addLibraries(libraries: Runtime): SideEffect.AddLibraries = adding { factory.addLibraries(libraries) }
override fun addLibraries(libraries: Iterable): SideEffect.AddLibraries =
adding {
factory.addLibraries(libraries)
}
override fun addLibraries(libraries: Sequence): SideEffect.AddLibraries =
adding {
factory.addLibraries(libraries)
}
override fun addLibraries(vararg libraries: Library): SideEffect.AddLibraries =
adding {
factory.addLibraries(*libraries)
}
override fun resetInputChannels(
inputChannels: Iterable>>,
): SideEffect.ResetInputChannels = adding { factory.resetInputChannels(inputChannels) }
override fun resetInputChannels(
inputChannels: Sequence>>,
): SideEffect.ResetInputChannels = adding { factory.resetInputChannels(inputChannels) }
override fun resetInputChannels(inputChannels: Map>): SideEffect.ResetInputChannels =
adding { factory.resetInputChannels(inputChannels) }
override fun resetOutputChannels(
outputChannels: Iterable>>,
): SideEffect.ResetOutputChannels = adding { factory.resetOutputChannels(outputChannels) }
override fun resetOutputChannels(
outputChannels: Sequence>>,
): SideEffect.ResetOutputChannels = adding { factory.resetOutputChannels(outputChannels) }
override fun addEphemeralData(
key: String,
value: Any,
): SideEffect.SetEphemeralData = adding { factory.addEphemeralData(key, value) }
override fun addEphemeralData(data: Map): SideEffect.SetEphemeralData =
adding {
factory.addEphemeralData(data)
}
override fun addEphemeralData(vararg data: Pair): SideEffect.SetEphemeralData =
adding { factory.addEphemeralData(*data) }
override fun setEphemeralData(
key: String,
value: Any,
): SideEffect.SetEphemeralData = adding { factory.setEphemeralData(key, value) }
override fun setEphemeralData(data: Map): SideEffect.SetEphemeralData =
adding {
factory.setEphemeralData(data)
}
override fun setEphemeralData(vararg data: Pair): SideEffect.SetEphemeralData =
adding { factory.setEphemeralData(*data) }
override fun addDurableData(
key: String,
value: Any,
): SideEffect.SetDurableData = adding { factory.addDurableData(key, value) }
override fun addDurableData(data: Map): SideEffect.SetDurableData =
adding {
factory.addDurableData(data)
}
override fun addDurableData(vararg data: Pair): SideEffect.SetDurableData =
adding {
factory.addDurableData(*data)
}
override fun setDurableData(
key: String,
value: Any,
): SideEffect.SetDurableData = adding { factory.setDurableData(key, value) }
override fun setDurableData(data: Map): SideEffect.SetDurableData =
adding {
factory.setDurableData(data)
}
override fun setDurableData(vararg data: Pair): SideEffect.SetDurableData =
adding {
factory.setDurableData(*data)
}
override fun addPersistentData(
key: String,
value: Any,
): SideEffect.SetPersistentData = adding { factory.addPersistentData(key, value) }
override fun addPersistentData(data: Map): SideEffect.SetPersistentData =
adding {
factory.addPersistentData(data)
}
override fun addPersistentData(vararg data: Pair): SideEffect.SetPersistentData =
adding { factory.addPersistentData(*data) }
override fun setPersistentData(
key: String,
value: Any,
): SideEffect.SetPersistentData = adding { factory.setPersistentData(key, value) }
override fun setPersistentData(data: Map): SideEffect.SetPersistentData =
adding {
factory.setPersistentData(data)
}
override fun setPersistentData(vararg data: Pair): SideEffect.SetPersistentData =
adding { factory.setPersistentData(*data) }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy