convert QofInstance to using GObject

note that this breaks the build of this branch, and that the
build will remain broken until each of the objects is converted
over to basic GObject support.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev-warlord@15781 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/gobject-engine-dev-warlord
Derek Atkins 19 years ago
parent ab60ce2a6a
commit 44103fd12f

@ -33,7 +33,8 @@
* for the QofInstance type you would need to define the following
* macros:
*
* #define #define QOF_INSTANCE(o) \
* #define QOF_TYPE_INSTANCE (qof_instance_get_type ())
* #define QOF_INSTANCE(o) \
* (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
* #define QOF_INSTANCE_CLASS(k) \
* (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
@ -47,7 +48,7 @@
* @param type_name The function type_name for this type
*/
#define QOF_GOBJECT_DECL(type_name) \
GType type_name##_get_type();
GType type_name##_get_type(void);
/**
* The following macros are for convenience in your QOF object
@ -67,10 +68,11 @@
}
#define QOF_GOBJECT_FINALIZE(type_name) \
static void type_name##_finalize_real(GObject* object); \
static void type_name##_finalize(GObject *object) \
{ \
type_name##_finalize_real(object); \
G_OBJECT_CLASS(type_name##parent_class)->finalize(object); \
G_OBJECT_CLASS(type_name##_parent_class)->finalize(object); \
}
#define QOF_GOBJECT_IMPL_WITH_CODE(type_name, TypeName, TYPE_PARENT, CODE) \

@ -39,24 +39,12 @@ static QofLogModule log_module = QOF_MOD_ENGINE;
/* ========================================================== */
QofInstance*
qof_instance_create (QofIdType type, QofBook *book)
{
QofInstance *inst;
inst = g_new0(QofInstance, 1);
qof_instance_init(inst, type, book);
return inst;
}
QOF_GOBJECT_IMPL(qof_instance, QofInstance, G_TYPE_OBJECT);
void
qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
static void
qof_instance_init (QofInstance *inst)
{
QofCollection *col;
inst->book = book;
inst->book = NULL;
inst->kvp_data = kvp_frame_new();
inst->last_update.tv_sec = 0;
inst->last_update.tv_nsec = -1;
@ -64,14 +52,25 @@ qof_instance_init (QofInstance *inst, QofIdType type, QofBook *book)
inst->do_free = FALSE;
inst->dirty = FALSE;
inst->infant = TRUE;
}
void
qof_instance_init_data (QofInstance *inst, QofIdType type, QofBook *book)
{
QofCollection *col;
g_return_if_fail(QOF_IS_INSTANCE(inst));
g_return_if_fail(!inst->book);
inst->book = book;
col = qof_book_get_collection (book, type);
qof_entity_init (inst, type, col);
}
void
qof_instance_release (QofInstance *inst)
static void
qof_instance_finalize_real (GObject *instp)
{
QofInstance* inst = QOF_INSTANCE(instp);
kvp_frame_delete (inst->kvp_data);
inst->kvp_data = NULL;
inst->editlevel = 0;

@ -36,17 +36,27 @@
#ifndef QOF_INSTANCE_H
#define QOF_INSTANCE_H
typedef struct _QofInstanceClass QofInstanceClass;
#include "qofid.h"
#include "guid.h"
#include "gnc-date.h"
#include "kvp_frame.h"
#include "qofbook.h"
#include "qofid.h"
#include "qof-gobject.h"
/* --- type macros --- */
/* cheesy, but will do for now, eventually should be more gtk-like, handle
* thunks, etc. */
#define QOF_INSTANCE(object) ((QofInstance *)(object))
#define QOF_TYPE_INSTANCE (qof_instance_get_type ())
#define QOF_INSTANCE(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_INSTANCE, QofInstance))
#define QOF_INSTANCE_CLASS(k) \
(G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_INSTANCE, QofInstanceClass))
#define QOF_IS_INSTANCE(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_INSTANCE))
#define QOF_IS_INSTANCE_CLASS(k) \
(G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_INSTANCE))
#define QOF_INSTANCE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_INSTANCE, QofInstanceClass))
struct QofInstance_s
{
@ -95,15 +105,10 @@ struct _QofInstanceClass
};
/** Return the GType of a QofInstance */
GType qof_instance_get_type();
GType qof_instance_get_type(void);
/** Initialise the memory associated with an instance */
#if 1
void qof_instance_init (QofInstance *, QofIdType, QofBook *);
void qof_instance_release (QofInstance *);
#else
/** Initialise the settings associated with an instance */
void qof_instance_init_data (QofInstance *, QofIdType, QofBook *);
#endif
/** Return the book pointer */
QofBook * qof_instance_get_book (const QofInstance *);
@ -150,8 +155,6 @@ gboolean qof_instance_do_free(const QofInstance *inst);
void qof_instance_mark_free(QofInstance *inst);
QofInstance* qof_instance_create (QofIdType type, QofBook *book);
/** Pair things up. This routine inserts a kvp value into each instance
* containing the guid of the other. In this way, if one has one of the
* pair, one can always find the other by looking up it's guid. Typically,

Loading…
Cancel
Save