Code

store_lookup: Let the iter operators support services and metrics.
authorSebastian Harl <sh@tokkee.org>
Wed, 5 Nov 2014 23:28:00 +0000 (00:28 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 5 Nov 2014 23:28:00 +0000 (00:28 +0100)
src/core/store_lookup.c

index 94459cb097b1e21526f9c54f65d1cf3cd433c1ca..ffa1346bb1ea9f9bf7ea37b9cdb859cc637addfb 100644 (file)
@@ -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)) {