index cab77d0816973ca242620c8320c22c8eca07682c..2f466104c86ee10c3973dc964ce3e80469b29f3c 100644 (file)
int (*init)(sdb_object_t *, va_list);
void (*destroy)(sdb_object_t *);
+ sdb_object_t *(*clone)(const sdb_object_t *);
};
-#define SDB_TYPE_INIT { 0, NULL, NULL }
+#define SDB_TYPE_INIT { 0, NULL, NULL, NULL }
struct sdb_object {
sdb_type_t type;
int ref_cnt;
};
#define SDB_OBJECT_INIT { SDB_TYPE_INIT, 1 }
+#define SDB_OBJECT_TYPED_INIT(t) { (t), 1 }
typedef struct {
sdb_object_t super;
} sdb_object_wrapper_t;
#define SDB_OBJ(obj) ((sdb_object_t *)(obj))
+#define SDB_CONST_OBJ(obj) ((const sdb_object_t *)(obj))
#define SDB_OBJ_WRAPPER(obj) ((sdb_object_wrapper_t *)(obj))
+#define SDB_CONST_OBJ_WRAPPER(obj) ((const sdb_object_wrapper_t *)(obj))
/*
* sdb_object_create:
void
sdb_object_ref(sdb_object_t *obj);
+/*
+ * sdb_object_clone:
+ * Clone an existing object using its type's 'clone' callback. The callback is
+ * responsible for correctly initializing a new object (which may be done
+ * using the object create function or the object's type's init function).
+ *
+ * Returns:
+ * - the cloned object on success
+ * - NULL on error or if no clone callback is available
+ */
+sdb_object_t *
+sdb_object_clone(const sdb_object_t *obj);
+
#ifdef __cplusplus
} /* extern "C" */
#endif