mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-02 05:29:20 -06:00
rename gncObject to QofObject
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8689 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
50906151db
commit
5770f0ca0d
@ -46,10 +46,10 @@
|
||||
#include "kvp-util-p.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "QueryObject.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
static short module = MOD_ACCOUNT;
|
||||
|
||||
@ -3175,7 +3175,7 @@ account_foreach (QofBook *book, foreachObjectCB cb, gpointer ud)
|
||||
xaccForeachEntity (et, GNC_ID_ACCOUNT, cb, ud);
|
||||
}
|
||||
|
||||
static GncObject_t account_object_def = {
|
||||
static QofObject account_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_ACCOUNT,
|
||||
"Account",
|
||||
@ -3208,7 +3208,7 @@ gboolean xaccAccountRegister (void)
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_ACCOUNT, (QuerySort)xaccAccountOrder, params);
|
||||
|
||||
return gncObjectRegister (&account_object_def);
|
||||
return qof_object_register (&account_object_def);
|
||||
}
|
||||
|
||||
/* ======================= END OF FILE =========================== */
|
||||
|
@ -38,9 +38,9 @@
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-numeric.h"
|
||||
#include "gncObject.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
@ -1315,7 +1315,7 @@ group_mark_clean(QofBook *book)
|
||||
xaccGroupMarkSaved(xaccGetAccountGroup(book));
|
||||
}
|
||||
|
||||
static GncObject_t group_object_def =
|
||||
static QofObject group_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
name: GNC_ID_GROUP,
|
||||
@ -1331,7 +1331,7 @@ static GncObject_t group_object_def =
|
||||
gboolean
|
||||
xaccGroupRegister (void)
|
||||
{
|
||||
return gncObjectRegister (&group_object_def);
|
||||
return qof_object_register (&group_object_def);
|
||||
}
|
||||
|
||||
/* ========================= END OF FILE ======================== */
|
||||
|
@ -40,12 +40,12 @@ libgncmod_engine_la_SOURCES = \
|
||||
gnc-trace.c \
|
||||
gncmod-engine.c \
|
||||
guid.c \
|
||||
gncObject.c \
|
||||
kvp_frame.c \
|
||||
kvp-util.c \
|
||||
md5.c \
|
||||
messages.c \
|
||||
qofbook.c
|
||||
qofbook.c \
|
||||
qofobject.c
|
||||
|
||||
EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
|
||||
|
||||
@ -89,7 +89,8 @@ gncinclude_HEADERS = \
|
||||
kvp-scm.h \
|
||||
kvp-util.h \
|
||||
messages.h \
|
||||
qofbook.h
|
||||
qofbook.h \
|
||||
qofobject.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
AccountP.h \
|
||||
@ -111,12 +112,12 @@ noinst_HEADERS = \
|
||||
gnc-lot-p.h \
|
||||
gnc-pricedb-p.h \
|
||||
gnc-session-p.h \
|
||||
gncObjectP.h \
|
||||
kvp-util-p.h \
|
||||
md5.h \
|
||||
gw-engine.h \
|
||||
gw-kvp.h \
|
||||
qofbook-p.h
|
||||
qofbook-p.h \
|
||||
qofobject-p.h
|
||||
|
||||
noinst_SCRIPTS = iso-currencies-to-c
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gncObject.h"
|
||||
#include "BackendP.h"
|
||||
|
||||
#include "QueryObjectP.h"
|
||||
@ -38,12 +37,13 @@
|
||||
#include "QueryNewP.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
static short module = MOD_QUERY;
|
||||
|
||||
typedef struct query_new_term {
|
||||
GSList * param_list;
|
||||
QueryPredData_t pdata;
|
||||
QueryPredData_t pdata;
|
||||
gboolean invert;
|
||||
|
||||
/* These values are filled in during "compilation" of the query
|
||||
@ -52,22 +52,22 @@ typedef struct query_new_term {
|
||||
* convert types.
|
||||
*/
|
||||
GSList * param_fcns;
|
||||
QueryPredicate pred_fcn;
|
||||
QueryPredicate pred_fcn;
|
||||
} QueryNewTerm;
|
||||
|
||||
typedef struct query_new_sort {
|
||||
GSList * param_list;
|
||||
GSList * param_list;
|
||||
gint options;
|
||||
gboolean increasing;
|
||||
gboolean increasing;
|
||||
|
||||
/* These values are filled in during "compilation" of the query
|
||||
* term, based upon the obj_name, param_name, and searched-for
|
||||
* object type. If conv_fcn is NULL, then we don't know how to
|
||||
* convert types.
|
||||
*/
|
||||
gboolean use_default;
|
||||
GSList * param_fcns;
|
||||
QuerySort obj_cmp; /* In case you are comparing objects */
|
||||
gboolean use_default;
|
||||
GSList * param_fcns;
|
||||
QuerySort obj_cmp; /* In case you are comparing objects */
|
||||
QueryCompare comp_fcn; /* When you are comparing core types */
|
||||
} QueryNewSort;
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "Group.h"
|
||||
@ -48,6 +47,7 @@
|
||||
#include "SX-book-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
static short module = MOD_SX;
|
||||
|
||||
@ -205,7 +205,7 @@ sxtt_mark_clean(QofBook *book)
|
||||
}
|
||||
|
||||
|
||||
static GncObject_t sxtt_object_def =
|
||||
static QofObject sxtt_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
name: GNC_ID_SXTT,
|
||||
@ -221,7 +221,7 @@ static GncObject_t sxtt_object_def =
|
||||
gboolean
|
||||
gnc_sxtt_register (void)
|
||||
{
|
||||
return gncObjectRegister (&sxtt_object_def);
|
||||
return qof_object_register (&sxtt_object_def);
|
||||
}
|
||||
|
||||
/* ========================== END OF FILE =============================== */
|
||||
|
@ -48,8 +48,8 @@
|
||||
#include "messages.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "QueryObject.h"
|
||||
|
||||
/*
|
||||
@ -3561,7 +3561,7 @@ split_foreach (QofBook *book, foreachObjectCB fcn, gpointer user_data)
|
||||
|
||||
/* hook into the gncObject registry */
|
||||
|
||||
static GncObject_t split_object_def = {
|
||||
static QofObject split_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_SPLIT,
|
||||
"Split",
|
||||
@ -3638,7 +3638,7 @@ gboolean xaccSplitRegister (void)
|
||||
(QuerySort)xaccSplitCompareOtherAccountCodes,
|
||||
NULL);
|
||||
|
||||
return gncObjectRegister (&split_object_def);
|
||||
return qof_object_register (&split_object_def);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3647,7 +3647,7 @@ trans_foreach (QofBook *book, foreachObjectCB fcn, gpointer user_data)
|
||||
do_foreach (book, GNC_ID_TRANS, fcn, user_data);
|
||||
}
|
||||
|
||||
static GncObject_t trans_object_def = {
|
||||
static QofObject trans_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_TRANS,
|
||||
"Transaction",
|
||||
@ -3691,7 +3691,7 @@ gboolean xaccTransRegister (void)
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_TRANS, (QuerySort)xaccTransOrder, params);
|
||||
|
||||
return gncObjectRegister (&trans_object_def);
|
||||
return qof_object_register (&trans_object_def);
|
||||
}
|
||||
|
||||
/************************ END OF ************************************\
|
||||
|
@ -1,104 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-book-p.h -- private functions for gnc books. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* HISTORY:
|
||||
* Created 2001 by Rob Browning
|
||||
* Copyright (c) 2001 Rob Browning
|
||||
* Copyright (c) 2001,2003 Linas Vepstas <linas@linas.org>
|
||||
*/
|
||||
|
||||
#ifndef GNC_BOOK_P_H
|
||||
#define GNC_BOOK_P_H
|
||||
|
||||
#include "Backend.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "gnc-book.h"
|
||||
#include "kvp_frame.h"
|
||||
|
||||
struct gnc_book_struct
|
||||
{
|
||||
/* Unique guid for this book. */
|
||||
GUID guid;
|
||||
|
||||
/* The kvp_frame provides a place for top-level data associated
|
||||
* with this book. */
|
||||
kvp_frame *kvp_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.
|
||||
*/
|
||||
GNCEntityTable *entity_table;
|
||||
|
||||
/* In order to store arbitrary data, for extensibility, add a table
|
||||
* that will be used to hold arbitrary pointers.
|
||||
*/
|
||||
GHashTable *data_tables;
|
||||
|
||||
/* state flag: 'y' means 'open for editing',
|
||||
* 'n' means 'book is closed'
|
||||
*/
|
||||
char book_open;
|
||||
|
||||
/* dirty/clean flag. If dirty, then this book has been modified,
|
||||
* but has not yet been written out to storage (file/database)
|
||||
*/
|
||||
gboolean dirty;
|
||||
|
||||
/* 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 ... */
|
||||
Backend *backend;
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
/* Backend private expansion data */
|
||||
guint32 idata; /* used by the sql backend for kvp management */
|
||||
};
|
||||
|
||||
/*
|
||||
* These gnc_book_set_*() routines are used by backends to
|
||||
* initialize the pointers in the book structure to
|
||||
* something that contains actual data. These routines
|
||||
* should not be used otherwise. (Its somewhat questionable
|
||||
* if the backends should even be doing this much, but for
|
||||
* backwards compatibility, we leave these here.)
|
||||
*/
|
||||
void gnc_book_set_guid(GNCBook *book, GUID guid);
|
||||
void gnc_book_set_schedxactions( GNCBook *book, GList *newList );
|
||||
|
||||
void gnc_book_set_backend (GNCBook *book, Backend *be);
|
||||
|
||||
/* The gnc_book_mark_saved() routine marks the book as having been
|
||||
* saved (to a file, to a database). Used by backends to mark the
|
||||
* notsaved flag as FALSE just after loading. Do not use otherwise!
|
||||
*/
|
||||
void gnc_book_mark_saved(GNCBook *book);
|
||||
|
||||
/* Register books with the engine */
|
||||
gboolean gnc_book_register (void);
|
||||
|
||||
#endif /* GNC_BOOK_P_H */
|
@ -1,306 +0,0 @@
|
||||
/********************************************************************\
|
||||
* gnc-book.c -- dataset access (set of accounting books) *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* gnc-book.c
|
||||
*
|
||||
* FUNCTION:
|
||||
* Encapsulate all the information about a gnucash dataset.
|
||||
* See src/doc/books.txt for design overview.
|
||||
*
|
||||
* HISTORY:
|
||||
* Created by Linas Vepstas December 1998
|
||||
* Copyright (c) 1998-2001,2003 Linas Vepstas <linas@linas.org>
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "Backend.h"
|
||||
#include "BackendP.h"
|
||||
#include "QueryObject.h"
|
||||
#include "gnc-book.h"
|
||||
#include "gnc-book-p.h"
|
||||
#include "gnc-event.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "gncObjectP.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
/* ====================================================================== */
|
||||
/* constructor / destructor */
|
||||
|
||||
static void
|
||||
gnc_book_init (GNCBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
|
||||
book->entity_table = xaccEntityTableNew ();
|
||||
|
||||
xaccGUIDNew(&book->guid, book);
|
||||
xaccStoreEntity(book->entity_table, book, &book->guid, GNC_ID_BOOK);
|
||||
|
||||
book->kvp_data = kvp_frame_new ();
|
||||
|
||||
book->data_tables = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
book->book_open = 'y';
|
||||
book->version = 0;
|
||||
book->idata = 0;
|
||||
}
|
||||
|
||||
GNCBook *
|
||||
gnc_book_new (void)
|
||||
{
|
||||
GNCBook *book;
|
||||
|
||||
ENTER (" ");
|
||||
book = g_new0(GNCBook, 1);
|
||||
gnc_book_init(book);
|
||||
gncObjectBookBegin (book);
|
||||
|
||||
#if 0
|
||||
gnc_engine_generate_event (&book->guid, GNC_EVENT_CREATE);
|
||||
#endif
|
||||
LEAVE ("book=%p", book);
|
||||
return book;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_book_destroy (GNCBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
|
||||
ENTER ("book=%p", book);
|
||||
gnc_engine_force_event (&book->guid, GNC_EVENT_DESTROY);
|
||||
|
||||
gncObjectBookEnd (book);
|
||||
|
||||
xaccRemoveEntity (book->entity_table, &book->guid);
|
||||
xaccEntityTableDestroy (book->entity_table);
|
||||
book->entity_table = NULL;
|
||||
|
||||
/* FIXME: Make sure the data_table is empty */
|
||||
g_hash_table_destroy (book->data_tables);
|
||||
|
||||
g_free (book);
|
||||
LEAVE ("book=%p", book);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
/* XXX this should probably be calling is_equal callbacks on gncObject */
|
||||
|
||||
gboolean
|
||||
gnc_book_equal (GNCBook *book_1, GNCBook *book_2)
|
||||
{
|
||||
if (book_1 == book_2) return TRUE;
|
||||
if (!book_1 || !book_2) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
gboolean
|
||||
gnc_book_not_saved(GNCBook *book)
|
||||
{
|
||||
if (!book) return FALSE;
|
||||
|
||||
return(book->dirty || gncObjectIsDirty (book));
|
||||
}
|
||||
|
||||
void
|
||||
gnc_book_mark_saved(GNCBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
|
||||
book->dirty = FALSE;
|
||||
gncObjectMarkClean (book);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
/* getters */
|
||||
|
||||
const GUID *
|
||||
gnc_book_get_guid (GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return &book->guid;
|
||||
}
|
||||
|
||||
kvp_frame *
|
||||
gnc_book_get_slots (GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return book->kvp_data;
|
||||
}
|
||||
|
||||
GNCEntityTable *
|
||||
gnc_book_get_entity_table (GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return book->entity_table;
|
||||
}
|
||||
|
||||
Backend *
|
||||
xaccGNCBookGetBackend (GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return book->backend;
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
/* setters */
|
||||
|
||||
void
|
||||
gnc_book_set_guid (GNCBook *book, GUID uid)
|
||||
{
|
||||
if (!book) return;
|
||||
|
||||
if (guid_equal (&book->guid, &uid)) return;
|
||||
|
||||
xaccRemoveEntity(book->entity_table, &book->guid);
|
||||
book->guid = uid;
|
||||
xaccStoreEntity(book->entity_table, book, &book->guid, GNC_ID_BOOK);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_book_set_backend (GNCBook *book, Backend *be)
|
||||
{
|
||||
if (!book) return;
|
||||
ENTER ("book=%p be=%p", book, be);
|
||||
book->backend = be;
|
||||
}
|
||||
|
||||
gpointer gnc_book_get_backend (GNCBook *book)
|
||||
{
|
||||
if (!book) return NULL;
|
||||
return (gpointer)book->backend;
|
||||
}
|
||||
|
||||
|
||||
void gnc_book_kvp_changed (GNCBook *book)
|
||||
{
|
||||
if (!book) return;
|
||||
book->dirty = TRUE;
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
/* Store arbitrary pointers in the GNCBook for data storage extensibility */
|
||||
/* XXX if data is NULL, we ashould remove the key from the hash table!
|
||||
*
|
||||
* XXX We need some design comments: an equivalent storage mechanism
|
||||
* would have been to give each item a GUID, store the GUID in a kvp frame,
|
||||
* and then do a GUID lookup to get the pointer to the actual object.
|
||||
* Of course, doing a kvp lookup followed by a GUID lookup would be
|
||||
* a good bit slower, but may be that's OK? In most cases, book data
|
||||
* is accessed only infrequently? --linas
|
||||
*/
|
||||
void
|
||||
gnc_book_set_data (GNCBook *book, const char *key, gpointer data)
|
||||
{
|
||||
if (!book || !key) return;
|
||||
g_hash_table_insert (book->data_tables, (gpointer)key, data);
|
||||
}
|
||||
|
||||
gpointer
|
||||
gnc_book_get_data (GNCBook *book, const char *key)
|
||||
{
|
||||
if (!book || !key) return NULL;
|
||||
return g_hash_table_lookup (book->data_tables, (gpointer)key);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
gint64
|
||||
gnc_book_get_counter (GNCBook *book, const char *counter_name)
|
||||
{
|
||||
Backend *be;
|
||||
kvp_frame *kvp;
|
||||
kvp_value *value;
|
||||
gint64 counter;
|
||||
|
||||
if (!book) {
|
||||
PWARN ("No book!!!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!counter_name || *counter_name == '\0') {
|
||||
PWARN ("Invalid counter name.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we've got a backend with a counter method, call it */
|
||||
be = book->backend;
|
||||
if (be && be->counter)
|
||||
return ((be->counter)(be, counter_name));
|
||||
|
||||
/* If not, then use the KVP in the book */
|
||||
kvp = gnc_book_get_slots (book);
|
||||
|
||||
if (!kvp) {
|
||||
PWARN ("Book has no KVP_Frame");
|
||||
return -1;
|
||||
}
|
||||
|
||||
value = kvp_frame_get_slot_path (kvp, "counters", counter_name, NULL);
|
||||
if (value) {
|
||||
/* found it */
|
||||
counter = kvp_value_get_gint64 (value);
|
||||
} else {
|
||||
/* New counter */
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
/* Counter is now valid; increment it */
|
||||
counter++;
|
||||
|
||||
/* Save off the new counter */
|
||||
value = kvp_value_new_gint64 (counter);
|
||||
kvp_frame_set_slot_path (kvp, value, "counters", counter_name, NULL);
|
||||
kvp_value_delete (value);
|
||||
|
||||
/* and return the value */
|
||||
return counter;
|
||||
}
|
||||
|
||||
/* gncObject function implementation and registration */
|
||||
gboolean gnc_book_register (void)
|
||||
{
|
||||
static QueryObjectDef params[] = {
|
||||
{ BOOK_KVP, QUERYCORE_KVP, (QueryAccess)gnc_book_get_slots },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gnc_book_get_guid },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_BOOK, NULL, params);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ========================== END OF FILE =============================== */
|
@ -31,12 +31,12 @@
|
||||
#include <stdio.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "guid.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
@ -1124,7 +1124,7 @@ commodity_table_book_end (QofBook *book)
|
||||
* Don't we have to save user-created/modified commodities?
|
||||
* I don't get it ... does this need fixing?
|
||||
*/
|
||||
static GncObject_t commodity_table_object_def =
|
||||
static QofObject commodity_table_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
name: GNC_ID_COMMODITY_TABLE,
|
||||
@ -1140,7 +1140,7 @@ static GncObject_t commodity_table_object_def =
|
||||
gboolean
|
||||
gnc_commodity_table_register (void)
|
||||
{
|
||||
return gncObjectRegister (&commodity_table_object_def);
|
||||
return qof_object_register (&commodity_table_object_def);
|
||||
}
|
||||
|
||||
/* ========================= END OF FILE ============================== */
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "GNCIdP.h"
|
||||
#include "QueryNewP.h"
|
||||
#include "gncObjectP.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
@ -40,6 +39,7 @@
|
||||
#include "gnc-pricedb-p.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject-p.h"
|
||||
|
||||
static GList * engine_init_hooks = NULL;
|
||||
static int engine_is_initialized = 0;
|
||||
@ -81,7 +81,7 @@ gnc_engine_init(int argc, char ** argv)
|
||||
gnc_engine_get_string_cache();
|
||||
|
||||
xaccGUIDInit ();
|
||||
gncObjectInitialize ();
|
||||
qof_object_initialize ();
|
||||
gncQueryNewInit ();
|
||||
|
||||
/* Now register our core types */
|
||||
@ -117,7 +117,7 @@ gnc_engine_shutdown (void)
|
||||
|
||||
gnc_engine_string_cache_destroy ();
|
||||
|
||||
gncObjectShutdown ();
|
||||
qof_object_shutdown ();
|
||||
xaccGUIDShutdown ();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "BackendP.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "gncObject.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-event-p.h"
|
||||
@ -38,6 +37,7 @@
|
||||
#include "kvp-util.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_PRICE;
|
||||
@ -1949,7 +1949,7 @@ pricedb_mark_clean(QofBook *book)
|
||||
gnc_pricedb_mark_clean(gnc_pricedb_get_db(book));
|
||||
}
|
||||
|
||||
static GncObject_t pricedb_object_def =
|
||||
static QofObject pricedb_object_def =
|
||||
{
|
||||
interface_version: GNC_OBJECT_VERSION,
|
||||
name: GNC_ID_PRICEDB,
|
||||
@ -1965,7 +1965,7 @@ static GncObject_t pricedb_object_def =
|
||||
gboolean
|
||||
gnc_pricedb_register (void)
|
||||
{
|
||||
return gncObjectRegister (&pricedb_object_def);
|
||||
return qof_object_register (&pricedb_object_def);
|
||||
}
|
||||
|
||||
/* ========================= END OF FILE ============================== */
|
||||
|
@ -1,112 +1,18 @@
|
||||
/********************************************************************\
|
||||
* gncObject.h -- the Core Object Registration/Lookup Interface *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
/** @addtogroup Engine
|
||||
@{ */
|
||||
/** @file gncObject.h
|
||||
* @breif the Core Object Registration/Lookup Interface
|
||||
*
|
||||
* @author Copyright (c) 2001,2002, Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifndef GNC_OBJECT_H_
|
||||
#define GNC_OBJECT_H_
|
||||
|
||||
#include "GNCId.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
/* Defines the version of the core object object registration
|
||||
* interface. Only object modules compiled against this version
|
||||
* of the interface will load properly
|
||||
*/
|
||||
#define GNC_OBJECT_VERSION 1
|
||||
|
||||
typedef struct _gncObjectDef GncObject_t;
|
||||
typedef void (*foreachTypeCB) (GncObject_t *type, gpointer user_data);
|
||||
typedef void (*foreachBackendTypeCB) (GNCIdTypeConst type,
|
||||
gpointer backend_data,
|
||||
gpointer user_data);
|
||||
|
||||
/* This is the Object Object descriptor */
|
||||
struct _gncObjectDef {
|
||||
gint interface_version; /* of this object interface */
|
||||
GNCIdType name; /* the Object's GNC_ID */
|
||||
const char * type_label; /* "Printable" type-label string */
|
||||
|
||||
/* book_begin is called from within the Book routines to create
|
||||
* module-specific hooks in a book whenever a book is created.
|
||||
* book_end is called when the book is being closed, to clean
|
||||
* up (and free memory).
|
||||
*/
|
||||
void (*book_begin)(QofBook *);
|
||||
void (*book_end)(QofBook *);
|
||||
|
||||
/* Determine if there are any dirty items in this book */
|
||||
gboolean (*is_dirty)(QofBook *);
|
||||
|
||||
/* Mark this object's book clean (for after a load) */
|
||||
void (*mark_clean)(QofBook *);
|
||||
|
||||
/* foreach() is used to execute a callback over each object
|
||||
* stored in the particular book
|
||||
*/
|
||||
void (*foreach)(QofBook *, foreachObjectCB, gpointer);
|
||||
|
||||
/* Given a particular object, return a printable string */
|
||||
const char * (*printable)(gpointer obj);
|
||||
|
||||
};
|
||||
|
||||
void gncObjectForeachType (foreachTypeCB cb, gpointer user_data);
|
||||
|
||||
void gncObjectForeach (GNCIdTypeConst type_name, QofBook *book,
|
||||
foreachObjectCB cb, gpointer user_data);
|
||||
|
||||
const char * gncObjectPrintable (GNCIdTypeConst type_name, gpointer obj);
|
||||
#include "qofobject.h"
|
||||
|
||||
|
||||
/* REGISTRATION AND REG-LOOKUP FUNCTIONS */
|
||||
#define GncObject_t QofObject
|
||||
#define gncObjectLookup qof_object_lookup
|
||||
#define gncObjectRegister qof_object_register
|
||||
#define gncObjectGetTypeLabel qof_object_get_type_label
|
||||
#define gncObjectRegisterBackend qof_object_register_backend
|
||||
#define gncObjectLookupBackend qof_object_lookup_backend
|
||||
#define gncObjectForeachBackend qof_object_foreach_backend
|
||||
|
||||
/** Register new types of object objects */
|
||||
gboolean gncObjectRegister (const GncObject_t *object);
|
||||
#define gncObjectInitialize qof_object_initialize
|
||||
#define gncObjectShutdown qof_object_shutdown
|
||||
#define gncObjectBookBegin qof_object_book_begin
|
||||
#define gncObjectBookEnd qof_object_book_end
|
||||
#define gncObjectIsDirty qof_object_is_dirty
|
||||
#define gncObjectMarkClean qof_object_mark_clean
|
||||
|
||||
/** Get the printable label for a type. This label is *not*
|
||||
* translated; you must use _() on it if you want a translated version.
|
||||
*/
|
||||
const char * gncObjectGetTypeLabel (GNCIdTypeConst type_name);
|
||||
|
||||
/** Lookup a object definition */
|
||||
const GncObject_t * gncObjectLookup (GNCIdTypeConst type_name);
|
||||
|
||||
|
||||
/** Register and lookup backend-specific data for this particular object */
|
||||
gboolean gncObjectRegisterBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name,
|
||||
gpointer be_data);
|
||||
|
||||
gpointer gncObjectLookupBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name);
|
||||
|
||||
void gncObjectForeachBackend (const char *backend_name,
|
||||
foreachBackendTypeCB cb,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* GNC_OBJECT_H_ */
|
||||
/** @} */
|
||||
|
@ -46,9 +46,9 @@
|
||||
#include "gnc-event.h"
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-trace.h"
|
||||
#include "gncObjectP.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofbook-p.h"
|
||||
#include "qofobject-p.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
@ -82,7 +82,7 @@ qof_book_new (void)
|
||||
ENTER (" ");
|
||||
book = g_new0(QofBook, 1);
|
||||
qof_book_init(book);
|
||||
gncObjectBookBegin (book);
|
||||
qof_object_book_begin (book);
|
||||
|
||||
#if 0
|
||||
gnc_engine_generate_event (&book->guid, GNC_EVENT_CREATE);
|
||||
@ -99,7 +99,7 @@ qof_book_destroy (QofBook *book)
|
||||
ENTER ("book=%p", book);
|
||||
gnc_engine_force_event (&book->guid, GNC_EVENT_DESTROY);
|
||||
|
||||
gncObjectBookEnd (book);
|
||||
qof_object_book_end (book);
|
||||
|
||||
xaccRemoveEntity (book->entity_table, &book->guid);
|
||||
xaccEntityTableDestroy (book->entity_table);
|
||||
@ -130,7 +130,7 @@ qof_book_not_saved(QofBook *book)
|
||||
{
|
||||
if (!book) return FALSE;
|
||||
|
||||
return(book->dirty || gncObjectIsDirty (book));
|
||||
return(book->dirty || qof_object_is_dirty (book));
|
||||
}
|
||||
|
||||
void
|
||||
@ -139,7 +139,7 @@ qof_book_mark_saved(QofBook *book)
|
||||
if (!book) return;
|
||||
|
||||
book->dirty = FALSE;
|
||||
gncObjectMarkClean (book);
|
||||
qof_object_mark_clean (book);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
@ -33,17 +33,16 @@
|
||||
#include "qofbook.h"
|
||||
|
||||
/* Initialize the object registration subsystem */
|
||||
/* XXX A better name would be 'ObjectClassInitialize ... */
|
||||
void gncObjectInitialize (void);
|
||||
void gncObjectShutdown (void);
|
||||
void qof_object_initialize (void);
|
||||
void qof_object_shutdown (void);
|
||||
|
||||
/* Note that the following are per-class and not per-instance */
|
||||
/* To be called from within the book */
|
||||
void gncObjectBookBegin (QofBook *book);
|
||||
void gncObjectBookEnd (QofBook *book);
|
||||
void qof_object_book_begin (QofBook *book);
|
||||
void qof_object_book_end (QofBook *book);
|
||||
|
||||
gboolean gncObjectIsDirty (QofBook *book);
|
||||
void gncObjectMarkClean (QofBook *book);
|
||||
gboolean qof_object_is_dirty (QofBook *book);
|
||||
void qof_object_mark_clean (QofBook *book);
|
||||
|
||||
#endif /* GNC_OBJECTP_H_ */
|
||||
/** @} */
|
@ -29,8 +29,8 @@
|
||||
#include <glib.h>
|
||||
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gncObject.h"
|
||||
#include "gncObjectP.h"
|
||||
#include "qofobject.h"
|
||||
#include "qofobject-p.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
static gboolean object_is_initialized = FALSE;
|
||||
@ -38,13 +38,13 @@ static GList *object_modules = NULL;
|
||||
static GList *book_list = NULL;
|
||||
static GHashTable *backend_data = NULL;
|
||||
|
||||
void gncObjectBookBegin (QofBook *book)
|
||||
void qof_object_book_begin (QofBook *book)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
if (!book) return;
|
||||
for (l = object_modules; l; l = l->next) {
|
||||
GncObject_t *obj = l->data;
|
||||
QofObject *obj = l->data;
|
||||
if (obj->book_begin)
|
||||
obj->book_begin (book);
|
||||
}
|
||||
@ -53,13 +53,13 @@ void gncObjectBookBegin (QofBook *book)
|
||||
book_list = g_list_prepend (book_list, book);
|
||||
}
|
||||
|
||||
void gncObjectBookEnd (QofBook *book)
|
||||
void qof_object_book_end (QofBook *book)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
if (!book) return;
|
||||
for (l = object_modules; l; l = l->next) {
|
||||
GncObject_t *obj = l->data;
|
||||
QofObject *obj = l->data;
|
||||
if (obj->book_end)
|
||||
obj->book_end (book);
|
||||
}
|
||||
@ -68,13 +68,13 @@ void gncObjectBookEnd (QofBook *book)
|
||||
book_list = g_list_remove (book_list, book);
|
||||
}
|
||||
|
||||
gboolean gncObjectIsDirty (QofBook *book)
|
||||
gboolean qof_object_is_dirty (QofBook *book)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
if (!book) return FALSE;
|
||||
for (l = object_modules; l; l = l->next) {
|
||||
GncObject_t *obj = l->data;
|
||||
QofObject *obj = l->data;
|
||||
if (obj->is_dirty)
|
||||
if (obj->is_dirty (book))
|
||||
return TRUE;
|
||||
@ -82,13 +82,13 @@ gboolean gncObjectIsDirty (QofBook *book)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void gncObjectMarkClean (QofBook *book)
|
||||
void qof_object_mark_clean (QofBook *book)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
if (!book) return;
|
||||
for (l = object_modules; l; l = l->next) {
|
||||
GncObject_t *obj = l->data;
|
||||
QofObject *obj = l->data;
|
||||
if (obj->mark_clean)
|
||||
(obj->mark_clean) (book);
|
||||
}
|
||||
@ -101,7 +101,7 @@ void gncObjectForeachType (foreachTypeCB cb, gpointer user_data)
|
||||
if (!cb) return;
|
||||
|
||||
for (l = object_modules; l; l = l->next) {
|
||||
GncObject_t *obj = l->data;
|
||||
QofObject *obj = l->data;
|
||||
(cb) (obj, user_data);
|
||||
}
|
||||
}
|
||||
@ -109,11 +109,11 @@ void gncObjectForeachType (foreachTypeCB cb, gpointer user_data)
|
||||
void gncObjectForeach (GNCIdTypeConst type_name, QofBook *book,
|
||||
foreachObjectCB cb, gpointer user_data)
|
||||
{
|
||||
const GncObject_t *obj;
|
||||
const QofObject *obj;
|
||||
|
||||
if (!book || !type_name) return;
|
||||
|
||||
obj = gncObjectLookup (type_name);
|
||||
obj = qof_object_lookup (type_name);
|
||||
if (!obj) return;
|
||||
|
||||
if (obj->foreach)
|
||||
@ -125,11 +125,11 @@ void gncObjectForeach (GNCIdTypeConst type_name, QofBook *book,
|
||||
const char *
|
||||
gncObjectPrintable (GNCIdTypeConst type_name, gpointer obj)
|
||||
{
|
||||
const GncObject_t *b_obj;
|
||||
const QofObject *b_obj;
|
||||
|
||||
if (!type_name || !obj) return NULL;
|
||||
|
||||
b_obj = gncObjectLookup (type_name);
|
||||
b_obj = qof_object_lookup (type_name);
|
||||
if (!b_obj) return NULL;
|
||||
|
||||
if (b_obj->printable)
|
||||
@ -138,13 +138,13 @@ gncObjectPrintable (GNCIdTypeConst type_name, gpointer obj)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * gncObjectGetTypeLabel (GNCIdTypeConst type_name)
|
||||
const char * qof_object_get_type_label (GNCIdTypeConst type_name)
|
||||
{
|
||||
const GncObject_t *obj;
|
||||
const QofObject *obj;
|
||||
|
||||
if (!type_name) return NULL;
|
||||
|
||||
obj = gncObjectLookup (type_name);
|
||||
obj = qof_object_lookup (type_name);
|
||||
if (!obj) return NULL;
|
||||
|
||||
return (obj->type_label);
|
||||
@ -158,14 +158,14 @@ static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
||||
|
||||
/* INITIALIZATION and PRIVATE FUNCTIONS */
|
||||
|
||||
void gncObjectInitialize (void)
|
||||
void qof_object_initialize (void)
|
||||
{
|
||||
if (object_is_initialized) return;
|
||||
backend_data = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
object_is_initialized = TRUE;
|
||||
}
|
||||
|
||||
void gncObjectShutdown (void)
|
||||
void qof_object_shutdown (void)
|
||||
{
|
||||
g_return_if_fail (object_is_initialized == TRUE);
|
||||
|
||||
@ -185,7 +185,7 @@ void gncObjectShutdown (void)
|
||||
* return FALSE if it fails, invalid arguments, or if the object
|
||||
* already exists
|
||||
*/
|
||||
gboolean gncObjectRegister (const GncObject_t *object)
|
||||
gboolean qof_object_register (const QofObject *object)
|
||||
{
|
||||
g_return_val_if_fail (object_is_initialized, FALSE);
|
||||
|
||||
@ -207,10 +207,10 @@ gboolean gncObjectRegister (const GncObject_t *object)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const GncObject_t * gncObjectLookup (GNCIdTypeConst name)
|
||||
const QofObject * qof_object_lookup (GNCIdTypeConst name)
|
||||
{
|
||||
GList *iter;
|
||||
const GncObject_t *obj;
|
||||
const QofObject *obj;
|
||||
|
||||
g_return_val_if_fail (object_is_initialized, NULL);
|
||||
|
||||
@ -224,7 +224,7 @@ const GncObject_t * gncObjectLookup (GNCIdTypeConst name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean gncObjectRegisterBackend (GNCIdTypeConst type_name,
|
||||
gboolean qof_object_registerBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name,
|
||||
gpointer be_data)
|
||||
{
|
||||
@ -250,7 +250,7 @@ gboolean gncObjectRegisterBackend (GNCIdTypeConst type_name,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gpointer gncObjectLookupBackend (GNCIdTypeConst type_name,
|
||||
gpointer qof_object_lookupBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name)
|
||||
{
|
||||
GHashTable *ht;
|
||||
@ -282,7 +282,7 @@ static void foreach_backend (gpointer key, gpointer be_item, gpointer arg)
|
||||
(cb_data->cb) (data_type, be_item, cb_data->user_data);
|
||||
}
|
||||
|
||||
void gncObjectForeachBackend (const char *backend_name,
|
||||
void qof_object_foreach_backend (const char *backend_name,
|
||||
foreachBackendTypeCB cb,
|
||||
gpointer user_data)
|
||||
{
|
112
src/engine/qofobject.h
Normal file
112
src/engine/qofobject.h
Normal file
@ -0,0 +1,112 @@
|
||||
/********************************************************************\
|
||||
* qofobject.h -- the Core Object Registration/Lookup Interface *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
/** @addtogroup Engine
|
||||
@{ */
|
||||
/** @file qofobject.h
|
||||
* @breif the Core Object Registration/Lookup Interface
|
||||
*
|
||||
* @author Copyright (c) 2001,2002, Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifndef QOF_OBJECT_H_
|
||||
#define QOF_OBJECT_H_
|
||||
|
||||
#include "GNCId.h"
|
||||
#include "qofbook.h"
|
||||
|
||||
/* Defines the version of the core object object registration
|
||||
* interface. Only object modules compiled against this version
|
||||
* of the interface will load properly
|
||||
*/
|
||||
#define GNC_OBJECT_VERSION 1
|
||||
|
||||
typedef struct _QofObject QofObject;
|
||||
typedef void (*foreachTypeCB) (QofObject *type, gpointer user_data);
|
||||
typedef void (*foreachBackendTypeCB) (GNCIdTypeConst type,
|
||||
gpointer backend_data,
|
||||
gpointer user_data);
|
||||
|
||||
/* This is the Object Object descriptor */
|
||||
struct _QofObject {
|
||||
gint interface_version; /* of this object interface */
|
||||
GNCIdType name; /* the Object's GNC_ID */
|
||||
const char * type_label; /* "Printable" type-label string */
|
||||
|
||||
/* book_begin is called from within the Book routines to create
|
||||
* module-specific hooks in a book whenever a book is created.
|
||||
* book_end is called when the book is being closed, to clean
|
||||
* up (and free memory).
|
||||
*/
|
||||
void (*book_begin)(QofBook *);
|
||||
void (*book_end)(QofBook *);
|
||||
|
||||
/* Determine if there are any dirty items in this book */
|
||||
gboolean (*is_dirty)(QofBook *);
|
||||
|
||||
/* Mark this object's book clean (for after a load) */
|
||||
void (*mark_clean)(QofBook *);
|
||||
|
||||
/* foreach() is used to execute a callback over each object
|
||||
* stored in the particular book
|
||||
*/
|
||||
void (*foreach)(QofBook *, foreachObjectCB, gpointer);
|
||||
|
||||
/* Given a particular object, return a printable string */
|
||||
const char * (*printable)(gpointer obj);
|
||||
|
||||
};
|
||||
|
||||
void gncObjectForeachType (foreachTypeCB cb, gpointer user_data);
|
||||
|
||||
void gncObjectForeach (GNCIdTypeConst type_name, QofBook *book,
|
||||
foreachObjectCB cb, gpointer user_data);
|
||||
|
||||
const char * gncObjectPrintable (GNCIdTypeConst type_name, gpointer obj);
|
||||
|
||||
|
||||
/* REGISTRATION AND REG-LOOKUP FUNCTIONS */
|
||||
|
||||
/** Register new types of object objects */
|
||||
gboolean qof_object_register (const QofObject *object);
|
||||
|
||||
/** Get the printable label for a type. This label is *not*
|
||||
* translated; you must use _() on it if you want a translated version.
|
||||
*/
|
||||
const char * qof_object_get_type_label (GNCIdTypeConst type_name);
|
||||
|
||||
/** Lookup a object definition */
|
||||
const QofObject * qof_object_lookup (GNCIdTypeConst type_name);
|
||||
|
||||
|
||||
/** Register and lookup backend-specific data for this particular object */
|
||||
gboolean qof_object_registerBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name,
|
||||
gpointer be_data);
|
||||
|
||||
gpointer qof_object_lookupBackend (GNCIdTypeConst type_name,
|
||||
const char *backend_name);
|
||||
|
||||
void qof_object_foreach_backend (const char *backend_name,
|
||||
foreachBackendTypeCB cb,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* QOF_OBJECT_H_ */
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user