RAVE
rave_attribute_table.h File Reference

Used for managing attributes and handle different versions. More...

#include "rave_object.h"
#include "raveobject_hashtable.h"
#include "rave_attribute.h"
#include "rave_types.h"

Go to the source code of this file.

Typedefs

typedef struct _RaveAttributeTable_t RaveAttributeTable_t
 Defines a attribute tablee.
 

Functions

int RaveAttributeTable_setVersion (RaveAttributeTable_t *self, RaveIO_ODIM_Version version)
 Sets the default version to use for the attribute tables.
 
RaveIO_ODIM_Version RaveAttributeTable_getVersion (RaveAttributeTable_t *self)
 Returns the default version to use for the attribute tables.
 
int RaveAttributeTable_addAttribute (RaveAttributeTable_t *self, RaveAttribute_t *attr, RaveAttribute_t **translation)
 Adds an attribute to the attribute table.
 
int RaveAttributeTable_addAttributeVersion (RaveAttributeTable_t *self, RaveAttribute_t *attr, RaveIO_ODIM_Version version, RaveAttribute_t **translation)
 Adds an attribute to the attribute table.
 
RaveAttribute_tRaveAttributeTable_getAttribute (RaveAttributeTable_t *self, const char *attrname)
 Returns an attribute from the attribute table according to default version.
 
RaveAttribute_tRaveAttributeTable_getAttributeVersion (RaveAttributeTable_t *self, const char *attrname, RaveIO_ODIM_Version version)
 Returns an attribute from the attribute table according to specified version.
 
int RaveAttributeTable_size (RaveAttributeTable_t *self)
 Returns the number of items in this table.
 
int RaveAttributeTable_hasAttribute (RaveAttributeTable_t *self, const char *key)
 Returns if the specified key exists or not.
 
RaveAttribute_tRaveAttributeTable_removeAttribute (RaveAttributeTable_t *self, const char *key)
 Removes the item with the specified key and returns it.
 
void RaveAttributeTable_clear (RaveAttributeTable_t *self)
 Clears all entries in the table.
 
RaveList_tRaveAttributeTable_getAttributeNames (RaveAttributeTable_t *self)
 Returns the keys for the table at the current state.
 
RaveList_tRaveAttributeTable_getAttributeNamesVersion (RaveAttributeTable_t *self, RaveIO_ODIM_Version version)
 Returns the keys for the table at the current state.
 
RaveObjectList_tRaveAttributeTable_getValues (RaveAttributeTable_t *self)
 Returns the values for the table.
 
RaveObjectList_tRaveAttributeTable_getValuesVersion (RaveAttributeTable_t *self, RaveIO_ODIM_Version version)
 Returns the values for the table.
 
RaveObjectList_tRaveAttributeTable_getInternalValues (RaveAttributeTable_t *self)
 Returns the internal values for the table.
 
int RaveAttributeTable_shiftAttribute (RaveAttributeTable_t *self, const char *name, int nx)
 Performs a circular shift of an array attribute.
 
int RaveAttributeTable_shiftAttributeIfExists (RaveAttributeTable_t *self, const char *name, int nx)
 Performs a circular shift of an array attribute if it exists.
 
void RaveAttributeTable_destroyKeyList (RaveList_t *l)
 Helper function to destroy the returned list of keys.
 

Variables

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

Detailed Description

Used for managing attributes and handle different versions.

This object supports RAVE_OBJECT_CLONE.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2022-03-30

Typedef Documentation

◆ RaveAttributeTable_t

Defines a attribute tablee.

Function Documentation

◆ RaveAttributeTable_addAttribute()

int RaveAttributeTable_addAttribute ( RaveAttributeTable_t * self,
RaveAttribute_t * attr,
RaveAttribute_t ** translation )

Adds an attribute to the attribute table.

Parameters
[in]self- self
[in]attr- the attribute
[in,out]translation- if provided and attribute was translated somehow this attribute will be set. Remember to release.
Returns
1 on success

◆ RaveAttributeTable_addAttributeVersion()

int RaveAttributeTable_addAttributeVersion ( RaveAttributeTable_t * self,
RaveAttribute_t * attr,
RaveIO_ODIM_Version version,
RaveAttribute_t ** translation )

Adds an attribute to the attribute table.

Parameters
[in]self- self
[in]attr- the attribute
[in]version- the version of the attribute set
[in,out]translation- if provided and attribute was translated somehow this attribute will be set. Remember to release.
Returns
1 on success

◆ RaveAttributeTable_clear()

void RaveAttributeTable_clear ( RaveAttributeTable_t * self)

Clears all entries in the table.

Parameters
[in]self- the self

◆ RaveAttributeTable_destroyKeyList()

void RaveAttributeTable_destroyKeyList ( RaveList_t * l)

Helper function to destroy the returned list of keys.

Parameters
[in]l- the list to destroy

◆ RaveAttributeTable_getAttribute()

RaveAttribute_t * RaveAttributeTable_getAttribute ( RaveAttributeTable_t * self,
const char * attrname )

Returns an attribute from the attribute table according to default version.

Parameters
[in]self- self
[in]attrname- the attribute name
Returns
the attribute if found or if it could be derived from information in table, otherwise NULL

◆ RaveAttributeTable_getAttributeNames()

RaveList_t * RaveAttributeTable_getAttributeNames ( RaveAttributeTable_t * self)

Returns the keys for the table at the current state.

Note, remember to deallocate keys appropriately after retrival or use the function @ref RaveList_freeAndDestroy that will take care of it for you.

Parameters
[in]self- self
Returns
a list containing char* pointers.

◆ RaveAttributeTable_getAttributeNamesVersion()

RaveList_t * RaveAttributeTable_getAttributeNamesVersion ( RaveAttributeTable_t * self,
RaveIO_ODIM_Version version )

Returns the keys for the table at the current state.

Note, remember to deallocate keys appropriately after retrival or use the function @ref RaveList_freeAndDestroy that will take care of it for you.

Parameters
[in]self- self
[in]version- the version of the attribute names to return
Returns
a list containing char* pointers.

◆ RaveAttributeTable_getAttributeVersion()

RaveAttribute_t * RaveAttributeTable_getAttributeVersion ( RaveAttributeTable_t * self,
const char * attrname,
RaveIO_ODIM_Version version )

Returns an attribute from the attribute table according to specified version.

Parameters
[in]self- self
[in]attrname- the attribute name
[in]version- the version of the attribute to return
Returns
the attribute if found or if it could be derived from information in table, otherwise NULL

◆ RaveAttributeTable_getInternalValues()

RaveObjectList_t * RaveAttributeTable_getInternalValues ( RaveAttributeTable_t * self)

Returns the internal values for the table.

Note, it is not cloned values but references to them.

Parameters
[in]self- self
Returns
a list of values

◆ RaveAttributeTable_getValues()

RaveObjectList_t * RaveAttributeTable_getValues ( RaveAttributeTable_t * self)

Returns the values for the table.

Note, it is cloned values but references to them.

Parameters
[in]self- self
Returns
a list of values

◆ RaveAttributeTable_getValuesVersion()

RaveObjectList_t * RaveAttributeTable_getValuesVersion ( RaveAttributeTable_t * self,
RaveIO_ODIM_Version version )

Returns the values for the table.

Note, it is cloned values but references to them.

Parameters
[in]self- self
[in]version- the version of the attribute names to return
Returns
a list of values

◆ RaveAttributeTable_getVersion()

RaveIO_ODIM_Version RaveAttributeTable_getVersion ( RaveAttributeTable_t * self)

Returns the default version to use for the attribute tables.

Note, this does not affect the internally stored attributes. They will always be latest version regardless. This affects the attribute version when using the add & get without specifying version.

Parameters
[in]self- self
Returns
the default version

◆ RaveAttributeTable_hasAttribute()

int RaveAttributeTable_hasAttribute ( RaveAttributeTable_t * self,
const char * key )

Returns if the specified key exists or not.

Parameters
[in]table- self
[in]key- the key to search for
Returns
1 if the key exists, 0 if it doesn't

◆ RaveAttributeTable_removeAttribute()

RaveAttribute_t * RaveAttributeTable_removeAttribute ( RaveAttributeTable_t * self,
const char * key )

Removes the item with the specified key and returns it.

Parameters
[in]self- the self
[in]key- the key
Returns
the object (or NULL if none found)

◆ RaveAttributeTable_setVersion()

int RaveAttributeTable_setVersion ( RaveAttributeTable_t * self,
RaveIO_ODIM_Version version )

Sets the default version to use for the attribute tables.

Note, this does not affect the internally stored attributes. They will always be latest version regardless. This affects the attribute version when using the add & get without specifying version.

Parameters
[in]self- self
[in]version- the version
Returns
1 on success

◆ RaveAttributeTable_shiftAttribute()

int RaveAttributeTable_shiftAttribute ( RaveAttributeTable_t * self,
const char * name,
int nx )

Performs a circular shift of an array attribute.

if nx < 0, then shift is performed counter clockwise, if nx > 0, shift is performed clock wise, if 0, no shift is performed.

Parameters
[in]self- self
[in]name- attribute to shift
[in]nx- number of positions to shift return 1 if successful, 0 if trying to shift an attribute that isn't an array or an error occurs during shift.

◆ RaveAttributeTable_shiftAttributeIfExists()

int RaveAttributeTable_shiftAttributeIfExists ( RaveAttributeTable_t * self,
const char * name,
int nx )

Performs a circular shift of an array attribute if it exists.

if nx < 0, then shift is performed counter clockwise, if nx > 0, shift is performed clock wise, if 0, no shift is performed.

Parameters
[in]self- self
[in]name- attribute to shift
[in]nx- number of positions to shift return 1 if successful, 0 if trying to shift an attribute that isn't an array or an error occurs during shift.

◆ RaveAttributeTable_size()

int RaveAttributeTable_size ( RaveAttributeTable_t * self)

Returns the number of items in this table.

Parameters
[in]self- the self
Returns
the number of items in this table.

Variable Documentation

◆ RaveAttributeTable_TYPE

RaveCoreObjectType RaveAttributeTable_TYPE
extern

Type definition to use when creating a rave object.