X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Finclude%2Fcore%2Fobject.h;h=3c00fb51abe807d00799d931278e2d5dddc8ffd6;hb=73272856dba3b5e49710205601017724fbb6c424;hp=2f466104c86ee10c3973dc964ce3e80469b29f3c;hpb=533dc85bfe9ef7ed1f7fead5ce612506b7fab90d;p=sysdb.git diff --git a/src/include/core/object.h b/src/include/core/object.h index 2f46610..3c00fb5 100644 --- a/src/include/core/object.h +++ b/src/include/core/object.h @@ -46,16 +46,16 @@ struct sdb_type { 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, NULL } +#define SDB_TYPE_INIT { 0, NULL, NULL } struct sdb_object { sdb_type_t type; int ref_cnt; + char *name; }; -#define SDB_OBJECT_INIT { SDB_TYPE_INIT, 1 } -#define SDB_OBJECT_TYPED_INIT(t) { (t), 1 } +#define SDB_OBJECT_INIT { SDB_TYPE_INIT, 1, NULL } +#define SDB_OBJECT_TYPED_INIT(t) { (t), 1, NULL } typedef struct { sdb_object_t super; @@ -70,8 +70,8 @@ typedef struct { /* * sdb_object_create: - * Allocates a new sdb_object_t of the specified 'type'. The object will be - * initialized to zero and then passed on to the 'init' function (if + * Allocates a new sdb_object_t of the specified 'name' and 'type'. The object + * will be initialized to zero and then passed on to the 'init' function (if * specified). If specified, the 'destroy' callback will be called, when the * reference count drops to zero and before freeing the memory allocated by * the object itself. @@ -87,7 +87,9 @@ typedef struct { * - NULL on error */ sdb_object_t * -sdb_object_create(sdb_type_t type, ...); +sdb_object_create(const char *name, sdb_type_t type, ...); +sdb_object_t * +sdb_object_vcreate(const char *name, sdb_type_t type, va_list ap); /* * sdb_object_create_wrapper: @@ -97,7 +99,8 @@ sdb_object_create(sdb_type_t type, ...); * of the SysDB object system. */ sdb_object_t * -sdb_object_create_wrapper(void *data, void (*destructor)(void *)); +sdb_object_create_wrapper(const char *name, + void *data, void (*destructor)(void *)); #define SDB_OBJECT_WRAPPER_STATIC(obj, destructor) \ { SDB_OBJECT_INIT, (obj), (destructor) } @@ -120,17 +123,16 @@ 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). + * sdb_object_cmp_by_name: + * Compare two objects by their name ignoring the case of the characters. * * Returns: - * - the cloned object on success - * - NULL on error or if no clone callback is available + * - a negative value if o1 compares less than o2 + * - zero if o1 matches o2 + * - a positive value if o1 compares greater than o2 */ -sdb_object_t * -sdb_object_clone(const sdb_object_t *obj); +int +sdb_object_cmp_by_name(const sdb_object_t *o1, const sdb_object_t *o2); #ifdef __cplusplus } /* extern "C" */