summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8260575)
raw | patch | inline | side by side (parent: 8260575)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 25 Oct 2014 19:43:28 +0000 (21:43 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 25 Oct 2014 19:43:28 +0000 (21:43 +0200) |
Similar to ANY, this matcher iterators over objects. It matches, if *all* of
those objects match another matcher.
those objects match another matcher.
src/core/store-private.h | patch | blob | history | |
src/core/store_lookup.c | patch | blob | history | |
src/include/core/store.h | patch | blob | history |
index 4c38f1570bca1d449a4478fa33119e410cf33136..a0f4ec61db0ece7ebafaf1ed52a96f83db40290e 100644 (file)
--- a/src/core/store-private.h
+++ b/src/core/store-private.h
MATCHER_AND,
MATCHER_NOT,
MATCHER_ANY,
+ MATCHER_ALL,
MATCHER_LT,
MATCHER_LE,
MATCHER_EQ,
: ((t) == MATCHER_NOT) ? "NOT" \
: ((t) == MATCHER_NAME) ? "NAME" \
: ((t) == MATCHER_ANY) ? "ANY" \
+ : ((t) == MATCHER_ALL) ? "ALL" \
: ((t) == MATCHER_LT) ? "<" \
: ((t) == MATCHER_LE) ? "<=" \
: ((t) == MATCHER_EQ) ? "=" \
index 11d85fea0a5ead05b42f6fffd089b6b135b0bcb9..513b6a64a7a824c5263eec708945c14a3812cfe6 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
{
sdb_avltree_iter_t *iter = NULL;
int status;
- int all = 0;
+ int all = (int)(m->type == MATCHER_ALL);
- assert(m->type == MATCHER_ANY);
+ assert((m->type == MATCHER_ANY) || (m->type == MATCHER_ALL));
/* TODO: support all object types */
if (obj->type != SDB_HOST)
match_logical,
match_unary,
match_iter,
+ match_iter,
match_lt,
match_le,
match_eq,
return NULL;
return M(sdb_object_create("any-matcher", iter_type,
MATCHER_ANY, type, m));
-} /* sdb_store_iter_matcher */
+} /* sdb_store_any_matcher */
+
+sdb_store_matcher_t *
+sdb_store_all_matcher(int type, sdb_store_matcher_t *m)
+{
+ if ((type != SDB_SERVICE) && (type != SDB_METRIC)
+ && (type != SDB_ATTRIBUTE))
+ return NULL;
+ return M(sdb_object_create("all-matcher", iter_type,
+ MATCHER_ALL, type, m));
+} /* sdb_store_all_matcher */
sdb_store_matcher_t *
sdb_store_lt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
index ed445c3a0533b53e40b3858e82ea0e4516188947..9ba19b8acbeb6da1ed3513ac9676080b1ba2f0bf 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
sdb_store_matcher_t *
sdb_store_any_matcher(int type, sdb_store_matcher_t *m);
+/*
+ * sdb_store_all_matcher:
+ * Creates a matcher iterating over objects of the specified type. It matches
+ * if *all* of those objects match 'm'.
+ */
+sdb_store_matcher_t *
+sdb_store_all_matcher(int type, sdb_store_matcher_t *m);
+
/*
* sdb_store_lt_matcher, sdb_store_le_matcher, sdb_store_eq_matcher,
* sdb_store_ge_matcher, sdb_store_gt_matcher: