mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
get libqof to build using GObject
- migrate QofBook to GObject - move around some typedef to get libqof to build again git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev-warlord@15784 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -43,65 +43,6 @@
|
||||
#include "qofid-p.h"
|
||||
#include "qofinstance-p.h"
|
||||
|
||||
/* Book structure */
|
||||
struct _QofBook
|
||||
{
|
||||
QofInstance inst; /* Unique guid for this book. */
|
||||
|
||||
/* The time when the book was first dirtied. This is a secondary
|
||||
* indicator. It should only be used when inst.dirty is TRUE. */
|
||||
time_t dirty_time;
|
||||
|
||||
/* This callback function is called any time the book dirty flag
|
||||
* changes state. Both clean->dirty and dirty->clean transitions
|
||||
* trigger a callback. */
|
||||
QofBookDirtyCB dirty_cb;
|
||||
|
||||
/* This is the user supplied data that is returned in the dirty
|
||||
* callback function.*/
|
||||
gpointer dirty_data;
|
||||
|
||||
/* The entity table associates the GUIDs of all the objects
|
||||
* belonging to this book, with their pointers to the respective
|
||||
* objects. This allows a lookup of objects based on thier guid.
|
||||
*/
|
||||
GHashTable * hash_of_collections;
|
||||
|
||||
/* In order to store arbitrary data, for extensibility, add a table
|
||||
* that will be used to hold arbitrary pointers.
|
||||
*/
|
||||
GHashTable *data_tables;
|
||||
|
||||
/* Hash table of destroy callbacks for the data table. */
|
||||
GHashTable *data_table_finalizers;
|
||||
|
||||
/* state flag: 'y' means 'open for editing',
|
||||
* 'n' means 'book is closed'
|
||||
* xxxxx shouldn't this be replaced by the instance editlevel ???
|
||||
*/
|
||||
char book_open;
|
||||
|
||||
/* a flag denoting whether the book is closing down, used to
|
||||
* help the QOF objects shut down cleanly without maintaining
|
||||
* internal consistency.
|
||||
* XXX shouldn't this be replaced by instance->do_free ???
|
||||
*/
|
||||
gboolean shutting_down;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
|
||||
/* To be technically correct, backends belong to sessions and
|
||||
* not books. So the pointer below "really shouldn't be here",
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
/*
|
||||
* qof_book_set_backend() is used by backends to
|
||||
* initialize the pointers in the book structure to
|
||||
|
@@ -48,6 +48,8 @@
|
||||
|
||||
static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||
|
||||
QOF_GOBJECT_IMPL(qof_book, QofBook, QOF_TYPE_INSTANCE);
|
||||
|
||||
/* ====================================================================== */
|
||||
/* constructor / destructor */
|
||||
|
||||
@@ -66,7 +68,7 @@ qof_book_init (QofBook *book)
|
||||
(GDestroyNotify)qof_util_string_cache_remove, /* key_destroy_func */
|
||||
coll_destroy); /* value_destroy_func */
|
||||
|
||||
qof_instance_init (&book->inst, QOF_ID_BOOK, book);
|
||||
qof_instance_init_data (&book->inst, QOF_ID_BOOK, book);
|
||||
|
||||
book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
book->data_table_finalizers = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
@@ -82,8 +84,7 @@ qof_book_new (void)
|
||||
QofBook *book;
|
||||
|
||||
ENTER (" ");
|
||||
book = g_new0(QofBook, 1);
|
||||
qof_book_init(book);
|
||||
book = g_object_new(QOF_TYPE_BOOK, NULL);
|
||||
qof_object_book_begin (book);
|
||||
|
||||
qof_event_gen (&book->inst, QOF_EVENT_CREATE, NULL);
|
||||
@@ -101,6 +102,11 @@ book_final (gpointer key, gpointer value, gpointer booq)
|
||||
(*cb) (book, key, user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
qof_book_finalize_real (GObject *bookp)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_destroy (QofBook *book)
|
||||
{
|
||||
@@ -122,12 +128,12 @@ qof_book_destroy (QofBook *book)
|
||||
g_hash_table_destroy (book->data_tables);
|
||||
book->data_tables = NULL;
|
||||
|
||||
qof_instance_release (&book->inst);
|
||||
/* qof_instance_release (&book->inst); */
|
||||
|
||||
g_hash_table_destroy (book->hash_of_collections);
|
||||
book->hash_of_collections = NULL;
|
||||
|
||||
g_free (book);
|
||||
g_object_unref (book);
|
||||
LEAVE ("book=%p", book);
|
||||
}
|
||||
|
||||
|
@@ -40,8 +40,92 @@
|
||||
#ifndef QOF_BOOK_H
|
||||
#define QOF_BOOK_H
|
||||
|
||||
typedef struct _QofBookClass QofBookClass;
|
||||
|
||||
#include "qofid.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofinstance.h"
|
||||
|
||||
/* --- type macros --- */
|
||||
#define QOF_TYPE_BOOK (qof_book_get_type ())
|
||||
#define QOF_BOOK(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
|
||||
#define QOF_BOOK_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
|
||||
#define QOF_IS_BOOK(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
|
||||
#define QOF_IS_BOOK_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
|
||||
#define QOF_BOOK_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
|
||||
|
||||
typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
|
||||
|
||||
/* Book structure */
|
||||
struct _QofBook
|
||||
{
|
||||
QofInstance inst; /* Unique guid for this book. */
|
||||
|
||||
/* The time when the book was first dirtied. This is a secondary
|
||||
* indicator. It should only be used when inst.dirty is TRUE. */
|
||||
time_t dirty_time;
|
||||
|
||||
/* This callback function is called any time the book dirty flag
|
||||
* changes state. Both clean->dirty and dirty->clean transitions
|
||||
* trigger a callback. */
|
||||
QofBookDirtyCB dirty_cb;
|
||||
|
||||
/* This is the user supplied data that is returned in the dirty
|
||||
* callback function.*/
|
||||
gpointer dirty_data;
|
||||
|
||||
/* The entity table associates the GUIDs of all the objects
|
||||
* belonging to this book, with their pointers to the respective
|
||||
* objects. This allows a lookup of objects based on thier guid.
|
||||
*/
|
||||
GHashTable * hash_of_collections;
|
||||
|
||||
/* In order to store arbitrary data, for extensibility, add a table
|
||||
* that will be used to hold arbitrary pointers.
|
||||
*/
|
||||
GHashTable *data_tables;
|
||||
|
||||
/* Hash table of destroy callbacks for the data table. */
|
||||
GHashTable *data_table_finalizers;
|
||||
|
||||
/* state flag: 'y' means 'open for editing',
|
||||
* 'n' means 'book is closed'
|
||||
* xxxxx shouldn't this be replaced by the instance editlevel ???
|
||||
*/
|
||||
char book_open;
|
||||
|
||||
/* a flag denoting whether the book is closing down, used to
|
||||
* help the QOF objects shut down cleanly without maintaining
|
||||
* internal consistency.
|
||||
* XXX shouldn't this be replaced by instance->do_free ???
|
||||
*/
|
||||
gboolean shutting_down;
|
||||
|
||||
/* version number, used for tracking multiuser updates */
|
||||
gint32 version;
|
||||
|
||||
/* To be technically correct, backends belong to sessions and
|
||||
* not books. So the pointer below "really shouldn't be here",
|
||||
* except that it provides a nice convenience, avoiding a lookup
|
||||
* from the session. Better solutions welcome ... */
|
||||
QofBackend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
struct _QofBookClass
|
||||
{
|
||||
QofInstanceClass parent_class;
|
||||
};
|
||||
|
||||
GType qof_book_get_type(void);
|
||||
|
||||
/** @brief Encapsulates all the information about a dataset
|
||||
* manipulated by QOF. This is the top-most structure
|
||||
@@ -59,14 +143,10 @@
|
||||
(c_type *) val; \
|
||||
})
|
||||
|
||||
/** \brief QofBook reference */
|
||||
typedef struct _QofBook QofBook;
|
||||
|
||||
/** GList of QofBook */
|
||||
typedef GList QofBookList;
|
||||
|
||||
typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
|
||||
typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
|
||||
|
||||
/** Register the book object with the QOF object system. */
|
||||
gboolean qof_book_register (void);
|
||||
|
@@ -83,8 +83,9 @@ typedef const gchar * QofIdTypeConst;
|
||||
/** QofLogModule declaration */
|
||||
typedef const gchar* QofLogModule;
|
||||
|
||||
/* Forward declaration for later */
|
||||
typedef struct QofInstance_s QofInstance;
|
||||
typedef struct QofCollection_s QofCollection;
|
||||
|
||||
#include "qofinstance.h"
|
||||
|
||||
#define QOF_ID_NONE NULL
|
||||
#define QOF_ID_NULL "null"
|
||||
@@ -133,8 +134,6 @@ print error message if its bad */
|
||||
@param data gpointer, place where object class can hang arbitrary data
|
||||
|
||||
*/
|
||||
typedef struct QofCollection_s QofCollection;
|
||||
|
||||
void qof_entity_init (QofInstance *ent, QofIdType type, QofCollection * tab);
|
||||
void qof_entity_release (QofInstance *ent);
|
||||
void qof_instance_set_guid (QofInstance *ent, const GUID *guid);
|
||||
|
@@ -37,12 +37,15 @@
|
||||
#define QOF_INSTANCE_H
|
||||
|
||||
typedef struct _QofInstanceClass QofInstanceClass;
|
||||
typedef struct QofInstance_s QofInstance;
|
||||
|
||||
/** \brief QofBook reference */
|
||||
typedef struct _QofBook QofBook;
|
||||
|
||||
#include "qofid.h"
|
||||
#include "guid.h"
|
||||
#include "gnc-date.h"
|
||||
#include "kvp_frame.h"
|
||||
#include "qofbook.h"
|
||||
#include "qof-gobject.h"
|
||||
|
||||
/* --- type macros --- */
|
||||
|
Reference in New Issue
Block a user