diff --git a/core/src/main/kotlin/org/nwapw/abacus/config/Configuration.kt b/core/src/main/kotlin/org/nwapw/abacus/config/Configuration.kt index e6bad12..e622910 100644 --- a/core/src/main/kotlin/org/nwapw/abacus/config/Configuration.kt +++ b/core/src/main/kotlin/org/nwapw/abacus/config/Configuration.kt @@ -1,7 +1,20 @@ package org.nwapw.abacus.config +/** + * A class that holds information that tells Abacus how to behave. + * + * Configuration stores information about how Abacus should behave, for + * instance, what number implementation it should use and what + * plugins should be ignored during loading. + * + * @property numberImplementation the number implementation Abacus should use for loading. + * @param disabledPlugins the plugins that should be disabled and not loaded by the plugin manager. + */ open class Configuration(var numberImplementation: String = "", disabledPlugins: Array = emptyArray()) { + /** + * The set of disabled plugins that should be ignored by the plugin manager. + */ val disabledPlugins = disabledPlugins.toMutableSet() } \ No newline at end of file diff --git a/fx/src/main/kotlin/org/nwapw/abacus/fx/ExtendedConfiguration.kt b/fx/src/main/kotlin/org/nwapw/abacus/fx/ExtendedConfiguration.kt index d79d6fd..9c0b152 100644 --- a/fx/src/main/kotlin/org/nwapw/abacus/fx/ExtendedConfiguration.kt +++ b/fx/src/main/kotlin/org/nwapw/abacus/fx/ExtendedConfiguration.kt @@ -5,25 +5,53 @@ import com.moandjiezana.toml.TomlWriter import org.nwapw.abacus.config.Configuration import java.io.File +/** + * Additional settings for user interface. + * + * ExtendedConfiguration is used to add other settings + * that aren't built into Abacus core, but are necessary + * for the fx module. + * + * @property computationDelay the delay before which the computation stops. + * @param implementation the number implementation, same as [Configuration.numberImplementation] + * @param disabledPlugins the list of plugins that should be disabled, same as [Configuration.disabledPlugins] + */ class ExtendedConfiguration(var computationDelay: Double = 0.0, implementation: String = "", disabledPlugins: Array = emptyArray()) : Configuration(implementation, disabledPlugins) { companion object { + /** + * The default TOML. + */ val DEFAULT_TOML_STRING = """ computationDelay=0.0 implementation="naive" disabledPlugins=[] """ + /** + * A reader with the default TOML data. + */ val DEFAULT_TOML_READER = Toml().read(DEFAULT_TOML_STRING) + /** + * A writer used to writing the configuration to disk. + */ val DEFAULT_TOML_WRITER = TomlWriter() } + /** + * Constructs a new configuration from a file on disk. + * @param tomlFile the file from disk to load. + */ constructor(tomlFile: File) : this() { copyFrom(Toml(DEFAULT_TOML_READER).read(tomlFile).to(ExtendedConfiguration::class.java)) } + /** + * Copies data from another configuration into this one. + * @param config the configuration to copy from. + */ fun copyFrom(config: ExtendedConfiguration) { computationDelay = config.computationDelay numberImplementation = config.numberImplementation @@ -31,6 +59,10 @@ class ExtendedConfiguration(var computationDelay: Double = 0.0, disabledPlugins.addAll(config.disabledPlugins) } + /** + * Saves this configuration to a file. + * @param file the file to save to. + */ fun saveTo(file: File) { DEFAULT_TOML_WRITER.write(this, file) }