RAVE
file_object.c File Reference

Defines a general file object. More...

#include "file_object.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include <stdio.h>

Classes

struct  _FileObject_t
 Represents the file object. More...
 

Functions

FileObject_tFileObject_createRoot (void)
 Creates the root group to get started.
 
int FileObjectInternal_areNamesSet (FileObject_t *self)
 
int FileObject_areNamesSet (FileObject_t *self)
 Verifies that all names are set in self and all child groups.
 
char * FileObject_toString (FileObject_t *self)
 Creates a string representation of the file object including subgroups and attributes.
 
void FileObject_setRestrictionMode (FileObject_t *self, FileObjectRestrictionMode mode)
 Sets a restriction mode on the file object structure.
 
FileObjectRestrictionMode FileObject_getRestrictionMode (FileObject_t *self)
 
FileObject_tFileObject_get (FileObject_t *self, const char *name)
 Gets the subgroup within self.
 
FileObject_tFileObject_getByIndex (FileObject_t *self, int index)
 Returns the sub group at specified index.
 
FileObject_tFileObject_create (FileObject_t *self, const char *name)
 Gets (or creates) the subgroup within self.
 
RaveData2D_tFileObject_getData (FileObject_t *self)
 
int FileObject_setData (FileObject_t *self, RaveData2D_t *data)
 
int FileObject_isDataset (FileObject_t *self)
 Returns if this group is a dataset node.
 
int FileObject_isDatasetLoaded (FileObject_t *self)
 Checks if the data 2d field has been set.
 
long FileObject_getDatasetX (FileObject_t *self)
 If this object is a dataset then this will return the xsize of the dataset.
 
long FileObject_getDatasetY (FileObject_t *self)
 If this object is a dataset then this will return the ysize of the dataset.
 
RaveDataType FileObject_getDatasetType (FileObject_t *self)
 If this object is a dataset then this will return the data type of the dataset.
 
int FileObject_setName (FileObject_t *self, const char *name)
 Sets the name of this file object.
 
const char * FileObject_getName (FileObject_t *self)
 
size_t FileObject_numberOfGroups (FileObject_t *self)
 
int FileObject_exists (FileObject_t *self, const char *name)
 
RaveObjectList_tFileObject_groups (FileObject_t *self)
 Returns the sub groups.
 
RaveValue_tFileObject_attributes (FileObject_t *self)
 Returns the attributes as a RaveValueHash.
 
int FileObject_addAttribute (FileObject_t *self, const char *name, RaveValue_t *value)
 Adds an attribute to this group.
 
int FileObject_setLazyDataset (FileObject_t *self, LazyDataset_t *lazyDataset)
 Sets a lazy dataset in the file object.
 

Variables

RaveCoreObjectType FileObject_TYPE
 Type definition to use when creating a rave object.
 

Detailed Description

Defines a general file object.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2025-12-17

Function Documentation

◆ FileObject_addAttribute()

int FileObject_addAttribute ( FileObject_t * self,
const char * name,
RaveValue_t * value )

Adds an attribute to this group.

Parameters
[in]self- self
[in]name- name of the attribute
[in]value- the value that should be added
Returns
1 on success otherwise 0

◆ FileObject_areNamesSet()

int FileObject_areNamesSet ( FileObject_t * self)

Verifies that all names are set in self and all child groups.

The root group is allowed to have an empty string as name. All childs must have a name != "".

Parameters
[in]self- self
Returns
1 if groups names are ok, otherwise 0

◆ FileObject_attributes()

RaveValue_t * FileObject_attributes ( FileObject_t * self)

Returns the attributes as a RaveValueHash.

Parameters
[in]self- self
Returns
the attributes belonging to this group

◆ FileObject_create()

FileObject_t * FileObject_create ( FileObject_t * self,
const char * name )

Gets (or creates) the subgroup within self.

Can specify more than one level of subgroup, for example it is allowed to call FileObject_get(self, "/this/that/group1"). Note, it is only group/dataset names that can be handled.

Parameters
[in]self- self
[in]name- name of group wanted
Returns
the file object instance if found/created otherwise NULL

◆ FileObject_createRoot()

FileObject_t * FileObject_createRoot ( void )

Creates the root group to get started.

Returns
the root group with name set to ""

◆ FileObject_exists()

int FileObject_exists ( FileObject_t * self,
const char * name )
Parameters
[in]self- self
[in]name- name of the node that should be checked for

◆ FileObject_get()

FileObject_t * FileObject_get ( FileObject_t * self,
const char * name )

Gets the subgroup within self.

Can specify more than one level of subgroup, for example it is allowed to call FileObject_get(self, "/this/that/group1"). Note, it is only group/dataset names that can be handled.

Parameters
[in]self- self
[in]name- name of group wanted
Returns
the file object instance if found otherwise NULL

◆ FileObject_getByIndex()

FileObject_t * FileObject_getByIndex ( FileObject_t * self,
int index )

Returns the sub group at specified index.

Parameters
[in]self- self
[in]index- index of group

◆ FileObject_getData()

RaveData2D_t * FileObject_getData ( FileObject_t * self)
Parameters
[in]self- self
Returns
the data 2d field if this group is a dataset

◆ FileObject_getDatasetType()

RaveDataType FileObject_getDatasetType ( FileObject_t * self)

If this object is a dataset then this will return the data type of the dataset.

Can be useful if lazy loading is used and data not loaded.

Parameters
[in]self- self
Returns
the datatype

◆ FileObject_getDatasetX()

long FileObject_getDatasetX ( FileObject_t * self)

If this object is a dataset then this will return the xsize of the dataset.

Can be useful if lazy loading is used and data not loaded.

Parameters
[in]self- self
Returns
the xsize

◆ FileObject_getDatasetY()

long FileObject_getDatasetY ( FileObject_t * self)

If this object is a dataset then this will return the ysize of the dataset.

Can be useful if lazy loading is used and data not loaded.

Parameters
[in]self- self
Returns
the ysize

◆ FileObject_getName()

const char * FileObject_getName ( FileObject_t * self)
Parameters
[in]self- self
Returns
the name of this file object

◆ FileObject_getRestrictionMode()

FileObjectRestrictionMode FileObject_getRestrictionMode ( FileObject_t * self)
Parameters
[in]self- self
Returns
the restriction mode

◆ FileObject_groups()

RaveObjectList_t * FileObject_groups ( FileObject_t * self)

Returns the sub groups.

Parameters
[in]self
Returns
the sub groups

◆ FileObject_isDataset()

int FileObject_isDataset ( FileObject_t * self)

Returns if this group is a dataset node.

Can either be that the data 2d field is set or that a lazy dataset instance has been set in this object

Parameters
[in]self- self
Returns
if this object is a dataset or not

◆ FileObject_isDatasetLoaded()

int FileObject_isDatasetLoaded ( FileObject_t * self)

Checks if the data 2d field has been set.

I.e. if lazy dataset has been set but not loaded, then this method will return 0

Parameters
[in]self- self
Returns
if dataset has been loaded or not

◆ FileObject_numberOfGroups()

size_t FileObject_numberOfGroups ( FileObject_t * self)
Parameters
[in]self- self
Returns
number of sub groups this file object has

◆ FileObject_setData()

int FileObject_setData ( FileObject_t * self,
RaveData2D_t * data )
Parameters
[in]self- self
[in]data- the 2d data field
Returns
1 on success otherwise 0

◆ FileObject_setLazyDataset()

int FileObject_setLazyDataset ( FileObject_t * self,
LazyDataset_t * lazyDataset )

Sets a lazy dataset in the file object.

Parameters
[in]self- self
[in]lazyDataset- the lazy dataset
Returns
1 on success otherwise 0

◆ FileObject_setName()

int FileObject_setName ( FileObject_t * self,
const char * name )

Sets the name of this file object.

Parameters
[in]self- self
[in]name- name of the file object. Must not contain '/'.
Returns
1 on success otherwise 0

◆ FileObject_setRestrictionMode()

void FileObject_setRestrictionMode ( FileObject_t * self,
FileObjectRestrictionMode mode )

Sets a restriction mode on the file object structure.

For example if specifying ODIM, then datasets are not allowed to contain subgroups.

Parameters
[in]self- self
[in]mode- the mode to use

◆ FileObject_toString()

char * FileObject_toString ( FileObject_t * self)

Creates a string representation of the file object including subgroups and attributes.

Arrays in attributes and dataset values are not displayed.

Parameters
[in]self- self
Returns
a string representation of self

Variable Documentation

◆ FileObject_TYPE

RaveCoreObjectType FileObject_TYPE
Initial value:
= {
"FileObject",
sizeof(FileObject_t),
FileObject_constructor,
FileObject_destructor,
FileObject_copyconstructor
}
struct _FileObject_t FileObject_t
Defines a general file object.
Definition file_object.h:44

Type definition to use when creating a rave object.