- removed functions with void *data in the interface
- added GetHdbProp
This commit is contained in:
118
hipadaba.h
118
hipadaba.h
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* Hipadaba is a hierarchical database of parameters. Parameters can be of
|
||||
* various types. What happens when a parameter is being set, updated or read
|
||||
* is largely determined through callbacks which can be registered on
|
||||
@ -46,16 +46,19 @@
|
||||
#define HDBTYPEMISMATCH -7701
|
||||
#define HDBLENGTHMISMATCH -7702
|
||||
/*===================== structure definitions ===================================*/
|
||||
typedef void voidFunc(void);
|
||||
|
||||
typedef struct __hdbValue {
|
||||
int dataType;
|
||||
int arrayLength;
|
||||
int doNotFree;
|
||||
union __value {
|
||||
int intValue;
|
||||
int intValue;
|
||||
double doubleValue;
|
||||
char *text;
|
||||
int *intArray;
|
||||
double *floatArray;
|
||||
voidFunc *func;
|
||||
void *obj;
|
||||
}v;
|
||||
}hdbValue;
|
||||
@ -90,7 +93,13 @@ typedef struct {
|
||||
char *type;
|
||||
void *callData;
|
||||
}hdbTreeChangeMessage, *pHdbTreeChangeMessage;
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
char *type;
|
||||
void *testPtr;
|
||||
void *result;
|
||||
}hdbDataSearch, *pHdbDataSearch;
|
||||
/*-------------------------------------------------------------------------------*/
|
||||
typedef hdbCallbackReturn (*hdbCallbackFunction)(pHdb currentNode,
|
||||
void *userData,
|
||||
pHdbMessage message);
|
||||
@ -105,13 +114,6 @@ typedef struct __hdbcallback {
|
||||
struct __hdbcallback *next;
|
||||
struct __hdbcallback *previous;
|
||||
}hdbCallback, *pHdbCallback;
|
||||
/*--------------- another message: must be here for seqeunce --------------------*/
|
||||
typedef struct {
|
||||
char *type;
|
||||
hdbCallbackFunction testFunc;
|
||||
void *testPtr;
|
||||
void *result;
|
||||
}hdbDataSearch, *pHdbDataSearch;
|
||||
/*============= Message Test Functions ==========================================*/
|
||||
/**
|
||||
* Test a message if it is a set message
|
||||
@ -146,17 +148,22 @@ pHdbTreeChangeMessage GetHdbTreeChangeMessage(pHdbMessage toTest);
|
||||
* pointer if it is.
|
||||
*/
|
||||
pHdbDataSearch GetHdbDataSearchMessage(pHdbMessage toTest);
|
||||
/*======================== Function protoypes: hdbData ========================*/
|
||||
hdbValue makeHdbValue(int datatype, int length);
|
||||
/**
|
||||
* make a hdbValue and initailize it with the data in the void
|
||||
* pointer. Do not initialise when data = NULL.
|
||||
* @param dataType The datatype of the hdbValue
|
||||
* @param The array length of the hdbValue
|
||||
* @param data Initialisation data for hdbValue
|
||||
* Test a message if it is a kill node message
|
||||
* @param toTest The message to test.
|
||||
* @return NULL if the message is no kill node message or a message
|
||||
* pointer if it is.
|
||||
*/
|
||||
pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest);
|
||||
/*======================== Function protoypes: hdbData ========================*/
|
||||
/**
|
||||
* make a hdbValue with the given datatype and length
|
||||
* Do not initialise
|
||||
* @param datatype The datatype of the hdbValue
|
||||
* @param length The array length of the hdbValue
|
||||
* @return a suitably defined hdbValue
|
||||
*/
|
||||
hdbValue makeHdbData(int datatype, int length, void *data);
|
||||
hdbValue makeHdbValue(int datatype, int length);
|
||||
/**
|
||||
* wrap an integer as an hdbValue
|
||||
* @param initValue the initial value of the int
|
||||
@ -198,6 +205,18 @@ hdbValue MakeHdbIntArray(int length, int *data);
|
||||
* @return: A properly initialized hdbValue structure
|
||||
*/
|
||||
hdbValue MakeHdbFloatArray(int length, double *data);
|
||||
/**
|
||||
* wrap a function as an hdbValue
|
||||
* @param func the function
|
||||
* @return: A properly initialized hdbValue structure
|
||||
*/
|
||||
hdbValue MakeHdbFunc(voidFunc *func);
|
||||
/**
|
||||
* wrap an object as an hdbValue
|
||||
* @param obj the object
|
||||
* @return: A properly initialized hdbValue structure
|
||||
*/
|
||||
hdbValue MakeHdbObj(void *obj);
|
||||
/**
|
||||
* release any dynamic memory associated with v
|
||||
* @param v The hdbValue to check for dynamic memory allocation to be
|
||||
@ -238,6 +257,7 @@ int getHdbValueLength(hdbValue v);
|
||||
* make a new hipadaba node
|
||||
* @param name The name of the new node
|
||||
* @param datatype The datatype of the new node
|
||||
* @param length the array length
|
||||
* @return a new node or NULL when out of memory
|
||||
*/
|
||||
pHdb MakeHipadabaNode(char *name, int datatype, int length);
|
||||
@ -256,7 +276,7 @@ void DeleteNodeData(pHdb node);
|
||||
/**
|
||||
* delete a hipadaba node and all its children. Then invoke the tree
|
||||
* change callback to notify listeners.
|
||||
* @parma node The node to delete
|
||||
* @param node The node to delete
|
||||
* @param callData User data for the tree change callback
|
||||
*/
|
||||
void DeleteHipadabaNode(pHdb node, void *callData);
|
||||
@ -282,7 +302,7 @@ pHdb GetHipadabaNode(pHdb root, char *path);
|
||||
char *GetHipadabaPath(pHdb node);
|
||||
/**
|
||||
* removes a node from the parents child list.
|
||||
* @node the node to remove
|
||||
* @param node the node to remove
|
||||
* @param callData User data for the tree change callback
|
||||
*/
|
||||
void RemoveHdbNodeFromParent(pHdb node, void *callData);
|
||||
@ -307,33 +327,27 @@ pHdbCallback MakeHipadabaCallback(hdbCallbackFunction func,
|
||||
/**
|
||||
* add a callback at the end of the callback chain
|
||||
* @param node The node to which to append the callback
|
||||
* @param type the type of the callback to append
|
||||
* @param newCB The callback to append
|
||||
*/
|
||||
void AppendHipadabaCallback(pHdb node,pHdbCallback newCB);
|
||||
/**
|
||||
* add a callback at the head of the callback chain
|
||||
* @param node The node to which to append the callback
|
||||
* @param type the type of the callback to append
|
||||
* @param newCB The callback prepend
|
||||
*/
|
||||
void PrependHipadabaCallback(pHdb node,pHdbCallback newCB);
|
||||
/**
|
||||
* find the callback data
|
||||
* @param node the node from where callbacks have to be searched
|
||||
* @param func the function registered with the searched callback
|
||||
* @param userPtr A pointer to some user data whih the callback
|
||||
* @param userPtr A pointer to some user data which the callback
|
||||
* uses to determine if it is the right one.
|
||||
* @return the found callback user data or NULL on failure
|
||||
*/
|
||||
void *FindHdbCallbackData(pHdb node,hdbCallbackFunction func,
|
||||
void *userPtr);
|
||||
void *FindHdbCallbackData(pHdb node, void *userPtr);
|
||||
/**
|
||||
* invoke a callback chain.
|
||||
* @param root The callback chain to invoke
|
||||
* @param node The node reposnible for this callback chain
|
||||
* @param callData Some data belonging to the callback
|
||||
* @param v The new value for this callback
|
||||
* @param node The node reponsible for this callback chain
|
||||
* @param message the message to send
|
||||
* @return 1 on success, 0 on failure
|
||||
*/
|
||||
int InvokeCallbackChain(pHdb node, pHdbMessage message);
|
||||
@ -384,42 +398,6 @@ int NotifyHipadabaPar(pHdb node,void *callData);
|
||||
* @return 0 on failure, 1 on success
|
||||
*/
|
||||
int GetHipadabaPar(pHdb node, hdbValue *v, void *callData);
|
||||
/**
|
||||
* Set a hipadaba parameter. This is an external set for a parameter. It may cause
|
||||
* motors to start driving etc.
|
||||
* @param node The node for which to set the parameter
|
||||
* param dataType The datatype the value ought to have
|
||||
* @param data A pointer to the data to set.
|
||||
* @param length The length of data
|
||||
* @param callData Additonal context data to be passed to the callback functions
|
||||
* @return 0 on failure, a negative error code on failure
|
||||
*/
|
||||
int SetHdbPar(pHdb node, int dataType, void *data, int length,
|
||||
void *callData);
|
||||
/**
|
||||
* Updates a hipadaba parameter. This does not cause an active parameter to
|
||||
* start driving but invokes all notifications which may be registered on
|
||||
* this parameter.
|
||||
* @param node The node for which to set the parameter
|
||||
* param dataType The datatype the value ought to have
|
||||
* @param data A pointer to the data to set.
|
||||
* @param length The length of data
|
||||
* @param callData Additonal context data to be passed to the callback functions
|
||||
* @return 0 on failure, a negative error code on failure
|
||||
*/
|
||||
int UpdateHdbPar(pHdb node, int dataType, void *data, int length,
|
||||
void *callData);
|
||||
/**
|
||||
* Read a hipadaba parameter
|
||||
* @param node The node for which to read the parameter
|
||||
* @param dataType The expected type of the data
|
||||
* @param data A pointer to which data will be copied
|
||||
* @param length The length of data.
|
||||
* @param callData Additonal context data to be passed to the callback functions
|
||||
* @return 0 on failure, a negative error code on failures.
|
||||
*/
|
||||
int GetHdbPar(pHdb node, int dataType, void *data, int length,
|
||||
void *callData);
|
||||
/*================================ Property Interface ==============================================*/
|
||||
/**
|
||||
* set a property
|
||||
@ -437,6 +415,14 @@ int GetHdbPar(pHdb node, int dataType, void *data, int length,
|
||||
* @return 0 on failure, 1 on success
|
||||
*/
|
||||
int GetHdbProperty(pHdb node, char *key, char *value, int len);
|
||||
/**
|
||||
* get the value of a property
|
||||
* @param node The node to get the property from
|
||||
* @param key The properties key
|
||||
* @return the property or NULL on failure. Warning: the string is
|
||||
* only valid as long as the property has not changed
|
||||
*/
|
||||
char *GetHdbProp(pHdb node, char *key);
|
||||
/**
|
||||
* initialize a property scan on this node
|
||||
* @param node The node for which to scan properties
|
||||
|
Reference in New Issue
Block a user