index f33768579575524857b9991376b55c2262364439..603648ca057b51ced94b5a7ecd05bdadd615acbc 100644 (file)
--- a/src/core/store-private.h
+++ b/src/core/store-private.h
sdb_data_t value;
} sdb_attribute_t;
sdb_data_t value;
} sdb_attribute_t;
-#define SDB_ATTR(obj) ((sdb_attribute_t *)(obj))
-#define SDB_CONST_ATTR(obj) ((const sdb_attribute_t *)(obj))
+#define ATTR(obj) ((sdb_attribute_t *)(obj))
+#define CONST_ATTR(obj) ((const sdb_attribute_t *)(obj))
typedef struct {
sdb_store_base_t super;
typedef struct {
sdb_store_base_t super;
- sdb_llist_t *children;
sdb_llist_t *attributes;
sdb_llist_t *attributes;
-} sdb_store_obj_t;
-#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
-#define SDB_CONST_STORE_OBJ(obj) ((const sdb_store_obj_t *)(obj))
+} sdb_service_t;
+#define SVC(obj) ((sdb_service_t *)(obj))
+#define CONST_SVC(obj) ((const sdb_service_t *)(obj))
-/* shortcuts for accessing the sdb_store_obj_t attributes
- * of inheriting objects */
+typedef struct {
+ sdb_store_base_t super;
+
+ sdb_llist_t *services;
+ sdb_llist_t *attributes;
+} sdb_host_t;
+#define HOST(obj) ((sdb_host_t *)(obj))
+#define CONST_HOST(obj) ((const sdb_host_t *)(obj))
+
+/* shortcuts for accessing service/host attributes */
#define _last_update super.last_update
#define _interval super.interval
#define _last_update super.last_update
#define _interval super.interval
+/*
+ * conditionals
+ */
+
+/* compares a store object using the specified conditional */
+typedef int (*cmp_cb)(sdb_store_base_t *, sdb_store_cond_t *);
+
+struct sdb_store_cond {
+ sdb_object_t super;
+ cmp_cb cmp;
+};
+
+typedef struct {
+ sdb_store_cond_t super;
+ char *name;
+ sdb_data_t value;
+} attr_cond_t;
+#define ATTR_C(obj) ((attr_cond_t *)(obj))
+
/*
* matchers
*/
/*
* matchers
*/
MATCHER_NOT,
MATCHER_NAME,
MATCHER_ATTR,
MATCHER_NOT,
MATCHER_NAME,
MATCHER_ATTR,
+ MATCHER_LT,
+ MATCHER_LE,
+ MATCHER_EQ,
+ MATCHER_GE,
+ MATCHER_GT,
};
};
+#define MATCHER_SYM(t) \
+ (((t) == MATCHER_OR) ? "OR" \
+ : ((t) == MATCHER_AND) ? "AND" \
+ : ((t) == MATCHER_NOT) ? "NOT" \
+ : ((t) == MATCHER_NAME) ? "NAME" \
+ : ((t) == MATCHER_ATTR) ? "ATTR" \
+ : ((t) == MATCHER_LT) ? "<" \
+ : ((t) == MATCHER_LE) ? "<=" \
+ : ((t) == MATCHER_EQ) ? "=" \
+ : ((t) == MATCHER_GE) ? ">=" \
+ : ((t) == MATCHER_GT) ? ">" \
+ : "UNKNOWN")
+
/* match the name of something */
typedef struct {
char *name;
/* match the name of something */
typedef struct {
char *name;
};
#define M(m) ((sdb_store_matcher_t *)(m))
};
#define M(m) ((sdb_store_matcher_t *)(m))
-/* logical infix operator matcher */
+/* infix operator matcher */
typedef struct {
sdb_store_matcher_t super;
typedef struct {
sdb_store_matcher_t super;
} op_matcher_t;
#define OP_M(m) ((op_matcher_t *)(m))
} op_matcher_t;
#define OP_M(m) ((op_matcher_t *)(m))
-/* logical unary operator matcher */
+/* unary operator matcher */
typedef struct {
sdb_store_matcher_t super;
typedef struct {
sdb_store_matcher_t super;
typedef struct {
sdb_store_matcher_t super;
char *name;
typedef struct {
sdb_store_matcher_t super;
char *name;
- /* XXX: this needs to be more flexible;
- * add support for type-specific operators */
string_matcher_t value;
} attr_matcher_t;
#define ATTR_M(m) ((attr_matcher_t *)(m))
string_matcher_t value;
} attr_matcher_t;
#define ATTR_M(m) ((attr_matcher_t *)(m))
+/* match using conditionals */
+typedef struct {
+ sdb_store_matcher_t super;
+ sdb_store_cond_t *cond;
+} cond_matcher_t;
+#define COND_M(m) ((cond_matcher_t *)(m))
+
#ifdef __cplusplus
} /* extern "C" */
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif