From f417501d19e0fec18a9695ee0421a257abcf70b8 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 24 Sep 2017 22:19:49 +0200 Subject: Allow mutation of topology during simulation --- opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt | 3 ++- opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt | 3 ++- .../src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'opendc-core/src') diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt index 6185e273..83a7c4fb 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt @@ -30,6 +30,7 @@ import nl.atlarge.opendc.kernel.time.Clock import nl.atlarge.opendc.kernel.time.Duration import nl.atlarge.opendc.kernel.time.Instant import nl.atlarge.opendc.topology.Entity +import nl.atlarge.opendc.topology.MutableTopology import nl.atlarge.opendc.topology.Topology import nl.atlarge.opendc.topology.TopologyContext import java.lang.Process @@ -50,7 +51,7 @@ interface Context> : Readable, Writable, TopologyContext { /** * The [Topology] over which the simulation is run. */ - val topology: Topology + val topology: MutableTopology /** * The current point in simulation time. diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt index 524c9131..ffb6299c 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt @@ -24,6 +24,7 @@ package nl.atlarge.opendc.kernel +import nl.atlarge.opendc.topology.MutableTopology import nl.atlarge.opendc.topology.Topology /** @@ -45,5 +46,5 @@ interface Kernel { * @param topology The [Topology] to create a [Simulation] of. * @return A [Simulation] instance. */ - fun create(topology: Topology): Simulation + fun create(topology: MutableTopology): Simulation } diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt index 20cbdb0c..d5a57549 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt @@ -36,7 +36,7 @@ interface TopologyBuilder { * @param block The block to construct the topology. * @return The topology that has been built. */ - fun construct(block: MutableTopology.() -> Unit): Topology = build().apply(block) + fun construct(block: MutableTopology.() -> Unit): MutableTopology = build().apply(block) /** * Build a [Topology] instance from the current state of this builder. -- cgit v1.2.3