diff options
Diffstat (limited to 'opendc-core')
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt | 5 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/sampler/Sampler.kt) | 2 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt | 2 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyBuilder.kt | 11 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt | 40 | ||||
| -rw-r--r-- | opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt (renamed from opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt) | 4 |
6 files changed, 50 insertions, 14 deletions
diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt index 32b45ca2..d07c3ba0 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/Simulation.kt @@ -62,6 +62,11 @@ interface Simulation { val clock: Clock /** + * The observable state of an [Entity] in simulation, which is provided by the simulation context. + */ + val <E : Entity<S>, S> E.state: S + + /** * Step through one cycle in the simulation. This method will process all events in a single tick, update the * internal clock and then return the control to the user. */ diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/sampler/Sampler.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt index 2f36e6b7..66c33341 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/sampler/Sampler.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/kernel/sampler/Sampler.kt @@ -22,7 +22,7 @@ * SOFTWARE. */ -package nl.atlarge.opendc.sampler +package nl.atlarge.opendc.kernel.sampler /** * A sampler generates data points (samples) of the simulation based on the events that occur to [Entity] instances that diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt index ef9e0396..74b046de 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/AdjacencyList.kt @@ -55,7 +55,7 @@ internal class AdjacencyListTopologyBuilder : TopologyBuilder { * * @return The graph built from this builder. */ - override fun build(): MutableTopology = AdjacencyListTopology() + override fun create(): MutableTopology = AdjacencyListTopology() } /** 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 d5a57549..bb9c7e8e 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 @@ -29,19 +29,12 @@ package nl.atlarge.opendc.topology * * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) */ -interface TopologyBuilder { +interface TopologyBuilder : TopologyFactory { /** * Construct a [Topology] from the given block and return it. * * @param block The block to construct the topology. * @return The topology that has been built. */ - fun construct(block: MutableTopology.() -> Unit): MutableTopology = build().apply(block) - - /** - * Build a [Topology] instance from the current state of this builder. - * - * @return The graph built from this builder. - */ - fun build(): MutableTopology + fun construct(block: MutableTopology.() -> Unit): MutableTopology = create().apply(block) } diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt new file mode 100644 index 00000000..42b30a94 --- /dev/null +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/TopologyFactory.kt @@ -0,0 +1,40 @@ +/* + * MIT License + * + * Copyright (c) 2017 atlarge-research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package nl.atlarge.opendc.topology + +/** + * An interface for producing [Topology] instances. Implementors of this interface provide a way of generating a + * topology based on the state of the factory. + * + * @author Fabian Mastenbroek (f.s.mastenbroek@student.tudelft.nl) + */ +interface TopologyFactory { + /** + * Create a [MutableTopology] instance. + * + * @return A mutable topology. + */ + fun create(): MutableTopology +} diff --git a/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt index b5b5ec82..e57060ed 100644 --- a/opendc-core/src/main/kotlin/nl/atlarge/opendc/extension/topology/Traversable.kt +++ b/opendc-core/src/main/kotlin/nl/atlarge/opendc/topology/Traversable.kt @@ -22,9 +22,7 @@ * SOFTWARE. */ -package nl.atlarge.opendc.extension.topology - -import nl.atlarge.opendc.topology.Edge +package nl.atlarge.opendc.topology /** * Filter a [Set] of [Edge]s based on the tag of the edges and return the origin nodes casted to type `T`. |
