RAVE
rave_attribute.c File Reference

Defines the functions available when working with polar scans. More...

#include "rave_attribute.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include "rave_object.h"
#include "rave_datetime.h"
#include "rave_transform.h"
#include "raveobject_hashtable.h"
#include "rave_data2d.h"
#include <errno.h>

Classes

struct  _RaveAttribute_t
 Represents one scan in a volume. More...
 

Macros

#define DEFAULT_PARAMETER_NAME   "DBZH"
 This is the default parameter value that should be used when working with scans.
 

Functions

int RaveAttribute_setName (RaveAttribute_t *attr, const char *name)
 Sets the name of this attribute.
 
const char * RaveAttribute_getName (RaveAttribute_t *attr)
 Returns the name of this attribute.
 
RaveAttribute_Format RaveAttribute_getFormat (RaveAttribute_t *attr)
 Returns the format for this attribute.
 
void RaveAttribute_setLong (RaveAttribute_t *attr, long value)
 Sets the value as a long.
 
void RaveAttribute_setDouble (RaveAttribute_t *attr, double value)
 Sets the value as a double.
 
int RaveAttribute_setString (RaveAttribute_t *attr, const char *value)
 Sets the value as a string.
 
int RaveAttribute_setLongArray (RaveAttribute_t *attr, long *value, int len)
 Sets the value as a simple 1-dimensional long array.
 
int RaveAttribute_setDoubleArray (RaveAttribute_t *attr, double *value, int len)
 Sets the value as a simple 1-dimensional double array.
 
int RaveAttribute_setArrayFromData (RaveAttribute_t *attr, void *value, int len, RaveDataType type)
 Sets the attribute with the array from the provided data with the specified type and converts it into an appropriate array type.
 
int RaveAttribute_getLong (RaveAttribute_t *attr, long *value)
 Returns the value as a long.
 
int RaveAttribute_getDouble (RaveAttribute_t *attr, double *value)
 Returns the value as a double.
 
int RaveAttribute_getString (RaveAttribute_t *attr, char **value)
 Returns the value as a string.
 
int RaveAttribute_getLongArray (RaveAttribute_t *attr, long **value, int *len)
 Returns the value as a long array.
 
int RaveAttribute_getDoubleArray (RaveAttribute_t *attr, double **value, int *len)
 Returns the value as a double array.
 
int RaveAttribute_shiftArray (RaveAttribute_t *attr, int nx)
 Performs a circular shift of the array.
 
int RaveAttributeHelp_extractGroupAndName (const char *attrname, char **group, char **name)
 Helper function for extracting the group and name part from a string with the format <group>/<name>.
 
int RaveAttributeHelp_validateHowGroupAttributeName (const char *gname, const char *aname)
 Validates an attribute name that resides in a how-main group.
 
RaveAttribute_tRaveAttributeHelp_createNamedAttribute (const char *name)
 Creates a named rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createLong (const char *name, long value)
 Creates a long rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createDouble (const char *name, double value)
 Creates a double rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createDoubleFromString (const char *name, const char *value)
 Creates a double rave attribute from a string representation of the double value.
 
RaveAttribute_tRaveAttributeHelp_createString (const char *name, const char *value)
 Creates a string rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createLongArray (const char *name, long *value, int len)
 Creates a long array rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createDoubleArray (const char *name, double *value, int len)
 Creates a double array rave attribute.
 
RaveAttribute_tRaveAttributeHelp_createArrayFromData (const char *name, void *value, int len, RaveDataType type)
 Creates an array from the provided data with the specified type and converts it into an appropriate array type.
 

Variables

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

Detailed Description

Defines the functions available when working with polar scans.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-10-15

Macro Definition Documentation

◆ DEFAULT_PARAMETER_NAME

#define DEFAULT_PARAMETER_NAME   "DBZH"

This is the default parameter value that should be used when working with scans.

Function Documentation

◆ RaveAttribute_getDouble()

int RaveAttribute_getDouble ( RaveAttribute_t * attr,
double * value )

Returns the value as a double.

Parameters
[in]attr- self
[out]value- the double value
Returns
1 on success or 0 if format of the data not is a double

◆ RaveAttribute_getDoubleArray()

int RaveAttribute_getDoubleArray ( RaveAttribute_t * attr,
double ** value,
int * len )

Returns the value as a double array.

Parameters
[in]attr- self
[out]value- the internal double array, DO NOT RELEASE memory
[out]len- the number of values in the array
Returns
1 on success or 0 if format of the data not is a double array

◆ RaveAttribute_getFormat()

RaveAttribute_Format RaveAttribute_getFormat ( RaveAttribute_t * attr)

Returns the format for this attribute.

Parameters
[in]attr- self
Returns
the format

◆ RaveAttribute_getLong()

int RaveAttribute_getLong ( RaveAttribute_t * attr,
long * value )

Returns the value as a long.

Parameters
[in]attr- self
[out]value- the long value
Returns
1 on success or 0 if format of the data not is a long

◆ RaveAttribute_getLongArray()

int RaveAttribute_getLongArray ( RaveAttribute_t * attr,
long ** value,
int * len )

Returns the value as a long array.

Parameters
[in]attr- self
[out]value- the internal long array, DO NOT RELEASE memory
[out]len- the number of values in the array
Returns
1 on success or 0 if format of the data not is a long array

◆ RaveAttribute_getName()

const char * RaveAttribute_getName ( RaveAttribute_t * attr)

Returns the name of this attribute.

Parameters
[in]attr- self
Returns
the name of this attribute

◆ RaveAttribute_getString()

int RaveAttribute_getString ( RaveAttribute_t * attr,
char ** value )

Returns the value as a string.

Parameters
[in]attr- self
[out]value- the internal 0-terminated string, DO NOT RELEASE memory
Returns
1 on success or 0 if format of the data not is a string

◆ RaveAttribute_setArrayFromData()

int RaveAttribute_setArrayFromData ( RaveAttribute_t * attr,
void * value,
int len,
RaveDataType type )

Sets the attribute with the array from the provided data with the specified type and converts it into an appropriate array type.

Parameters
[in]attr- self
[in]name- the name of the attribute
[in]value- the data
[in]len- the number of items in the array
[in]type- the data type
Returns
1 on success otherwise 0

◆ RaveAttribute_setDouble()

void RaveAttribute_setDouble ( RaveAttribute_t * attr,
double value )

Sets the value as a double.

Parameters
[in]attr- self
[in]value- the value

◆ RaveAttribute_setDoubleArray()

int RaveAttribute_setDoubleArray ( RaveAttribute_t * attr,
double * value,
int len )

Sets the value as a simple 1-dimensional double array.

Parameters
[in]attr- self
[in]value- the value
[in]len- the number of doubles in the array
Returns
1 on success otherwise 0

◆ RaveAttribute_setLong()

void RaveAttribute_setLong ( RaveAttribute_t * attr,
long value )

Sets the value as a long.

Parameters
[in]attr- self
[in]value- the value

◆ RaveAttribute_setLongArray()

int RaveAttribute_setLongArray ( RaveAttribute_t * attr,
long * value,
int len )

Sets the value as a simple 1-dimensional long array.

Parameters
[in]attr- self
[in]value- the value
[in]len- the number of longs in the array
Returns
1 on success otherwise 0

◆ RaveAttribute_setName()

int RaveAttribute_setName ( RaveAttribute_t * attr,
const char * name )

Sets the name of this attribute.

Parameters
[in]attr- self
[in]name- the name this attribute should have
Returns
1 on success otherwise 0

◆ RaveAttribute_setString()

int RaveAttribute_setString ( RaveAttribute_t * attr,
const char * value )

Sets the value as a string.

Parameters
[in]attr- self
[in]value- the value
Returns
1 on success otherwise 0

◆ RaveAttribute_shiftArray()

int RaveAttribute_shiftArray ( RaveAttribute_t * attr,
int nx )

Performs a circular shift of the array.

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]attr- 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.

◆ RaveAttributeHelp_createArrayFromData()

RaveAttribute_t * RaveAttributeHelp_createArrayFromData ( const char * name,
void * value,
int len,
RaveDataType type )

Creates an array from the provided data with the specified type and converts it into an appropriate array type.

Parameters
[in]name- the name of the attribute
[in]value- the data
[in]len- the number of items in the array
[in]type- the data type
Returns
a rave attribute on success otherwise NULL

◆ RaveAttributeHelp_createDouble()

RaveAttribute_t * RaveAttributeHelp_createDouble ( const char * name,
double value )

Creates a double rave attribute.

Parameters
[in]name- the name of the attribute
[in]value- the double
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createDoubleArray()

RaveAttribute_t * RaveAttributeHelp_createDoubleArray ( const char * name,
double * value,
int len )

Creates a double array rave attribute.

Parameters
[in]name- the name of the attribute
[in]value- the double array
[in]len- the length of the array
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createDoubleFromString()

RaveAttribute_t * RaveAttributeHelp_createDoubleFromString ( const char * name,
const char * value )

Creates a double rave attribute from a string representation of the double value.

Parameters
[in]name- the name of the attribute
[in]value- the double
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createLong()

RaveAttribute_t * RaveAttributeHelp_createLong ( const char * name,
long value )

Creates a long rave attribute.

Parameters
[in]name- the name of the attribute
[in]value- the long
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createLongArray()

RaveAttribute_t * RaveAttributeHelp_createLongArray ( const char * name,
long * value,
int len )

Creates a long array rave attribute.

Parameters
[in]name- the name of the attribute
[in]value- the long array
[in]len- the length of the array
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createNamedAttribute()

RaveAttribute_t * RaveAttributeHelp_createNamedAttribute ( const char * name)

Creates a named rave attribute.

Parameters
[in]name- the name of the attribute
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_createString()

RaveAttribute_t * RaveAttributeHelp_createString ( const char * name,
const char * value )

Creates a string rave attribute.

Parameters
[in]name- the name of the attribute
[in]value- the string
Returns
the attribute on success otherwise NULL

◆ RaveAttributeHelp_extractGroupAndName()

int RaveAttributeHelp_extractGroupAndName ( const char * attrname,
char ** group,
char ** name )

Helper function for extracting the group and name part from a string with the format <group>/<name>.

Parameters
[in]attrname- the string that should get group and name extracted
[out]group- the group name (allocated memory so free it)
[out]name- the attr name (allocated memory so free it)
Returns
1 on success otherwise 0

◆ RaveAttributeHelp_validateHowGroupAttributeName()

int RaveAttributeHelp_validateHowGroupAttributeName ( const char * gname,
const char * aname )

Validates an attribute name that resides in a how-main group.

This will validate that it may exists sub groups and that this name is valid. gname should be how, then aname is the trailing part For example: gname=how, aname=attribute gname=how, aname=subgroup1/attribute gname=how, aname=subgroup1/subgroup2/attribute are all valid names.

Parameters
[in]gname- should always be how
[in]aname- the rest of the name as described above.
Returns
1 on success otherwise 0

Variable Documentation

◆ RaveAttribute_TYPE

RaveCoreObjectType RaveAttribute_TYPE
Initial value:
= {
"RaveAttribute",
sizeof(RaveAttribute_t),
RaveAttribute_constructor,
RaveAttribute_destructor,
RaveAttribute_copyconstructor
}
struct _RaveAttribute_t RaveAttribute_t
Defines a rave attribute.
Definition rave_attribute.h:43

Type definition to use when creating a rave object.