diff --git a/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt b/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt index ac5227b..318d1a7 100644 --- a/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt +++ b/base/src/main/kotlin/de/staropensource/engine/base/Engine.kt @@ -27,6 +27,7 @@ import de.staropensource.engine.base.utility.FileAccess import de.staropensource.engine.base.utility.dnihbd.BuildInformation import java.nio.charset.Charset import java.nio.charset.StandardCharsets +import kotlin.reflect.KClass /** * Primary class of the engine. @@ -102,6 +103,18 @@ class Engine private constructor() { */ fun getSubsystems(): Array = subsystems.toTypedArray() + /** + * Returns the loaded instance + * of the specified [Subsystem]. + * + * @since v1-alpha10 + */ + fun getSubsystem(subsystemClass: KClass): Subsystem? = getSubsystems().find { subsystem -> try { + subsystem::class.qualifiedName!! == subsystemClass.qualifiedName!! + } catch (_: NullPointerException) { + false + } } + /** * Registers the specified subsystem. *