6 "A data type component with component name and data type"
\r
7 @JavaType "org.simantics.databoard.type.Component"
\r
8 @FieldNames [name, "type"]
\r
9 data DatatypeComponent = DatatypeComponent String Datatype
\r
11 """A data type that represents the data types supported by the Simantics
\r
12 Databoard plugin."""
\r
13 @JavaType "org.simantics.databoard.type.Datatype"
\r
15 @JavaType "org.simantics.databoard.type.BooleanType"
\r
17 | @JavaType "org.simantics.databoard.type.ByteType"
\r
19 | @JavaType "org.simantics.databoard.type.IntegerType"
\r
21 | @JavaType "org.simantics.databoard.type.LongType"
\r
23 | @JavaType "org.simantics.databoard.type.FloatType"
\r
25 | @JavaType "org.simantics.databoard.type.DoubleType"
\r
27 | @JavaType "org.simantics.databoard.type.StringType"
\r
29 | @JavaType "org.simantics.databoard.type.ArrayType"
\r
30 @FieldNames [componentType]
\r
32 | @JavaType "org.simantics.databoard.type.OptionalType"
\r
33 @FieldNames [componentType]
\r
34 OptionalType Datatype
\r
35 | @JavaType "org.simantics.databoard.type.MapType"
\r
36 @FieldNames [keyType, valueType]
\r
37 MapType Datatype Datatype
\r
38 | @JavaType "org.simantics.databoard.type.RecordType"
\r
39 @FieldNames [components]
\r
40 RecordType (Vector DatatypeComponent)
\r
41 | @JavaType "org.simantics.databoard.type.UntionType"
\r
42 @FieldNames [components]
\r
43 UnionType (Vector DatatypeComponent)
\r
44 | @JavaType "org.simantics.databoard.type.VariantType"
\r
47 importJava "org.simantics.databoard.type.Datatype" where
\r
50 showDatatype :: Datatype -> String
\r
52 "Get the number of type components in an data type"
\r
53 @JavaName getComponentCount
\r
54 datatypeCompnentCount :: Datatype -> Integer
\r
56 "Get a component type of a composite data type"
\r
57 @JavaName getComponentType
\r
58 datatypeComponentType :: Datatype -> ChildReference -> Datatype
\r
62 datatypeEquals :: Datatype -> Datatype -> Boolean
\r
64 instance Show Datatype where
\r
67 instance Eq Datatype where
\r
68 (==) = datatypeEquals
\r
72 importJava "org.simantics.databoard.binding.Binding" where
\r
73 "Check whether a dynamic object is an instance of a given binding"
\r
74 @JavaName isInstance
\r
75 isBindingInstance :: Binding Dynamic -> Dynamic -> Boolean
\r
77 "Create a serializable object from a textual representation"
\r
78 parseValueDefinition :: Serializable a => String -> a
\r
80 "Compare two serializable objects\n\nResult is -1, 0 or 1 depending the partial ordering of the objects."
\r
82 compareObjects :: Serializable a => a -> a -> Integer
\r
84 "Return true, if two serializable values are equal"
\r
86 serializableEq :: Serializable a => a -> a -> Boolean
\r
88 "The default value of a serializable type"
\r
89 @JavaName createDefault
\r
90 serializableDefaultValue :: Serializable a => a
\r
92 "Create a random value of a serializable type"
\r
93 @JavaName createRandom
\r
94 serializableRandomValue :: Serializable a => <Random> a
\r
96 "Get a textual representation of a serializable value"
\r
98 showSerializable :: Serializable a => a -> String
\r
101 @JavaName getComponent
\r
102 getSerializableComponent_ :: Serializable a => a -> ChildReference -> Binding b -> b
\r
104 "Get a component binding"
\r
105 @JavaName getComponentBinding
\r
106 getComponentBinding :: Binding a -> ChildReference -> Binding b
\r
110 bindingEquals :: Binding a -> Binding a -> Boolean
\r
112 instance Eq (Binding a) where
\r
113 (==) = bindingEquals
\r
115 "Get a child data component of a composite serializable value"
\r
116 getSerializableComponent :: Serializable a => Serializable b => a -> ChildReference -> b
\r
117 getSerializableComponent object ref = getSerializableComponent_ object ref binding
\r
121 importJava "org.simantics.databoard.serialization.Serializer" where
\r
122 "A data serializer for SCL type a"
\r
126 @JavaName "serialize"
\r
127 serialize_ :: Serializer a -> a -> ByteArray
\r
130 @JavaName "deserialize"
\r
131 deserialize_ :: Serializer a -> ByteArray -> a
\r
133 importJava "org.simantics.databoard.Bindings" where
\r
135 @JavaName "getSerializer"
\r
136 serializerOf :: Binding a -> Serializer a
\r
140 bindingToString :: Binding a -> String
\r
142 "Adapt between types using explicitly provided binding objects: `adapt_ value from to`"
\r
144 adapt_ :: a -> Binding a -> Binding b -> b
\r
146 "Adapt value from one serializable type to another"
\r
147 adapt :: Serializable a => Serializable b => a -> b
\r
148 adapt x = adapt_ x binding binding
\r
150 instance Show (Binding a) where
\r
151 show = bindingToString
\r
153 "Serializes a value to a byte array using default serializer."
\r
154 serialize :: Serializable a => a -> ByteArray
\r
155 serialize v = serialize_ (serializerOf binding) v
\r
157 "Deserializes a value from a byte array using default serializer."
\r
158 deserialize :: Serializable a => ByteArray -> a
\r
159 deserialize ba = deserialize_ (serializerOf binding) ba
\r
161 importJava "org.simantics.databoard.Bindings" where
\r
162 "Get a default binding for a given data type"
\r
163 @JavaName getBinding
\r
164 datatypeBinding :: Datatype -> Binding Dynamic
\r
166 importJava "org.simantics.databoard.Datatypes" where
\r
167 "Get a data type from a string representation"
\r
168 @JavaName translate
\r
169 translateDatatype :: String -> Datatype
\r
171 importJava "org.simantics.databoard.binding.mutable.Variant" where
\r
172 // data Variant (in Builtins)
\r
173 "Create a variant using an explicitly provided binding value (unchecked cast)"
\r
175 createVariant_ :: Binding Dynamic -> Dynamic -> Variant
\r
177 "Get the data type of a variant object"
\r
179 variantDatatype :: Variant -> Datatype
\r
181 "Get raw value contained by a variant (unchecked cast)"
\r
183 rawVariantValue :: Variant -> a
\r
185 "Create a variant from a raw object (based on Java class)"
\r
186 @JavaName ofInstance
\r
187 variantOf :: a -> Variant
\r
189 "Create a variant with explicitly provided binding and value"
\r
191 variant_ :: Binding a -> a -> Variant
\r
193 "Get value from a variant using a given binding"
\r
195 variantValue_ :: Variant -> Binding a -> a
\r
199 showVariant :: Variant -> String
\r
201 "Get a component of compound data value in a variant"
\r
202 @JavaName getComponent
\r
203 variantComponent :: Variant -> ChildReference -> Variant
\r
205 "Create a variant of a given data type from an object in the default binding (unchecked, use with extreme caution)"
\r
206 createVariant :: Datatype -> Dynamic -> Variant
\r
207 createVariant dt v = createVariant_ (datatypeBinding dt) v
\r
209 "Create a variant from a serializable value"
\r
210 variant :: Serializable a => a -> Variant
\r
211 variant v = variant_ binding v
\r
213 "Get the value of a variant in a serializable type"
\r
214 variantValue :: Serializable a => Variant -> a
\r
215 variantValue v = variantValue_ v binding
\r
217 instance Show Variant where
\r
220 "Get an element of a compound variant value using an index reference"
\r
221 variantElement :: Serializable a => Variant -> Integer -> a
\r
222 variantElement v i = variantValue (variantComponent v (indexReference i))
\r
224 importJava "org.simantics.databoard.accessor.reference.ChildReference" where
\r
225 "A reference to a child element in a composite data type/binding or value"
\r
226 data ChildReference
\r
228 "Combine a list of child data object references into a single path reference"
\r
230 compileReference :: [ChildReference] -> ChildReference
\r
232 importJava "org.simantics.databoard.accessor.reference.IndexReference" where
\r
233 """Get a reference to a child data object using an index (zero-based)
\r
234 * Element index of an array object
\r
235 * Field index of a record or union type
\r
237 * Key component of a map type/binding
\r
238 * Component of any single-component type/binding (optional, array)
\r
239 * Contained value/type of any single-element object (optional, union, variant)
\r
241 * Value component of a map type/binding
\r
244 indexReference :: Integer -> ChildReference
\r
246 importJava "org.simantics.databoard.accessor.reference.KeyReference" where
\r
247 """Get a reference to a MapType child data object using a given key value
\r
248 * Contained value of a map object for a given key value
\r
251 keyReference :: Variant -> ChildReference
\r
253 importJava "org.simantics.databoard.accessor.reference.NameReference" where
\r
254 """Get a reference to a child data object using a field name
\r
255 * A component name of a record or union data type/binding
\r
256 * "key": The key component of a map data type/binding
\r
257 * "value": The value component of a map data type/binding
\r
260 nameReference :: String -> ChildReference
\r
262 importJava "org.simantics.databoard.accessor.reference.LabelReference" where
\r
263 """Get a reference to a child data object using a label
\r
264 * A component name of a record or union data type/binding
\r
265 * A string representation of the index of a record or union data type/binding component
\r
266 * "v": The component type of an array/optional data type/binding
\r
267 * "0"/"key": The key component of a map data type/binding
\r
268 * "1"/"value": The value component of a map data type/binding
\r
271 labelReference :: String -> ChildReference
\r
273 importJava "org.simantics.databoard.accessor.reference.ComponentReference" where
\r
274 """Get a reference to a component child data object
\r
275 * Component of an array/optional data type/binding
\r
276 * Contained value of an optional/variant/union object
\r
279 componentReference :: ChildReference
\r