index cadbfe47dbf861939168c3558ddbb6c7bd53c650..fb79b39fe089cf58f00eb7b99b702cbaa06e077e 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
/*
- * syscollector - src/include/core/store.h
+ * SysDB - src/include/core/store.h
* Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
* All rights reserved.
*
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SC_CORE_STORE_H
-#define SC_CORE_STORE_H 1
+#ifndef SDB_CORE_STORE_H
+#define SDB_CORE_STORE_H 1
-#include "syscollector.h"
+#include "sysdb.h"
#include "core/object.h"
-#include "utils/time.h"
+#include "core/time.h"
#include "utils/llist.h"
#include <stdio.h>
extern "C" {
#endif
-typedef struct {
- sc_object_t parent;
+extern const sdb_type_t sdb_host_type;
+extern const sdb_type_t sdb_attribute_type;
+extern const sdb_type_t sdb_service_type;
- sc_time_t last_update;
- char *name;
-} sc_store_obj_t;
-#define SC_STORE_OBJ_INIT { SC_OBJECT_INIT, 0, NULL }
-#define SC_STORE_OBJ(obj) ((sc_store_obj_t *)(obj))
+typedef struct {
+ sdb_object_t super;
+ sdb_time_t last_update;
+} sdb_store_obj_t;
+#define SDB_STORE_OBJ_INIT(t) { SDB_OBJECT_TYPED_INIT(t), 0 }
+#define SDB_STORE_OBJ(obj) ((sdb_store_obj_t *)(obj))
+#define SDB_CONST_STORE_OBJ(obj) ((const sdb_store_obj_t *)(obj))
typedef struct {
- sc_store_obj_t parent;
-#define svc_last_update parent.last_update
-#define svc_name parent.name
+ sdb_store_obj_t super;
char *hostname;
-} sc_service_t;
-#define SC_SVC_INIT { SC_STORE_OBJ_INIT, NULL }
-#define SC_SVC(obj) ((sc_service_t *)(obj))
+} sdb_service_t;
+#define SDB_SVC_INIT { SDB_STORE_OBJ_INIT(sdb_service_type), NULL }
+#define SDB_SVC(obj) ((sdb_service_t *)(obj))
+#define SDB_CONST_SVC(obj) ((const sdb_service_t *)(obj))
typedef struct {
- sc_store_obj_t parent;
-#define attr_last_update parent.last_update
-#define attr_name parent.name
+ sdb_store_obj_t super;
char *attr_value;
char *hostname;
-} sc_attribute_t;
-#define SC_ATTR_INIT { SC_STORE_OBJ_INIT, NULL, NULL }
-#define SC_ATTR(obj) ((sc_attribute_t *)(obj))
+} sdb_attribute_t;
+#define SDB_ATTR_INIT { SDB_STORE_OBJ_INIT(sdb_attribute_type), NULL, NULL }
+#define SDB_ATTR(obj) ((sdb_attribute_t *)(obj))
+#define SDB_CONST_ATTR(obj) ((const sdb_attribute_t *)(obj))
typedef struct {
- sc_store_obj_t parent;
-#define host_last_update parent.last_update
-#define host_name parent.name
+ sdb_store_obj_t super;
- sc_llist_t *attributes;
- sc_llist_t *services;
-} sc_host_t;
-#define SC_HOST_INIT { SC_STORE_OBJ_INIT, NULL, NULL }
-#define SC_HOST(obj) ((sc_host_t *)(obj))
+ sdb_llist_t *attributes;
+ sdb_llist_t *services;
+} sdb_host_t;
+#define SDB_HOST_INIT { SDB_STORE_OBJ_INIT(sdb_host_type), NULL, NULL }
+#define SDB_HOST(obj) ((sdb_host_t *)(obj))
+#define SDB_CONST_HOST(obj) ((const sdb_host_t *)(obj))
-sc_host_t *
-sc_host_create(const char *name);
+/* shortcuts for accessing the sdb_store_obj_t attributes of inheriting
+ * objects */
+#define _last_update super.last_update
-sc_host_t *
-sc_host_clone(const sc_host_t *host);
+sdb_host_t *
+sdb_host_create(const char *name);
/*
- * sc_store_host:
+ * sdb_store_host:
* Add/update a host in the store. If the host, identified by its name,
* already exists, it will be updated according to the specified 'host'
* object. Else, a new entry will be created in the store. Any memory required
* - a negative value on error
*/
int
-sc_store_host(const sc_host_t *host);
+sdb_store_host(const sdb_host_t *host);
-const sc_host_t *
-sc_store_get_host(const char *name);
+const sdb_host_t *
+sdb_store_get_host(const char *name);
-sc_attribute_t *
-sc_attribute_create(const char *hostname,
+sdb_attribute_t *
+sdb_attribute_create(const char *hostname,
const char *name, const char *value);
-sc_attribute_t *
-sc_attribute_clone(const sc_attribute_t *attr);
-
/*
- * sc_store_attribute:
+ * sdb_store_attribute:
* Add/update a host's attribute in the store. If the attribute, identified by
* its name, already exists for the specified host, it will be updated
* according to the specified 'attr' object. If the referenced host does not
* - a negative value on error
*/
int
-sc_store_attribute(const sc_attribute_t *attr);
-
-sc_service_t *
-sc_service_create(const char *hostname, const char *name);
+sdb_store_attribute(const sdb_attribute_t *attr);
-sc_service_t *
-sc_service_clone(const sc_service_t *svc);
+sdb_service_t *
+sdb_service_create(const char *hostname, const char *name);
/*
- * sc_store_service:
+ * sdb_store_service:
* Add/update a store in the store. If the service, identified by its name,
* already exists for the specified host, it will be updated according to the
* specified 'service' object. If the referenced host does not exist, an error
* - a negative value on error
*/
int
-sc_store_service(const sc_service_t *svc);
+sdb_store_service(const sdb_service_t *svc);
-const sc_service_t *
-sc_store_get_service(const sc_host_t *host, const char *name);
+const sdb_service_t *
+sdb_store_get_service(const sdb_host_t *host, const char *name);
int
-sc_store_dump(FILE *fh);
+sdb_store_dump(FILE *fh);
#ifdef __cplusplus
} /* extern "C" */
#endif
-#endif /* ! SC_CORE_STORE_H */
+#endif /* ! SDB_CORE_STORE_H */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */