diff --git a/build.gradle.kts b/build.gradle.kts index 9b042061..ecaee7a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("scientifik.mpp") version "0.1.4-dev" apply false - id("scientifik.publish") version "0.1.4-dev" apply false + id("scientifik.mpp") version "0.1.4" apply false + id("scientifik.publish") version "0.1.4" apply false } val dataforgeVersion by extra("0.1.3-dev-10") diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Config.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Config.kt index 07ce8f96..f47d3bcd 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Config.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/Config.kt @@ -7,6 +7,11 @@ import hep.dataforge.names.plus //TODO add validator to configuration +data class MetaListener( + val owner: Any? = null, + val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit +) + /** * Mutable meta representing object state */ diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt index 0b5c83d6..f79fed07 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MetaBuilder.kt @@ -1,5 +1,6 @@ package hep.dataforge.meta +import hep.dataforge.names.Name import hep.dataforge.names.asName import hep.dataforge.values.Value @@ -28,6 +29,25 @@ class MetaBuilder : AbstractMutableMeta() { infix fun String.to(metaBuilder: MetaBuilder.() -> Unit) { this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder) } + + infix fun Name.to(value: Any) { + if (value is Meta) { + this@MetaBuilder[this] = value + } + this@MetaBuilder[this] = Value.of(value) + } + + infix fun Name.to(meta: Meta) { + this@MetaBuilder[this] = meta + } + + infix fun Name.to(value: Iterable) { + this@MetaBuilder[this] = value.toList() + } + + infix fun Name.to(metaBuilder: MetaBuilder.() -> Unit) { + this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder) + } } /** diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableMeta.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableMeta.kt index b9ab6f62..285edd89 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/MutableMeta.kt @@ -3,12 +3,6 @@ package hep.dataforge.meta import hep.dataforge.names.* import hep.dataforge.values.Value -internal data class MetaListener( - val owner: Any? = null, - val action: (name: Name, oldItem: MetaItem<*>?, newItem: MetaItem<*>?) -> Unit -) - - interface MutableMeta> : MetaNode { override val items: Map> operator fun set(name: Name, item: MetaItem<*>?)