On Tue, 2008-03-25 at 14:52 -0700, Joel Becker wrote:
> dataconf_error_t dataconf_track (
> > dataconf_handle_t dataconf_handle,
> > char *xml_request,
> > int track_flags);
>
> Why do we have a single callback, btw? Why aren't we doing:
>
> dataconf_error_t dataconf_initialize(dataconf_handle_t *handle);
> dataconf_error_t dataconf_track(
> dataconf_handle_t handle,
> char *xml_request,
> int track_flags,
> void (*callback)(void *obj, void *key, void *value, void
> *user_data),
> void *user_data);
>
> In this fashion, the user could have many callbacks, each specific
> to the type of data they are expecting. Then the caller doesn't have
> to have a giant if() block:
>
> classic_ais_callback(void *obj, void *key, void *value)
> {
> if (object == obj1)
> call_one(object, key, value)
> else if (object == obj2)
> call_two(object, key, value)
> ...
> }
>
The basic idea is the api user use different dataconf_handle's for
different callback objects.
Placing the callback in track would work, however the track function
would have to return a new handle type "dataconf_track_handle_t" so that
later that same handle's tracking could be stopped.
>From an implementation perspective doing this would be highly painful,
but could possibly make the api user's life easier. But then if we were
to do that we may need no dataconf_handle_t type at all since there is
only one dispatch function.
I've attached an api from round -3 as well as an api that might expose
this callback via tracking and also remove the entire concept of handles
for the top level api.
Regards
-steve
> Joel
>
/*
* External API exported in a library api
*/
typedef uint64_t dataconf_handle_t;
typedef uint64_t dataconf_query_handle_t;
typedef enum {
DATACONF_DISPATCH_ONE,
DATACONF_DISPATCH_ALL,
DATACONF_DISPATCH_BLOCKING
} dataconf_dispatch_t;
#define DATACONF_TRACK_CURRENT 0x01
#define DATACONF_TRACK_CHANGES 0x02
#define DATACONF_TRACk_CHANGES_ONLY 0x04
typedef void (*dataconf_new_result_fn_t) (
dataconf_handle_t handle,
unsigned int seqno,
char *result);
typedef void (*dataconf_done_result_fn_t) (
dataconf_handle_t handle,
unsigned int seqno);
typedef struct {
dataconf_new_result_fn_t dataconf_new_result_fn_t,
dataconf_done_result_fn_t dataconf_done_result_fn
} dataconf_callbacks_t;
dataconf_error_t dataconf_initialize (
dataconf_handle_t *handle,
dataconf_callbacks_t *callbacks);
dataconf_error_t dataconf_finalize (
dataconf_handle_t handle);
dataconf_error_t dataconf_fd_get (
dataconf_handle_t *handle,
int *fd);
dataconf_error_t dataconf_dispatch (
dataconf_handle_t handle,
dataconf_handle_T dispatch_types);
/*
* Starts the delivery of callbacks for the xml query specified.
* All callbacks are deliverd via the dispatch function
* Depending on track flags, the current values of the xml query could be
* delivered in this callback
*/
dataconf_error_t dataconf_track (
dataconf_handle_t dataconf_handle,
char *xml_request,
int track_flags);
dataconf_error_t dataconf_trackstop (
dataconf_handle_t dataconf_handle);
/*
* Retrieves one key and value via an XML query
*/
dataconf_error_t dataconf_query_one (
dataconf_handle_t dataconf_handle,
char *xml_request,
char *result);
/*
* Retrieves lists of information via an XML query
*/
dataconf_error_t dataconf_query_list_initialize (
dataconf_handle_t dataconf_handle,
char *xml_request,
dataconf_query_list_handle_t *dataconf_query_list_handle);
dataconf_error_t dataconf_query_list_next (
dataconf_query_list_handle_t dataconf_query_list_handle,
char *result);
dataconf_error_t dataconf_query_list_finalize (
dataconf_query_list_handle_t dataconf_query_list_handle);
/*
* Internal implementation API used inside the executive
*/
typdef uint64t xml_handle_t;
xml_initialize (xml_handle_t *handle);
xml_track_set (xml_handle_t handle,
char *request,
void (*new_result_fn_t) (
unsigned int seqno,
char *result),
void (*done_result_fn_t) (
unsigned int seqno),
unsigned int track_flags);
xml_finalize (xml_handle_t handle);
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais