X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fcore%2Fstore-private.h;h=823cd18feea6731da32660130149df1d24588df5;hb=cb21eefec7a836927a2e313f83cda80c573f1b65;hp=abd94c22f1d40dba2e097870abfb5d47b343e9f8;hpb=ca7064277a864e8e33cf9042c693c5580727282b;p=sysdb.git diff --git a/src/core/store-private.h b/src/core/store-private.h index abd94c2..823cd18 100644 --- a/src/core/store-private.h +++ b/src/core/store-private.h @@ -34,6 +34,9 @@ #include "core/store.h" +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -46,6 +49,7 @@ struct sdb_store_base { /* common meta information */ sdb_time_t last_update; + sdb_time_t interval; /* moving average */ sdb_store_base_t *parent; }; #define STORE_BASE(obj) ((sdb_store_base_t *)(obj)) @@ -81,6 +85,90 @@ enum { /* shortcuts for accessing the sdb_store_obj_t attributes * of inheriting objects */ #define _last_update super.last_update +#define _interval super.interval + +/* + * matchers + */ + +/* when adding to this, also update 'matchers' in store_lookup.c */ +enum { + MATCHER_OR, + MATCHER_AND, + MATCHER_NOT, + MATCHER_ATTR, + MATCHER_SERVICE, + MATCHER_HOST, +}; + +/* match the name of something */ +typedef struct { + char *name; + regex_t *name_re; +} name_matcher_t; + +/* matcher base type */ +struct sdb_store_matcher { + sdb_object_t super; + /* type of the matcher */ + int type; +}; +#define M(m) ((sdb_store_matcher_t *)(m)) + +/* logical infix operator matcher */ +typedef struct { + sdb_store_matcher_t super; + + /* left and right hand operands */ + sdb_store_matcher_t *left; + sdb_store_matcher_t *right; +} op_matcher_t; +#define OP_M(m) ((op_matcher_t *)(m)) + +/* logical unary operator matcher */ +typedef struct { + sdb_store_matcher_t super; + + /* operand */ + sdb_store_matcher_t *op; +} uop_matcher_t; +#define UOP_M(m) ((uop_matcher_t *)(m)) + +/* match any type of object by it's base information */ +typedef struct { + sdb_store_matcher_t super; + + /* match by the name of the object */ + name_matcher_t name; +} obj_matcher_t; +#define OBJ_M(m) ((obj_matcher_t *)(m)) + +/* match attributes */ +typedef struct { + obj_matcher_t super; + /* XXX: this needs to be more flexible; + * add support for type-specific operators */ + name_matcher_t value; +} attr_matcher_t; +#define ATTR_M(m) ((attr_matcher_t *)(m)) + +/* match services */ +typedef struct { + obj_matcher_t super; + /* match by attributes assigned to the service */ + attr_matcher_t *attr; +} service_matcher_t; +#define SERVICE_M(m) ((service_matcher_t *)(m)) + +/* match hosts */ +typedef struct { + obj_matcher_t super; + /* match by services assigned to the host */ + service_matcher_t *service; + /* match by attributes assigned to the host */ + attr_matcher_t *attr; +} host_matcher_t; +#define HOST_M(m) ((host_matcher_t *)(m)) #ifdef __cplusplus } /* extern "C" */