=== lib/libqof/qof/qofinstance-p.h
==================================================================
--- lib/libqof/qof/qofinstance-p.h (revision 14365)
+++ lib/libqof/qof/qofinstance-p.h (local)
@@ -31,51 +31,6 @@
#include "qofinstance.h"
-/*
- * UNDER CONSTRUCTION!
- * This is mostly scaffolding for now,
- * eventually, it may hold more fields, such as refrence counting...
- *
- */
-struct QofInstance_s
-{
- /* Globally unique id identifying this instance */
- QofIdType e_type; /**< Entity type */
- GUID guid; /**< GUID for the entity */
- QofCollection * collection; /**< Entity collection */
-
- /* The entity_table in which this instance is stored */
- QofBook * book;
-
- /* kvp_data is a key-value pair database for storing arbirtary
- * information associated with this instance.
- * See src/engine/kvp_doc.txt for a list and description of the
- * important keys. */
- KvpFrame *kvp_data;
-
- /* Timestamp used to track the last modification to this
- * instance. Typically used to compare two versions of the
- * same object, to see which is newer. When used with the
- * SQL backend, this field is reserved for SQL use, to compare
- * the version in local memory to the remote, server version.
- */
- Timespec last_update;
-
- /* Keep track of nesting level of begin/end edit calls */
- int editlevel;
-
- /* In process of being destroyed */
- gboolean do_free;
-
- /* dirty/clean flag. If dirty, then this instance has been modified,
- * but has not yet been written out to storage (file/database)
- */
- gboolean dirty;
-
- /* True iff this instance has never been committed. */
- gboolean infant;
-};
-
void qof_instance_set_slots (QofInstance *, KvpFrame *);
/* Set the last_update time. Reserved for use by the SQL backend;
=== lib/libqof/qof/qofinstance.h
==================================================================
--- lib/libqof/qof/qofinstance.h (revision 14365)
+++ lib/libqof/qof/qofinstance.h (local)
@@ -42,20 +42,122 @@
#include "qofbook.h"
#include "qofid.h"
+/* --- QOF GObject Macros */
+#define QOF_GOBJECT_DECL(basefcn) \
+ GType basefcn##_get_type(); \
+
+#define QOF_GOBJECT_IMPL_DECLS(basefcn,basetype) \
+ static void basefcn##_class_init(basetype##Class *klass); \
+ static void basefcn##_init(basetype *sp); \
+ static void basefcn##_finalize(GObject *object); \
+ static void basefcn##_finalize_real(GObject *object); \
+ static GObjectClass *parent_class = NULL;
+
+#define QOF_GOBJECT_IMPL_GET_TYPE(basefcn,basetype,parent,thistype) \
+ GType basefcn##_get_type() \
+ { \
+ static GType type = 0; \
+ \
+ if (type == 0) \
+ { \
+ static const GTypeInfo our_info = \
+ { \
+ sizeof(basetype##Class), \
+ NULL, \
+ NULL, \
+ (GClassInitFunc)basefcn_class_init, \
+ NULL, \
+ NULL, \
+ sizeof(basetype), \
+ 0, \
+ (GInstanceInitFunc)basefcn##_init, \
+ }; \
+ \
+ type = g_type_register_static(parent, thistype, &our_info, 0); \
+ } \
+ \
+ return type; \
+ }
+
+#define QOF_GOBJECT_IMPL_CLASS_INIT(basefcn,basetype) \
+ static void basefcn##_class_init(basetype##Class *klass) \
+ { \
+ GObjectClass *object_class = G_OBJECT_CLASS(klass); \
+ \
+ parent_class = g_type_class_peek_parent(klass); \
+ object_class->finalize = basefcn##_finalize; \
+ }
+
+#define QOF_GOBJECT_IMPL_FINALIZE(basefcn) \
+ static void basefcn##_finalize(GObject *object) \
+ { \
+ basefcn##_finalize_real(object); \
+ G_OBJECT_CLASS(parent_class)->finalize(object); \
+ }
+
+#define QOF_GOBJECT_IMPL(basefcn,basetype,parent,thistype) \
+ QOF_GOBJECT_IMPL_DECLS(basefcn,basetype); \
+ QOF_GOBJECT_IMPL_GET_TYPE(basefcn,basetype,parent,thistype); \
+ QOF_GOBJECT_IMPL_CLASS_INIT(basefcn,basetype); \
+ QOF_GOBJECT_IMPL_FINALIZE(basefcn);
+
/* --- type macros --- */
/* cheesy, but will do for now, eventually should be more gtk-like, handle
* thunks, etc. */
#define QOF_INSTANCE(object) ((QofInstance *)(object))
-/*typedef struct QofInstance_s QofInstance;*/
+struct QofInstance_s
+{
+ GObject object;
+ /* Globally unique id identifying this instance */
+ QofIdType e_type; /**< Entity type */
+ GUID guid; /**< GUID for the entity */
+ QofCollection * collection; /**< Entity collection */
+
+ /* The entity_table in which this instance is stored */
+ QofBook * book;
+
+ /* kvp_data is a key-value pair database for storing arbirtary
+ * information associated with this instance.
+ * See src/engine/kvp_doc.txt for a list and description of the
+ * important keys. */
+ KvpFrame *kvp_data;
+
+ /* Timestamp used to track the last modification to this
+ * instance. Typically used to compare two versions of the
+ * same object, to see which is newer. When used with the
+ * SQL backend, this field is reserved for SQL use, to compare
+ * the version in local memory to the remote, server version.
+ */
+ Timespec last_update;
+
+ /* Keep track of nesting level of begin/end edit calls */
+ int editlevel;
+
+ /* In process of being destroyed */
+ gboolean do_free;
+
+ /* dirty/clean flag. If dirty, then this instance has been modified,
+ * but has not yet been written out to storage (file/database)
+ */
+ gboolean dirty;
+
+ /* True iff this instance has never been committed. */
+ gboolean infant;
+};
+
+struct _QofInstanceClass
+{
+ GObjectClass parent_class;
+};
+
+/** Return the GType of a QofInstance */
+GType qof_instance_get_type();
+
/** Initialise the memory associated with an instance */
-void qof_instance_init (QofInstance *, QofIdType, QofBook *);
+void qof_instance_init_full (QofInstance *, QofIdType, QofBook *);
-/** release the data associated with this instance. Dont actually free
- * the memory associated with the instance. */
-void qof_instance_release (QofInstance *inst);
-
/** Return the book pointer */
QofBook * qof_instance_get_book (const QofInstance *);