X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fstore-private.h;h=750a0b32bbb4e83706f5ac7658e25cf8e48904bf;hb=e4925baf923191b68f211354f57e743b7500d0c8;hp=703bc55e476c0b3ef2663ec28ac63098a0d2399b;hpb=88281ca69be18cdd05acb7fff580f40c091e49f5;p=sysdb.git diff --git a/src/core/store-private.h b/src/core/store-private.h index 703bc55..750a0b3 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -78,10 +78,22 @@ typedef struct { #define SVC(obj) ((sdb_service_t *)(obj)) #define CONST_SVC(obj) ((const sdb_service_t *)(obj)) +typedef struct { + sdb_store_obj_t super; + + sdb_avltree_t *attributes; + struct { + char *type; + char *id; + } store; +} sdb_metric_t; +#define METRIC(obj) ((sdb_metric_t *)(obj)) + typedef struct { sdb_store_obj_t super; sdb_avltree_t *services; + sdb_avltree_t *metrics; sdb_avltree_t *attributes; } sdb_host_t; #define HOST(obj) ((sdb_host_t *)(obj)) @@ -91,13 +103,34 @@ typedef struct { #define _last_update super.last_update #define _interval super.interval +/* + * expressions + */ +enum { + ATTR_VALUE = -2, /* attr name stored in data.data.string */ + FIELD_VALUE = -1, /* field type stored in data.data.integer */ + /* 0: const value (stored in data) */ + /* >0: operator id */ +}; + +struct sdb_store_expr { + sdb_object_t super; + + int type; /* see above */ + + sdb_store_expr_t *left; + sdb_store_expr_t *right; + + sdb_data_t data; +}; + /* * conditionals */ -/* compares a host using the specified conditional and taking the specified +/* compares an object using the specified conditional and taking the specified * filter into account */ -typedef int (*cmp_cb)(sdb_host_t *, sdb_store_cond_t *, +typedef int (*cmp_cb)(sdb_store_obj_t *, sdb_store_cond_t *, sdb_store_matcher_t *); struct sdb_store_cond { @@ -112,24 +145,44 @@ typedef struct { } attr_cond_t; #define ATTR_C(obj) ((attr_cond_t *)(obj)) +typedef struct { + sdb_store_cond_t super; + int field; + sdb_store_expr_t *expr; +} obj_cond_t; +#define OBJ_C(obj) ((obj_cond_t *)(obj)) + /* * matchers */ -/* when adding to this, also update 'matchers' and 'matchers_tostring' - * in store_lookup.c */ +/* when adding to this, also update 'MATCHER_SYM' below as well as 'matchers' + * and 'matchers_tostring' in store_lookup.c */ enum { MATCHER_OR, MATCHER_AND, MATCHER_NOT, MATCHER_NAME, MATCHER_ATTR, + MATCHER_SERVICE, + MATCHER_METRIC, + MATCHER_ATTRIBUTE, MATCHER_LT, MATCHER_LE, MATCHER_EQ, MATCHER_GE, MATCHER_GT, + MATCHER_CMP_LT, + MATCHER_CMP_LE, + MATCHER_CMP_EQ, + MATCHER_CMP_NE, + MATCHER_CMP_GE, + MATCHER_CMP_GT, + MATCHER_IN, + MATCHER_REGEX, + MATCHER_NREGEX, MATCHER_ISNULL, + MATCHER_ISNNULL, }; #define MATCHER_SYM(t) \ @@ -138,12 +191,20 @@ enum { : ((t) == MATCHER_NOT) ? "NOT" \ : ((t) == MATCHER_NAME) ? "NAME" \ : ((t) == MATCHER_ATTR) ? "ATTR" \ + : ((t) == MATCHER_SERVICE) ? "SERVICE" \ + : ((t) == MATCHER_METRIC) ? "METRIC" \ + : ((t) == MATCHER_ATTRIBUTE) ? "ATTRIBUTE" \ : ((t) == MATCHER_LT) ? "<" \ : ((t) == MATCHER_LE) ? "<=" \ : ((t) == MATCHER_EQ) ? "=" \ + : ((t) == MATCHER_CMP_NE) ? "!=" \ : ((t) == MATCHER_GE) ? ">=" \ : ((t) == MATCHER_GT) ? ">" \ + : ((t) == MATCHER_IN) ? "IN" \ + : ((t) == MATCHER_REGEX) ? "=~" \ + : ((t) == MATCHER_NREGEX) ? "!~" \ : ((t) == MATCHER_ISNULL) ? "IS NULL" \ + : ((t) == MATCHER_ISNNULL) ? "IS NOT NULL" \ : "UNKNOWN") /* match the name of something */ @@ -179,6 +240,23 @@ typedef struct { } uop_matcher_t; #define UOP_M(m) ((uop_matcher_t *)(m)) +/* child matcher */ +typedef struct { + sdb_store_matcher_t super; + sdb_store_matcher_t *m; +} child_matcher_t; +#define CHILD_M(m) ((child_matcher_t *)(m)) + +/* compare operator matcher */ +typedef struct { + sdb_store_matcher_t super; + + /* left and right hand expressions */ + sdb_store_expr_t *left; + sdb_store_expr_t *right; +} cmp_matcher_t; +#define CMP_M(m) ((cmp_matcher_t *)(m)) + /* match any type of object by it's name */ typedef struct { sdb_store_matcher_t super; @@ -198,7 +276,7 @@ typedef struct { typedef struct { sdb_store_matcher_t super; - char *attr_name; /* we only support matching attributes */ + sdb_store_expr_t *expr; } isnull_matcher_t; #define ISNULL_M(m) ((isnull_matcher_t *)(m))