This documentation is under development!

dlite-datamodel

dlite-datamodel#

Direct access to data model for an entity instance in a storage.

The dlite datamodel provides low level access to the data stored in an entity. You do normally not call the functions defined in this header file if you access data via the interface defined in dlite-entity.h or generated by the dlite code generator.

Minimum API

Minimum API that all plugins should implement.

DLiteDataModel *dlite_datamodel(const DLiteStorage *s, const char *id)#

Returns a new data model for instance id in storage s or NULL on error. Should be free’ed with dlite_datamodel_free().

int dlite_datamodel_free(DLiteDataModel *d)#

Frees up all resources allocated by dlite_datamodel().

char *dlite_datamodel_get_meta_uri(const DLiteDataModel *d)#

Returns newly malloc()’ed string with the metadata uri or NULL on error.

void dlite_datamodel_resolve_dimensions(DLiteDataModel *d, const DLiteMeta *meta)#

Resolve dimensions

int dlite_datamodel_get_dimension_size(const DLiteDataModel *d, const char *name)#

Returns the size of dimension name or -1 on error.

int dlite_datamodel_get_property(const DLiteDataModel *d, const char *name, void *ptr, DLiteType type, size_t size, size_t ndims, const size_t *shape)#

Copies property name to memory pointed to by ptr. Multi-dimensional arrays are supported.

Returns non-zero on error.

Note

The memory pointed to by ptr must be at least of size

size * shape[0] * ... * shape[ndim-1]
In contrast to the other data types, getting data of DTStringPtr type only writes (char *) pointers to the actual strings in memory pointed to ptr. The strings themself are allocated on the heap (using malloc()). Hence, the user is responsible to free this memory herselves.

Parameters
  • d – DLiteDataModel data handle.

  • name – Name of the property.

  • ptr – Pointer to memory to write to.

  • type – Type of data elements.

  • size – Size of each data element.

  • ndims – Number of dimensions.

  • shape – Array of dimension sizes of length ndims.

Optional API

Optional API that plugins are free leave unimplemented.

The plugin must provide dlite_datamodel_set_property(), dlite_datamodel_set_meta_uri() and dlite_datamodel_set_dimension_size() to support writing, otherwise only read is supported.

All functions below are supported by the HDF5 plugin.

int dlite_datamodel_set_property(DLiteDataModel *d, const char *name, const void *ptr, DLiteType type, size_t size, size_t ndims, const size_t *shape)#

Sets property name to the memory (of size bytes) pointed to by value. The argument string_pointers has the same meaning as for dlite_datamodel_get_property().

Returns non-zero on error.

int dlite_datamodel_set_meta_uri(DLiteDataModel *d, const char *uri)#

Sets metadata uri. Returns non-zero on error.

int dlite_datamodel_set_dimension_size(DLiteDataModel *d, const char *name, size_t size)#

Sets size of dimension name. Returns non-zero on error.

int dlite_datamodel_has_dimension(DLiteDataModel *d, const char *name)#

Returns a positive value if dimension name is defined, zero if it isn’t and a negative value on error (e.g. if this function isn’t supported by the plugin).

int dlite_datamodel_has_property(DLiteDataModel *d, const char *name)#

Returns a positive value if property name is defined, zero if it isn’t and a negative value on error (e.g. if this function isn’t supported by the plugin).

char *dlite_datamodel_get_dataname(DLiteDataModel *d)#

If the uuid was generated from a unique name, return a pointer to a newly malloc’ed string with this name. Otherwise NULL is returned.

Unnamed Group

int dlite_copy_to_flat(void *dst, const void *src, size_t size, size_t ndims, const size_t *shape)#

Utility functions intended to be used by the plugins Copies data from nested pointer to pointers array src to the flat continuous C-ordered array dst. The size of dest must be sufficient large. Returns non-zero on error.

int dlite_copy_to_nested(void *dst, const void *src, size_t size, size_t ndims, const size_t *shape)#

Copies data from flat continuous C-ordered array src to nested pointer to pointers array dst. The size of dest must be sufficient large. Returns non-zero on error.

Typedefs

typedef struct _DLiteDataModel DLiteDataModel#

Opaque type for a DLiteDataModel.

A data model refers to a specific instance of an entity in a storage.