mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2025-06-30 22:18:29 -04:00
Feature: Added igloo_ro_get_interface()
This commit is contained in:
parent
c1b2715265
commit
d123abab8c
@ -113,6 +113,24 @@ typedef igloo_ro_t (*igloo_ro_clone_t)(igloo_ro_t self, igloo_ro_cf_t required,
|
|||||||
*/
|
*/
|
||||||
typedef igloo_ro_t (*igloo_ro_convert_t)(igloo_ro_t self, const igloo_ro_type_t *type, igloo_ro_cf_t required, igloo_ro_cf_t allowed, const char *name, igloo_ro_t associated);
|
typedef igloo_ro_t (*igloo_ro_convert_t)(igloo_ro_t self, const igloo_ro_type_t *type, igloo_ro_cf_t required, igloo_ro_cf_t allowed, const char *name, igloo_ro_t associated);
|
||||||
|
|
||||||
|
/* Type used for callback called when a specific interface to the object is requested.
|
||||||
|
*
|
||||||
|
* There are two cases that must be handled by the callback:
|
||||||
|
* 0) The object self is of the same type as this callback is set for and type is pointing to different type that is an interface.
|
||||||
|
* 1) The object self is of any type and type is pointing to the type this callback was set to which is an interface.
|
||||||
|
*
|
||||||
|
* This must not be used for converting to non-interface types. Use igloo_ro_convert() for that.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* self
|
||||||
|
* The object to convert.
|
||||||
|
* type
|
||||||
|
* The type of the interface requested.
|
||||||
|
* name, associated
|
||||||
|
* See igloo_ro_new().
|
||||||
|
*/
|
||||||
|
typedef igloo_ro_t (*igloo_ro_get_interface_t)(igloo_ro_t self, const igloo_ro_type_t *type, const char *name, igloo_ro_t associated);
|
||||||
|
|
||||||
/* Type used for callback called when the object needs to be converted to a string.
|
/* Type used for callback called when the object needs to be converted to a string.
|
||||||
*
|
*
|
||||||
* This is used mostly for debugging or preseting the object to the user.
|
* This is used mostly for debugging or preseting the object to the user.
|
||||||
@ -186,6 +204,8 @@ struct igloo_ro_type_tag {
|
|||||||
igloo_ro_clone_t type_clonecb;
|
igloo_ro_clone_t type_clonecb;
|
||||||
/* Callback to be called by igloo_ro_convert() */
|
/* Callback to be called by igloo_ro_convert() */
|
||||||
igloo_ro_convert_t type_convertcb;
|
igloo_ro_convert_t type_convertcb;
|
||||||
|
/* Callback to be called by igloo_ro_get_interface() */
|
||||||
|
igloo_ro_get_interface_t type_get_interfacecb;
|
||||||
/* Callback to be called by igloo_ro_stringify() */
|
/* Callback to be called by igloo_ro_stringify() */
|
||||||
igloo_ro_stringify_t type_stringifycb;
|
igloo_ro_stringify_t type_stringifycb;
|
||||||
/* Callback to be called by igloo_ro_compare() */
|
/* Callback to be called by igloo_ro_compare() */
|
||||||
@ -301,6 +321,25 @@ igloo_ro_t igloo_ro_clone(igloo_ro_t self, igloo_ro_cf_t required, igloo_ro
|
|||||||
*/
|
*/
|
||||||
igloo_ro_t igloo_ro_convert(igloo_ro_t self, const igloo_ro_type_t *type, igloo_ro_cf_t required, igloo_ro_cf_t allowed, const char *name, igloo_ro_t associated);
|
igloo_ro_t igloo_ro_convert(igloo_ro_t self, const igloo_ro_type_t *type, igloo_ro_cf_t required, igloo_ro_cf_t allowed, const char *name, igloo_ro_t associated);
|
||||||
|
|
||||||
|
/* Request a specific interface from the object.
|
||||||
|
*
|
||||||
|
* This must not be used to convert the object. This can only be used for requesting a specific interface.
|
||||||
|
*
|
||||||
|
* The object may return the same object for the same requested interface multiple times.
|
||||||
|
* However each time the same object is returned a new reference to it is returned.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* self
|
||||||
|
* The object to copy and convert.
|
||||||
|
* type
|
||||||
|
* The interface requested.
|
||||||
|
* name, associated
|
||||||
|
* See igloo_ro_new().
|
||||||
|
* Returns:
|
||||||
|
* An object that represents the given interface or igloo_RO_NULL.
|
||||||
|
*/
|
||||||
|
igloo_ro_t igloo_ro_get_interface(igloo_ro_t self, const igloo_ro_type_t *type, const char *name, igloo_ro_t associated);
|
||||||
|
|
||||||
/* Convert a object to a string.
|
/* Convert a object to a string.
|
||||||
* This is used for debugging and presenting to the user.
|
* This is used for debugging and presenting to the user.
|
||||||
*
|
*
|
||||||
|
@ -51,6 +51,7 @@ static const igloo_ro_type_t igloo_ro__typedef__ ## type = \
|
|||||||
#define igloo_RO_TYPEDECL_NEW_NOOP() .type_newcb = igloo_ro_new__return_zero
|
#define igloo_RO_TYPEDECL_NEW_NOOP() .type_newcb = igloo_ro_new__return_zero
|
||||||
#define igloo_RO_TYPEDECL_CLONE(cb) .type_clonecb = (cb)
|
#define igloo_RO_TYPEDECL_CLONE(cb) .type_clonecb = (cb)
|
||||||
#define igloo_RO_TYPEDECL_CONVERT(cb) .type_convertcb = (cb)
|
#define igloo_RO_TYPEDECL_CONVERT(cb) .type_convertcb = (cb)
|
||||||
|
#define igloo_RO_TYPEDECL_GET_INTERFACE(cb) .type_get_interfacecb = (cb)
|
||||||
#define igloo_RO_TYPEDECL_STRINGIFY(cb) .type_stringifycb = (cb)
|
#define igloo_RO_TYPEDECL_STRINGIFY(cb) .type_stringifycb = (cb)
|
||||||
#define igloo_RO_TYPEDECL_COMPARE(cb) .type_comparecb = (cb)
|
#define igloo_RO_TYPEDECL_COMPARE(cb) .type_comparecb = (cb)
|
||||||
|
|
||||||
|
20
src/ro.c
20
src/ro.c
@ -372,6 +372,26 @@ igloo_ro_t igloo_ro_convert(igloo_ro_t self, const igloo_ro_type_t *type, i
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igloo_ro_t igloo_ro_get_interface(igloo_ro_t self, const igloo_ro_type_t *type, const char *name, igloo_ro_t associated)
|
||||||
|
{
|
||||||
|
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
||||||
|
igloo_ro_t ret = igloo_RO_NULL;
|
||||||
|
|
||||||
|
if (!base || !type)
|
||||||
|
return igloo_RO_NULL;
|
||||||
|
|
||||||
|
igloo_thread_mutex_lock(&(base->lock));
|
||||||
|
if (!base->refc) {
|
||||||
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
|
return igloo_RO_NULL;
|
||||||
|
}
|
||||||
|
if (base->type->type_get_interfacecb)
|
||||||
|
ret = base->type->type_get_interfacecb(self, type, name, associated);
|
||||||
|
igloo_thread_mutex_unlock(&(base->lock));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
char * igloo_ro_stringify(igloo_ro_t self)
|
char * igloo_ro_stringify(igloo_ro_t self)
|
||||||
{
|
{
|
||||||
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
igloo_ro_base_t *base = igloo_RO__GETBASE(self);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user