You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
861 B
Kotlin
28 lines
861 B
Kotlin
package me.eater.hefbrug.dsl.context.extension_util
|
|
|
|
import me.eater.hefbrug.dsl.context.ContextInterface
|
|
import me.eater.hefbrug.dsl.scope.ScopeInterface
|
|
import java.util.*
|
|
|
|
class RuntimeRegister {
|
|
private val scopeMap = mutableMapOf<ContextInterface, ScopeInterface>()
|
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
fun <T : ScopeInterface> getScope(context: ContextInterface): T =
|
|
scopeMap[context]!! as T
|
|
|
|
fun registerScope(context: ContextInterface, scope: ScopeInterface) {
|
|
scopeMap[context] = scope
|
|
}
|
|
|
|
companion object {
|
|
private val runtimeRegisterMap = mutableMapOf<UUID, RuntimeRegister>()
|
|
|
|
operator fun get(runtimeUUID: UUID) =
|
|
runtimeRegisterMap.getOrPut(runtimeUUID, { RuntimeRegister() })
|
|
|
|
fun remove(runtimeUUID: UUID) {
|
|
runtimeRegisterMap.remove(runtimeUUID)
|
|
}
|
|
}
|
|
} |