From f47d818c0185b28f69366e8e98b432f394ec184a Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 6 Nov 2014 00:28:00 +0100 Subject: [PATCH] store_lookup: Let the iter operators support services and metrics. --- src/core/store_lookup.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 94459cb..ffa1346 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -93,16 +93,20 @@ match_iter(sdb_store_matcher_t *m, sdb_store_obj_t *obj, assert((m->type == MATCHER_ANY) || (m->type == MATCHER_ALL)); - /* TODO: support all object types */ - if (obj->type != SDB_HOST) - return 0; - - if (ITER_M(m)->type == SDB_SERVICE) - iter = sdb_avltree_get_iter(HOST(obj)->services); - else if (ITER_M(m)->type == SDB_METRIC) - iter = sdb_avltree_get_iter(HOST(obj)->metrics); - else if (ITER_M(m)->type == SDB_ATTRIBUTE) - iter = sdb_avltree_get_iter(HOST(obj)->attributes); + if (obj->type == SDB_HOST) { + if (ITER_M(m)->type == SDB_SERVICE) + iter = sdb_avltree_get_iter(HOST(obj)->services); + else if (ITER_M(m)->type == SDB_METRIC) + iter = sdb_avltree_get_iter(HOST(obj)->metrics); + else if (ITER_M(m)->type == SDB_ATTRIBUTE) + iter = sdb_avltree_get_iter(HOST(obj)->attributes); + } else if (obj->type == SDB_SERVICE) { + if (ITER_M(m)->type == SDB_ATTRIBUTE) + iter = sdb_avltree_get_iter(SVC(obj)->attributes); + } else if (obj->type == SDB_METRIC) { + if (ITER_M(m)->type == SDB_ATTRIBUTE) + iter = sdb_avltree_get_iter(METRIC(obj)->attributes); + } status = all; while (sdb_avltree_iter_has_next(iter)) { -- 2.30.2