Result
[XMMSClient]

Result manipulation and error handlingEach command to the server will return a xmmsc_result_t to the programmer. More...

Modules

 ResultValueRetrieval
 

Explains how you can retrive values from a xmmsc_result_t.


Functions

xmmsc_result_txmmsc_result_ref (xmmsc_result_t *res)
 References the xmmsc_result_t.
xmmsc_result_type_t xmmsc_result_get_class (xmmsc_result_t *res)
 Get the class of the result (default, signal, broadcast).
void xmmsc_result_disconnect (xmmsc_result_t *res)
 Disconnect a signal or a broadcast.
uint32_t xmmsc_result_cookie_get (xmmsc_result_t *res)
 return the cookie of a resultset.
void xmmsc_result_visc_set (xmmsc_result_t *res, xmmsc_visualization_t *visc)
xmmsc_visualization_t * xmmsc_result_visc_get (xmmsc_result_t *res)
xmmsc_connection_txmmsc_result_get_connection (xmmsc_result_t *res)
void xmmsc_result_unref (xmmsc_result_t *res)
 Decreases the references for the xmmsc_result_t When the number of references reaches 0 it will be freed.
void xmmsc_result_notifier_set (xmmsc_result_t *res, xmmsc_result_notifier_t func, void *user_data)
 Set up a callback for the result retrival.
void xmmsc_result_notifier_set_full (xmmsc_result_t *res, xmmsc_result_notifier_t func, void *user_data, xmmsc_user_data_free_func_t free_func)
 Set up a callback for the result retrieval.
void xmmsc_result_wait (xmmsc_result_t *res)
 Block for the reply.

Detailed Description

Result manipulation and error handling

Each command to the server will return a xmmsc_result_t to the programmer.

This object will be used to see the results off the call. It will handle errors and the results.

results could be used in both sync and async fashions. Here is a sync example:

 xmmsc_result_t *res;
 xmmsv_t *val;
 uint32_t id;
 res = xmmsc_playback_get_current_id (connection);
 xmmsc_result_wait (res);
 if (!val = xmmsc_result_get_value (res)) {
   printf ("error: failed to retrieve value!");
 }
 if (xmmsv_is_error (val)) {
   printf ("error: %s", xmmsv_get_error (val));
 }
 xmmsv_get_uint (val, &id);
 xmmsc_result_unref (res);
 printf ("current id is: %d", id);

an async example is a bit more complex...

 static void handler (xmmsv_t *val, void *userdata) {
   uint32_t id;
   if (xmmsv_is_error (val)) {
      printf ("error: %s", xmmsv_get_error (val));
   }
   xmmsv_get_uint (val, &id);
   printf ("current id is: %d", id);
 }

 int main () {
   // Connect blah blah ...
   xmmsc_result_t *res;
   res = xmmsc_playback_get_current_id (connection);
   xmmsc_result_notifier_set (res, handler);
   xmmsc_result_unref (res);
 }

When the answer arrives handler will be called. with the resulting xmmsv_t


Function Documentation

uint32_t xmmsc_result_cookie_get ( xmmsc_result_t res  ) 

return the cookie of a resultset.

Definition at line 246 of file result.c.

Referenced by xmmsc_ipc_result_lookup(), and xmmsc_ipc_result_unregister().

void xmmsc_result_disconnect ( xmmsc_result_t res  ) 

Disconnect a signal or a broadcast.

Parameters:
res The result to disconnect, must be of class signal or broadcast.

Definition at line 181 of file result.c.

xmmsc_result_type_t xmmsc_result_get_class ( xmmsc_result_t res  ) 

Get the class of the result (default, signal, broadcast).

Returns:
The class of the result of type xmmsc_result_type_t

Definition at line 169 of file result.c.

xmmsc_connection_t* xmmsc_result_get_connection ( xmmsc_result_t res  ) 

Definition at line 270 of file result.c.

Referenced by setup_udp_handle().

void xmmsc_result_notifier_set ( xmmsc_result_t res,
xmmsc_result_notifier_t  func,
void *  user_data 
)

Set up a callback for the result retrival.

This callback Will be called when the answers arrives.

Parameters:
res a xmmsc_result_t that you got from a command dispatcher.
func the function that should be called when we receive the answer
user_data optional user data to the callback

Definition at line 305 of file result.c.

void xmmsc_result_notifier_set_full ( xmmsc_result_t res,
xmmsc_result_notifier_t  func,
void *  user_data,
xmmsc_user_data_free_func_t  free_func 
)

Set up a callback for the result retrieval.

This callback will be called when the answer arrives. This function differs from xmmsc_result_notifier_set in the additional free_func parameter, which allows to pass a pointer to a function which will be called to free the user_data when needed.

Parameters:
res a xmmsc_result_t that you got from a command dispatcher.
func the function that should be called when we receive the answer
user_data optional user data to the callback
free_func optional function that should be called to free the user_data

Definition at line 323 of file result.c.

Referenced by xmmsc_result_notifier_set().

xmmsc_result_t* xmmsc_result_ref ( xmmsc_result_t res  ) 

References the xmmsc_result_t.

Parameters:
result the result to reference.
Returns:
result

Definition at line 126 of file result.c.

Referenced by xmmsc_result_new(), xmmsc_result_notifier_set_full(), and xmmsc_result_run().

void xmmsc_result_unref ( xmmsc_result_t res  ) 

Decreases the references for the xmmsc_result_t When the number of references reaches 0 it will be freed.

And thus all data you extracted from it will be deallocated.

Definition at line 285 of file result.c.

Referenced by xmmsc_connect(), xmmsc_result_disconnect(), and xmmsc_result_run().

xmmsc_visualization_t* xmmsc_result_visc_get ( xmmsc_result_t res  ) 
void xmmsc_result_visc_set ( xmmsc_result_t res,
xmmsc_visualization_t *  visc 
)

Definition at line 254 of file result.c.

Referenced by setup_shm_prepare(), setup_udp_prepare(), and xmmsc_visualization_init().

void xmmsc_result_wait ( xmmsc_result_t res  ) 

Block for the reply.

In a synchronous application this can be used to wait for the result. Will return when the server replyed.

Definition at line 346 of file result.c.

Referenced by xmmsc_connect().


Generated on Tue Feb 23 18:17:57 2010 for XmmsClient by  doxygen 1.6.1