All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spice.ImplementationManager.scala Maven / Gradle / Ivy

There is a newer version: 0.5.14
Show newest version
package spice

import moduload.Moduload

trait ImplementationManager[Implementation, Config] {
  private var creator: Option[Config => Implementation] = None

  Moduload.load()

  def apply(config: Config): Implementation = creator
    .getOrElse(throw new NoImplementationException)
    .apply(config)

  def register(creator: Config => Implementation): Unit = synchronized {
    require(this.creator.isEmpty, "An implementation manager is already registered!")
    this.creator = Some(creator)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy