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'")
    }
}

However, if you prefer to create all docks at the same time as that the Harbour is created, consider using MapDockFactory.

Inheritors

Functions

Link copied to clipboard
abstract fun createDock(harbour: Harbour, dockID: String): Dock?
Link copied to clipboard
open fun dockClosed(harbour: Harbour, dock: Dock)

An optional method, which gives you the opportunity to tidy up (e.g. release resources) when a dock is closed.