Code

object: Added SDB_OBJECT_STATIC.
[sysdb.git] / src / include / core / object.h
index 819d11e849b48d4e1e2eb65d35247f4abe22af29..b91e9b88cebf815fe1dd6e22234c0140bb2d682f 100644 (file)
@@ -57,6 +57,10 @@ struct sdb_object {
 #define SDB_OBJECT_INIT { SDB_TYPE_INIT, 1, NULL }
 #define SDB_OBJECT_TYPED_INIT(t) { (t), 1, NULL }
 
+#define SDB_OBJECT_STATIC(name) { \
+       /* type */ { sizeof(sdb_object_t), NULL, NULL }, \
+       /* ref-cnt */ 1, (name) }
+
 typedef struct {
        sdb_object_t super;
        void *data;
@@ -68,6 +72,12 @@ typedef struct {
 #define SDB_OBJ_WRAPPER(obj) ((sdb_object_wrapper_t *)(obj))
 #define SDB_CONST_OBJ_WRAPPER(obj) ((const sdb_object_wrapper_t *)(obj))
 
+/*
+ * Callback types for comparing objects or performing object lookup.
+ */
+typedef int (*sdb_object_cmp_cb)(const sdb_object_t *, const sdb_object_t *);
+typedef int (*sdb_object_lookup_cb)(const sdb_object_t *, const void *user_data);
+
 /*
  * sdb_object_create:
  * Allocates a new sdb_object_t of the specified 'name' and 'type'. The object
@@ -127,8 +137,8 @@ sdb_object_t *
 sdb_object_create_wrapper(const char *name,
                void *data, void (*destructor)(void *));
 
-#define SDB_OBJECT_WRAPPER_STATIC(obj, destructor) \
-       { SDB_OBJECT_INIT, (obj), (destructor) }
+#define SDB_OBJECT_WRAPPER_STATIC(obj) \
+       { SDB_OBJECT_INIT, (obj), /* destructor */ NULL }
 
 /*
  * sdb_object_deref: