summaryrefslogtreecommitdiff
path: root/opendc-core
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-24 22:19:49 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2017-09-24 22:19:49 +0200
commitf417501d19e0fec18a9695ee0421a257abcf70b8 (patch)
tree6f7fb80d6d9f910fcc6695ac761fb28dbd3395ab /opendc-core
parenta031db367c71ec1604b34f3765198c2196bfe551 (diff)
Allow mutation of topology during simulation
Diffstat (limited to 'opendc-core')
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Context.kt3
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Kernel.kt3
-rw-r--r--opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt2
3 files changed, 5 insertions, 3 deletions
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<out E : Entity<*>> : 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.