smax-clib v0.9
A C/C++ client library for SMA-X
|
A set of utility functions for manipulating optional static metadata. More...
Functions | |
XCoordinateSystem * | smaxCreateCoordinateSystem (int nAxis) |
void | smaxDestroyCoordinateSystem (XCoordinateSystem *coords) |
XCoordinateAxis * | smaxGetCoordinateAxis (const char *id, int n) |
XCoordinateSystem * | smaxGetCoordinateSystem (const char *table, const char *key) |
char * | smaxGetDescription (const char *table, const char *key) |
char * | smaxGetUnits (const char *table, const char *key) |
char * | smaxPullMeta (const char *meta, const char *table, const char *key, int *status) |
double | smaxPullTime (const char *table, const char *key) |
XType | smaxPullTypeDimension (const char *table, const char *key, int *ndim, int *sizes) |
int | smaxPushMeta (const char *meta, const char *table, const char *key, const char *value) |
int | smaxSetCoordinateAxis (const char *id, int n, const XCoordinateAxis *axis) |
int | smaxSetCoordinateSystem (const char *table, const char *key, const XCoordinateSystem *coords) |
int | smaxSetDescription (const char *table, const char *key, const char *description) |
int | smaxSetUnits (const char *table, const char *key, const char *unit) |
A set of utility functions for manipulating optional static metadata.
XCoordinateSystem * smaxCreateCoordinateSystem | ( | int | nAxis | ) |
Creates a coordinate system with the desired dimension, and standard Cartesian coordinates with no labels, or units specified (NULL).
nAxis | Dimension of the coordiante system, i.e. number of axes. |
References XCoordinateSystem::axis, XCoordinateSystem::nAxis, XCoordinateAxis::step, x_error(), and X_MAX_DIMS.
void smaxDestroyCoordinateSystem | ( | XCoordinateSystem * | coords | ) |
Deallocates a coordinate system structure.
coords | Pointer to the coordinate system to discard. |
References XCoordinateSystem::axis.
XCoordinateAxis * smaxGetCoordinateAxis | ( | const char * | id, |
int | n | ||
) |
Returns the n'th coordinate axis for a given SMA-X coordinate system table id.
id | Fully qualified SMA-X coordinate system ID. |
n | The (0-based) index of the coordinate axis |
References RedisEntry::key, XCoordinateAxis::name, redisxGetTable(), XCoordinateAxis::refIndex, XCoordinateAxis::refValue, smaxError(), smaxGetRedis(), XCoordinateAxis::step, XCoordinateAxis::unit, RedisEntry::value, x_error(), X_NO_INIT, x_trace_null(), and xGetAggregateID().
XCoordinateSystem * smaxGetCoordinateSystem | ( | const char * | table, |
const char * | key | ||
) |
Returns the coordinate system, if any, associated to a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
References XCoordinateSystem::axis, META_COORDS, XCoordinateSystem::nAxis, smaxGetCoordinateAxis(), X_MAX_DIMS, x_trace_null(), and xGetAggregateID().
char * smaxGetDescription | ( | const char * | table, |
const char * | key | ||
) |
Returns a concise description of a variable.
table | Hash table name. |
key | Variable / field name in table. |
References META_DESCRIPTION, smaxPullMeta(), X_SUCCESS, and x_trace_null().
char * smaxGetUnits | ( | const char * | table, |
const char * | key | ||
) |
Returns the physical unit name, if any, for the given variable.
table | Hash table name. |
key | Variable / field name in table. |
References META_UNIT, smaxPullMeta(), X_SUCCESS, and x_trace_null().
char * smaxPullMeta | ( | const char * | meta, |
const char * | table, | ||
const char * | key, | ||
int * | status | ||
) |
Retrieves a metadata string value for a given variable from the database
meta | Root meta table name, usually something like "<metaname>". |
table | Hash table name. |
key | Variable / field name in table. |
status | Pointer to int in which to return a X_SUCCESS or an error code. |
References redisxGetStringValue(), smaxError(), smaxGetRedis(), x_error(), X_GROUP_INVALID, X_NO_INIT, x_trace_null(), and xGetAggregateID().
double smaxPullTime | ( | const char * | table, |
const char * | key | ||
) |
Retrieves the timestamp for a given variable from the database.
[in] | table | Hash table name (or NULL if key is an aggregate ID). |
[in] | key | Variable / field name in table. |
References NAN, SMAX_TIMESTAMPS, smaxPullMeta(), x_error(), and x_trace_null().
XType smaxPullTypeDimension | ( | const char * | table, |
const char * | key, | ||
int * | ndim, | ||
int * | sizes | ||
) |
Retrieves the timestamp for a given variable from the database.
[in] | table | Hash table name (or NULL if key is an aggregate ID). |
[in] | key | Variable / field name in table. |
[out] | ndim | Pointer to integer in which to return the dimensionality of the variable, or NULL if not requested. |
[out] | sizes | Array to store sizes along each dimension, which should hold X_MAX_DIMS integers, or NULL if dimensions are not requested. |
References SMAX_DIMS, SMAX_TYPES, smaxPullMeta(), smaxTypeForString(), x_trace(), X_UNKNOWN, and xParseDims().
int smaxPushMeta | ( | const char * | meta, |
const char * | table, | ||
const char * | key, | ||
const char * | value | ||
) |
Adds/updates metadata associated with an SMA-X variable. The data will be pushed via the Redis pipeline channel.
meta | Root meta table name, usually something like "<metaname>". |
table | Hash table name. |
key | Variable / field name in table. |
value | Metadata string value. |
References FALSE, redisxNotify(), redisxSetValue(), smaxError(), smaxGetProgramID(), smaxGetRedis(), x_error(), X_GROUP_INVALID, X_INCOMPLETE, X_NO_INIT, X_NULL, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxSetCoordinateAxis | ( | const char * | id, |
int | n, | ||
const XCoordinateAxis * | axis | ||
) |
Defines the n'th coordinate axis for a given SMA-X coordinate system table id.
id | Fully qualified SMA-X coordinate system ID. |
n | The (0-based) index of the coordinate axis |
axis | Pointer to the structure describing the coordinate axis. |
References FALSE, RedisEntry::key, XCoordinateAxis::name, redisxMultiSet(), XCoordinateAxis::refIndex, XCoordinateAxis::refValue, smaxGetRedis(), XCoordinateAxis::step, XCoordinateAxis::unit, RedisEntry::value, X_FAILURE, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxSetCoordinateSystem | ( | const char * | table, |
const char * | key, | ||
const XCoordinateSystem * | coords | ||
) |
Sets the coordinate system metadata for data in the database.
table | Hash table name. |
key | Variable / field name in table. |
coords | Pointer to the coordinate system structure associated to this variable. |
References XCoordinateSystem::axis, META_COORDS, XCoordinateSystem::nAxis, smaxSetCoordinateAxis(), X_NULL, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxSetDescription | ( | const char * | table, |
const char * | key, | ||
const char * | description | ||
) |
Sets the static description for a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
description | Concise but descriptive summary of the meaning of the variable. |
References META_DESCRIPTION, smaxPushMeta(), and X_SUCCESS.
int smaxSetUnits | ( | const char * | table, |
const char * | key, | ||
const char * | unit | ||
) |
Sets the physical unit name for a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
unit | Standard unit specification, e.g. "W / Hz" or "W Hz**{-1}". |
References META_UNIT, smaxPushMeta(), and X_SUCCESS.