X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fstore-private.h;h=b8f27e25e20ff0f7af2c34f7a98ba9df93f4728c;hb=f257d14eeca9e263e561f2f597b31bd9b0f4e931;hp=eea43164fed967c4b4e2bdec92e426c10d56e3d0;hpb=135992ebf12bf7aa866848650cbb47d3d3726c6d;p=sysdb.git diff --git a/src/core/store-private.h b/src/core/store-private.h index eea4316..b8f27e2 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -33,6 +33,7 @@ #define SDB_CORE_STORE_PRIVATE_H 1 #include "core/store.h" +#include "utils/avltree.h" #include #include @@ -41,6 +42,10 @@ extern "C" { #endif +/* + * core types + */ + struct sdb_store_obj { sdb_object_t super; @@ -68,7 +73,7 @@ typedef struct { typedef struct { sdb_store_obj_t super; - sdb_llist_t *attributes; + sdb_avltree_t *attributes; } sdb_service_t; #define SVC(obj) ((sdb_service_t *)(obj)) #define CONST_SVC(obj) ((const sdb_service_t *)(obj)) @@ -76,8 +81,20 @@ typedef struct { typedef struct { sdb_store_obj_t super; - sdb_llist_t *services; - sdb_llist_t *attributes; + 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)) #define CONST_HOST(obj) ((const sdb_host_t *)(obj)) @@ -90,8 +107,10 @@ typedef struct { * conditionals */ -/* compares a host using the specified conditional */ -typedef int (*cmp_cb)(sdb_host_t *, sdb_store_cond_t *); +/* compares an object using the specified conditional and taking the specified + * filter into account */ +typedef int (*cmp_cb)(sdb_store_obj_t *, sdb_store_cond_t *, + sdb_store_matcher_t *); struct sdb_store_cond { sdb_object_t super; @@ -101,10 +120,17 @@ struct sdb_store_cond { typedef struct { sdb_store_cond_t super; char *name; - sdb_data_t value; + sdb_store_expr_t *expr; } 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 */ @@ -117,11 +143,20 @@ enum { 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_GE, + MATCHER_CMP_GT, + MATCHER_ISNULL, }; #define MATCHER_SYM(t) \ @@ -130,11 +165,15 @@ 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_GE) ? ">=" \ : ((t) == MATCHER_GT) ? ">" \ + : ((t) == MATCHER_ISNULL) ? "IS NULL" \ : "UNKNOWN") /* match the name of something */ @@ -170,6 +209,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; @@ -187,6 +243,12 @@ typedef struct { } attr_matcher_t; #define ATTR_M(m) ((attr_matcher_t *)(m)) +typedef struct { + sdb_store_matcher_t super; + char *attr_name; /* we only support matching attributes */ +} isnull_matcher_t; +#define ISNULL_M(m) ((isnull_matcher_t *)(m)) + /* match using conditionals */ typedef struct { sdb_store_matcher_t super;