DockFactory
interface DockFactory
Harbour can load/save the position and visibility of docks. We therefore need a way to create a dock from a unique identifier.
The identifier is Dock.dockID, which is a String
.
If you wish to create docks on-demand :
class MyDockFactory(val harbour: Harbour) : DockFactory {
override fun createDock(harbour : Harbour, dockID: String) = harbour.findDock(dockID) ?: when (dockID) {
"abc" -> AbcDock(harbour)
"xyz" -> XyzDock(harbour)
else -> throw Exception("Unknown '$dockID'")
}
}
Content copied to clipboard
However, if you prefer to create all docks at the same time as that the Harbour is created, consider using MapDockFactory.