idnode: add a find by class feature and second enum for dynamic output
This commit is contained in:
parent
226a3600f9
commit
e925c7d527
4 changed files with 32 additions and 0 deletions
26
src/idnode.c
26
src/idnode.c
|
@ -616,3 +616,29 @@ idnode_set_sort
|
|||
{
|
||||
qsort_r(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_sort, sort);
|
||||
}
|
||||
|
||||
void
|
||||
idnode_set_free ( idnode_set_t *is )
|
||||
{
|
||||
free(is->is_array);
|
||||
free(is);
|
||||
}
|
||||
|
||||
idnode_set_t *
|
||||
idnode_find_all ( const idclass_t *idc )
|
||||
{
|
||||
idnode_t *in;
|
||||
const idclass_t *ic;
|
||||
idnode_set_t *is = calloc(1, sizeof(idnode_set_t));
|
||||
RB_FOREACH(in, &idnodes, in_link) {
|
||||
ic = in->in_class;
|
||||
while (ic) {
|
||||
if (ic == idc) {
|
||||
idnode_set_add(is, in, NULL);
|
||||
break;
|
||||
}
|
||||
ic = ic->ic_super;
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ const char *idnode_uuid_as_str(const idnode_t *in);
|
|||
|
||||
void *idnode_find(const char *uuid, const idclass_t *class);
|
||||
|
||||
idnode_set_t *idnode_find_all(const idclass_t *class);
|
||||
|
||||
idnode_t **idnode_get_childs(idnode_t *in);
|
||||
|
||||
int idnode_is_leaf(idnode_t *in);
|
||||
|
@ -118,3 +120,4 @@ int idnode_filter
|
|||
void idnode_set_add
|
||||
( idnode_set_t *is, idnode_t *in, idnode_filter_t *filt );
|
||||
void idnode_set_sort ( idnode_set_t *is, idnode_sort_t *s );
|
||||
void idnode_set_free ( idnode_set_t *is );
|
||||
|
|
|
@ -173,6 +173,8 @@ prop_add_params_to_msg(void *obj, const property_t *p, htsmsg_t *msg)
|
|||
e++;
|
||||
}
|
||||
htsmsg_add_msg(m, "enum", l);
|
||||
} else if (p[i].type == PT_STR && p[i].str_enum2) {
|
||||
htsmsg_add_msg(m, "enum", p[i].str_enum2(obj));
|
||||
}
|
||||
if (obj)
|
||||
prop_read_value(obj, p+i, m, "value");
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef struct property {
|
|||
const char *(*str_get)(void *ptr);
|
||||
void (*str_set)(void *ptr, const char *str);
|
||||
const char **(*str_enum)(void *ptr);
|
||||
htsmsg_t *(*str_enum2)(void *ptr);
|
||||
|
||||
void (*notify)(void *ptr);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue