[Gnucash-changes] -- Rename QOF_QUERY_PARAM_XX to QOF_PARAM_XX --
Add 'new' callback to
Linas Vepstas
linas at cvs.gnucash.org
Sun May 23 13:31:43 EDT 2004
Log Message:
-----------
-- Rename QOF_QUERY_PARAM_XX to QOF_PARAM_XX
-- Add 'new' callback to QofObject. This allows QofObject to act
as an 'object factory', creating a new instance of something,
given only the type name. Plan to use this in the new SQL
backend, when restoring objects from SQL tables.
Modified Files:
--------------
gnucash/src/backend/postgres:
putil.h
gnucash/src/business/business-core:
gncBillTerm.c
gncCustomer.c
gncEmployee.c
gncEntry.c
gncInvoice.c
gncJob.c
gncOrder.c
gncOwner.c
gncTaxTable.c
gncVendor.c
gnucash/src/engine:
Account.c
Group.c
Query.c
QueryNew.h
SX-book.c
Transaction.c
gnc-commodity.c
gnc-lot.c
gnc-pricedb.c
qofbook.c
qofgobj.c
qofid.c
qofid.h
qofobject.c
qofobject.h
qofquery.c
qofquery.h
qofsql.c
xlate.pl
gnucash/src/engine/test:
test-object.c
Revision Data
-------------
Index: putil.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/postgres/putil.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -Lsrc/backend/postgres/putil.h -Lsrc/backend/postgres/putil.h -u -r1.14 -r1.15
--- src/backend/postgres/putil.h
+++ src/backend/postgres/putil.h
@@ -146,13 +146,13 @@
result = PQgetResult (conn); \
if (!result) break; \
status = PQresultStatus(result); \
- msg = PQresultErrorMessage(result); \
if ((PGRES_COMMAND_OK != status) && \
(PGRES_TUPLES_OK != status)) \
{ \
+ msg = PQresultErrorMessage(result); \
PERR("failed to get result to query:\n\t%s", msg); \
PQclear (result); \
- qof_backend_set_message (&be->be, msg); \
+ qof_backend_set_message (&be->be, msg); \
qof_backend_set_error (&be->be, ERR_BACKEND_SERVER_ERR);\
break; \
} \
Index: qofquery.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/engine/qofquery.h -Lsrc/engine/qofquery.h -u -r1.11 -r1.12
--- src/engine/qofquery.h
+++ src/engine/qofquery.h
@@ -105,11 +105,11 @@
#define QUERY_DEFAULT_SORT "QofQueryDefaultSort"
/** "Known" Object Parameters -- all objects must support these */
-#define QOF_QUERY_PARAM_BOOK "book"
-#define QOF_QUERY_PARAM_GUID "guid"
+#define QOF_PARAM_BOOK "book"
+#define QOF_PARAM_GUID "guid"
/** "Known" Object Parameters -- some objects might support these */
-#define QOF_QUERY_PARAM_ACTIVE "active"
+#define QOF_PARAM_ACTIVE "active"
/* --------------------------------------------------------- */
/** @name Query Subsystem Initialization and Shudown */
Index: qofquery.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lsrc/engine/qofquery.c -Lsrc/engine/qofquery.c -u -r1.23 -r1.24
--- src/engine/qofquery.c
+++ src/engine/qofquery.c
@@ -1222,9 +1222,10 @@
if (g_list_index (q->books, book) == -1)
q->books = g_list_prepend (q->books, book);
- qof_query_add_guid_match (q, g_slist_prepend (g_slist_prepend (NULL,
- QOF_QUERY_PARAM_GUID),
- QOF_QUERY_PARAM_BOOK),
+ GSList *slist = NULL;
+ g_slist_prepend (slist, QOF_PARAM_GUID);
+ g_slist_prepend (slist, QOF_PARAM_BOOK);
+ qof_query_add_guid_match (q, slist,
qof_book_get_guid(book), QOF_QUERY_AND);
}
Index: qofid.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/engine/qofid.h -Lsrc/engine/qofid.h -u -r1.11 -r1.12
--- src/engine/qofid.h
+++ src/engine/qofid.h
@@ -73,14 +73,16 @@
typedef const char * QofIdTypeConst;
#define QOF_ID_NONE NULL
-#define QOF_ID_BOOK "Book"
#define QOF_ID_NULL "null"
+
+#define QOF_ID_BOOK "Book"
+#define QOF_ID_FREQSPEC "FreqSpec"
#define QOF_ID_SESSION "Session"
-/* simple,cheesy cast but holds water for now */
+/** simple,cheesy cast but holds water for now */
#define QOF_ENTITY(object) ((QofEntity *)(object))
-/* Inline string comparision; compiler will optimize away most of this */
+/** Inline string comparision; compiler will optimize away most of this */
#define QSTRCMP(da,db) ({ \
int val = 0; \
if ((da) && (db)) { \
@@ -131,7 +133,7 @@
void qof_entity_release (QofEntity *);
/* @} */
-/* Return the GUID of this entity */
+/** Return the GUID of this entity */
const GUID * qof_entity_get_guid (QofEntity *);
/** @name Collections of Entities
@@ -161,7 +163,7 @@
gpointer qof_collection_get_data (QofCollection *col);
void qof_collection_set_data (QofCollection *col, gpointer user_data);
-/* Return value of 'dirty' flag on collection */
+/** Return value of 'dirty' flag on collection */
gboolean qof_collection_is_dirty (QofCollection *col);
/** @} */
Index: Group.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Group.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -Lsrc/engine/Group.c -Lsrc/engine/Group.c -u -r1.132 -r1.133
--- src/engine/Group.c
+++ src/engine/Group.c
@@ -1263,6 +1263,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_GROUP,
type_label: "AccountGroup",
+ new: NULL,
book_begin: group_book_begin,
book_end: group_book_end,
is_dirty: group_is_dirty,
Index: qofsql.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofsql.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -Lsrc/engine/qofsql.c -Lsrc/engine/qofsql.c -u -r1.5 -r1.6
--- src/engine/qofsql.c
+++ src/engine/qofsql.c
@@ -22,7 +22,7 @@
/**
@file qofsql.c
- @breif QOF client-side SQL parser.
+ @brief QOF client-side SQL parser.
@author Copyright (C) 2004 Linas Vepstas <linas at linas.org>
*/
Index: Query.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Query.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -Lsrc/engine/Query.c -Lsrc/engine/Query.c -u -r1.127 -r1.128
--- src/engine/Query.c
+++ src/engine/Query.c
@@ -266,7 +266,7 @@
switch (how) {
case QOF_GUID_MATCH_ANY:
case QOF_GUID_MATCH_NONE:
- param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_QUERY_PARAM_GUID, NULL);
+ param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_PARAM_GUID, NULL);
break;
case QOF_GUID_MATCH_ALL:
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_SPLITLIST,
@@ -484,11 +484,11 @@
return;
if (!safe_strcmp (id_type, GNC_ID_SPLIT))
- param_list = qof_query_build_param_list (QOF_QUERY_PARAM_GUID, NULL);
+ param_list = qof_query_build_param_list (QOF_PARAM_GUID, NULL);
else if (!safe_strcmp (id_type, GNC_ID_TRANS))
- param_list = qof_query_build_param_list (SPLIT_TRANS, QOF_QUERY_PARAM_GUID, NULL);
+ param_list = qof_query_build_param_list (SPLIT_TRANS, QOF_PARAM_GUID, NULL);
else if (!safe_strcmp (id_type, GNC_ID_ACCOUNT))
- param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_QUERY_PARAM_GUID, NULL);
+ param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_PARAM_GUID, NULL);
else
PERR ("Invalid match type: %s", id_type);
Index: Account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Account.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -Lsrc/engine/Account.c -Lsrc/engine/Account.c -u -r1.271 -r1.272
--- src/engine/Account.c
+++ src/engine/Account.c
@@ -2836,6 +2836,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_ACCOUNT,
type_label: "Account",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: NULL,
@@ -2857,8 +2858,8 @@
{ ACCOUNT_RECONCILED_, QOF_TYPE_NUMERIC, (QofAccessFunc)xaccAccountGetReconciledBalance, NULL },
{ ACCOUNT_FUTURE_MINIMUM_, QOF_TYPE_NUMERIC, (QofAccessFunc)xaccAccountGetProjectedMinimumBalance, NULL },
{ ACCOUNT_TAX_RELATED, QOF_TYPE_BOOLEAN, (QofAccessFunc)xaccAccountGetTaxRelated, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ ACCOUNT_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, NULL },
{ NULL },
};
Index: qofbook.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofbook.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lsrc/engine/qofbook.c -Lsrc/engine/qofbook.c -u -r1.20 -r1.21
--- src/engine/qofbook.c
+++ src/engine/qofbook.c
@@ -221,6 +221,8 @@
{
QofCollection *col;
+ if (!book || !entity_type) return NULL;
+
col = g_hash_table_lookup (book->hash_of_collections, entity_type);
if (col) return col;
@@ -324,7 +326,7 @@
{
static QofParam params[] = {
{ QOF_BOOK_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_book_get_slots, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
{ NULL },
};
Index: gnc-pricedb.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-pricedb.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lsrc/engine/gnc-pricedb.c -Lsrc/engine/gnc-pricedb.c -u -r1.73 -r1.74
--- src/engine/gnc-pricedb.c
+++ src/engine/gnc-pricedb.c
@@ -2057,6 +2057,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_PRICE,
type_label: "Price",
+ new: NULL,
book_begin: pricedb_book_begin,
book_end: pricedb_book_end,
is_dirty: pricedb_is_dirty,
Index: qofgobj.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofgobj.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lsrc/engine/qofgobj.c -Lsrc/engine/qofgobj.c -u -r1.2 -r1.3
--- src/engine/qofgobj.c
+++ src/engine/qofgobj.c
@@ -296,6 +296,7 @@
/* We could let the user specify a "nick" here, but
* the actual class name seems reasonable, e.g. for debugging. */
class_def->type_label = G_OBJECT_CLASS_NAME (obclass);
+ class_def->new = NULL;
class_def->book_begin = NULL;
class_def->book_end = NULL;
class_def->is_dirty = NULL;
Index: Transaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Transaction.c,v
retrieving revision 1.306
retrieving revision 1.307
diff -Lsrc/engine/Transaction.c -Lsrc/engine/Transaction.c -u -r1.306 -r1.307
--- src/engine/Transaction.c
+++ src/engine/Transaction.c
@@ -3187,6 +3187,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_SPLIT,
type_label: "Split",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: NULL,
@@ -3258,8 +3259,8 @@
{ SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op, NULL },
{ SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op, NULL },
{ SPLIT_KVP, QOF_TYPE_KVP, (QofAccessFunc)xaccSplitGetSlots, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)xaccSplitGetBook, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
{ NULL },
};
@@ -3281,6 +3282,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_TRANS,
type_label: "Transaction",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: NULL,
@@ -3314,8 +3316,8 @@
{ TRANS_VOID_TIME, QOF_TYPE_DATE, (QofAccessFunc)xaccTransGetVoidTime,NULL },
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QofAccessFunc)xaccTransGetSplitList,NULL },
{ TRANS_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots,NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book,NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid,NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book,NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid,NULL },
{ NULL },
};
Index: gnc-lot.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-lot.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -Lsrc/engine/gnc-lot.c -Lsrc/engine/gnc-lot.c -u -r1.37 -r1.38
--- src/engine/gnc-lot.c
+++ src/engine/gnc-lot.c
@@ -361,8 +361,8 @@
void gnc_lot_register (void)
{
static const QofParam params[] = {
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book, NULL },
{ LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed, NULL },
{ LOT_BALANCE, QOF_TYPE_NUMERIC, (QofAccessFunc)gnc_lot_get_balance, NULL },
{ NULL },
Index: SX-book.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/SX-book.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -Lsrc/engine/SX-book.c -Lsrc/engine/SX-book.c -u -r1.9 -r1.10
--- src/engine/SX-book.c
+++ src/engine/SX-book.c
@@ -269,6 +269,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_SXTT,
type_label: "Scheduled Transaction Templates",
+ new: NULL,
book_begin: sxtt_book_begin,
book_end: sxtt_book_end,
is_dirty: book_sxlist_notsaved,
Index: qofid.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lsrc/engine/qofid.c -Lsrc/engine/qofid.c -u -r1.10 -r1.11
--- src/engine/qofid.c
+++ src/engine/qofid.c
@@ -182,6 +182,7 @@
static void
qof_collection_remove_entity (QofEntity *ent)
{
+ if (!ent) return;
QofCollection *col = ent->collection;
if (!col) return;
g_hash_table_remove (col->hash_of_entities, &ent->guid);
@@ -191,6 +192,7 @@
void
qof_collection_insert_entity (QofCollection *col, QofEntity *ent)
{
+ if (!col || !ent) return;
if (guid_equal(&ent->guid, guid_null())) return;
g_return_if_fail (col->e_type == ent->e_type);
qof_collection_remove_entity (ent);
Index: xlate.pl
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/xlate.pl,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lsrc/engine/xlate.pl -Lsrc/engine/xlate.pl -u -r1.12 -r1.13
--- src/engine/xlate.pl
+++ src/engine/xlate.pl
@@ -110,9 +110,9 @@
s/QUERY_NAND/QOF_QUERY_NAND/g;
s/QUERY_NOR/QOF_QUERY_NOR/g;
s/QUERY_XOR/QOF_QUERY_XOR/g;
- s/QUERY_PARAM_BOOK/QOF_QUERY_PARAM_BOOK/g;
- s/QUERY_PARAM_GUID/QOF_QUERY_PARAM_GUID/g;
- s/QUERY_PARAM_ACTIVE/QOF_QUERY_PARAM_ACTIVE/g;
+ s/QUERY_PARAM_BOOK/QOF_PARAM_BOOK/g;
+ s/QUERY_PARAM_GUID/QOF_PARAM_GUID/g;
+ s/QUERY_PARAM_ACTIVE/QOF_PARAM_ACTIVE/g;
s/QUERYCORE_INT64/QOF_QUERYCORE_INT64/g;
s/QUERYCORE_STRING/QOF_QUERYCORE_STRING/g;
Index: gnc-commodity.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-commodity.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -Lsrc/engine/gnc-commodity.c -Lsrc/engine/gnc-commodity.c -u -r1.66 -r1.67
--- src/engine/gnc-commodity.c
+++ src/engine/gnc-commodity.c
@@ -1598,6 +1598,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: GNC_ID_COMMODITY_TABLE,
type_label: "CommodityTable",
+ new: NULL,
book_begin: commodity_table_book_begin,
book_end: commodity_table_book_end,
is_dirty: NULL,
Index: qofobject.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofobject.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/engine/qofobject.c -Lsrc/engine/qofobject.c -u -r1.11 -r1.12
--- src/engine/qofobject.c
+++ src/engine/qofobject.c
@@ -41,6 +41,22 @@
static GList *book_list = NULL;
static GHashTable *backend_data = NULL;
+gpointer
+qof_object_new_instance (QofIdTypeConst type_name, QofBook *book)
+{
+ const QofObject *obj;
+
+ if (!type_name) return NULL;
+
+ obj = qof_object_lookup (type_name);
+ if (!obj) return NULL;
+
+ if (obj->new)
+ return (obj->new (book));
+
+ return NULL;
+}
+
void qof_object_book_begin (QofBook *book)
{
GList *l;
@@ -333,3 +349,5 @@
g_hash_table_foreach (ht, foreach_backend, &cb_data);
}
+
+/* ========================= END OF FILE =================== */
Index: qofobject.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofobject.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lsrc/engine/qofobject.h -Lsrc/engine/qofobject.h -u -r1.15 -r1.16
--- src/engine/qofobject.h
+++ src/engine/qofobject.h
@@ -36,8 +36,8 @@
@{ */
/** @file qofobject.h
- * @brief the Core Object Registration/Lookup Interface
- * @author Copyright (c) 2001,2002, Derek Atkins <warlord at MIT.EDU>
+ * @brief the Core Object Registration/Lookup Interface
+ * @author Copyright (c) 2001,2002 Derek Atkins <warlord at MIT.EDU>
*/
#ifndef QOF_OBJECT_H_
@@ -61,8 +61,6 @@
gpointer user_data);
/** This is the QofObject Class descriptor
- *
- * XXX Hmm, should we add an object factory to this?
*/
struct _QofObject
{
@@ -70,28 +68,33 @@
QofIdType e_type; /* the Object's QOF_ID */
const char * type_label; /* "Printable" type-label string */
- /* book_begin is called from within the Book routines to create
+ /** Create a new instance of this object type. */
+ gpointer (*new)(QofBook *);
+
+ /** 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 *);
+
+ /** book_end is called when the book is being closed, to clean
+ * up (and free memory).
+ */
void (*book_end)(QofBook *);
- /* Determine if there are any dirty items in this book */
+ /** Determine if there are any dirty items in this book */
gboolean (*is_dirty)(QofCollection *);
- /* Mark this object's book clean (for after a load) */
+ /** Mark this object's book clean (for after a load) */
void (*mark_clean)(QofCollection *);
- /* foreach() is used to execute a callback over each object
+ /** foreach() is used to execute a callback over each object
* stored in the particular book
*/
void (*foreach)(QofCollection *, QofEntityForeachCB, gpointer);
- /* Given a particular object, return a printable string */
- /* Argument should really be QofInstance not gpointer.. */
- const char * (*printable)(gpointer obj);
+ /** Given a particular instance of this type, return a printable string.
+ * Argument should really be QofInstance not gpointer.. */
+ const char * (*printable)(gpointer instance);
};
@@ -103,6 +106,26 @@
void qof_object_shutdown (void);
/** @} */
+/** Register new types of object objects */
+gboolean qof_object_register (const QofObject *object);
+
+/** Lookup an object definition */
+const QofObject * qof_object_lookup (QofIdTypeConst type_name);
+
+/** Create an instance of the indicated type, returning a pointer to that
+ * instance. This routine just calls the (*new) callback on the object
+ * definition.
+ */
+gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book);
+
+/** 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 (QofIdTypeConst type_name);
+
+/** @return a Human-readable string name for an instance */
+const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance);
+
/** Invoke the callback 'cb' on every object class definition.
* The user_data pointer is passed back to the callback.
*/
@@ -116,22 +139,6 @@
void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
QofEntityForeachCB cb, gpointer user_data);
-/** @return a Human-readable string name for on object */
-const char * qof_object_printable (QofIdTypeConst type_name, gpointer obj);
-
-
-/** 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 (QofIdTypeConst type_name);
-
-/** Lookup a object definition */
-const QofObject * qof_object_lookup (QofIdTypeConst type_name);
-
-
/** Register and lookup backend-specific data for this particular object */
gboolean qof_object_register_backend (QofIdTypeConst type_name,
const char *backend_name,
Index: QueryNew.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/QueryNew.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -Lsrc/engine/QueryNew.h -Lsrc/engine/QueryNew.h -u -r1.26 -r1.27
--- src/engine/QueryNew.h
+++ src/engine/QueryNew.h
@@ -6,9 +6,9 @@
#define QUERY_NAND QOF_QUERY_NAND
#define QUERY_NOR QOF_QUERY_NOR
#define QUERY_XOR QOF_QUERY_XOR
- #define QUERY_PARAM_BOOK QOF_QUERY_PARAM_BOOK
- #define QUERY_PARAM_GUID QOF_QUERY_PARAM_GUID
- #define QUERY_PARAM_ACTIVE QOF_QUERY_PARAM_ACTIVE
+ #define QUERY_PARAM_BOOK QOF_PARAM_BOOK
+ #define QUERY_PARAM_GUID QOF_PARAM_GUID
+ #define QUERY_PARAM_ACTIVE QOF_PARAM_ACTIVE
#define querynew_s _QofQuery
#define QueryNew QofQuery
Index: gncEmployee.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEmployee.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -Lsrc/business/business-core/gncEmployee.c -Lsrc/business/business-core/gncEmployee.c -u -r1.40 -r1.41
--- src/business/business-core/gncEmployee.c
+++ src/business/business-core/gncEmployee.c
@@ -403,6 +403,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Employee",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -417,9 +418,9 @@
{ EMPLOYEE_ID, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetID, NULL },
{ EMPLOYEE_USERNAME, QOF_TYPE_STRING, (QofAccessFunc)gncEmployeeGetUsername, NULL },
{ EMPLOYEE_ADDR, GNC_ADDRESS_MODULE_NAME, (QofAccessFunc)gncEmployeeGetAddr, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncEmployeeGetActive, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncEmployeeGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncOwner.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOwner.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lsrc/business/business-core/gncOwner.c -Lsrc/business/business-core/gncOwner.c -u -r1.35 -r1.36
--- src/business/business-core/gncOwner.c
+++ src/business/business-core/gncOwner.c
@@ -406,7 +406,7 @@
{ OWNER_PARENT, GNC_ID_OWNER, (QofAccessFunc)gncOwnerGetEndOwner, NULL },
{ OWNER_PARENTG, QOF_TYPE_GUID, (QofAccessFunc)gncOwnerGetEndGUID, NULL },
{ OWNER_NAME, QOF_TYPE_STRING, (QofAccessFunc)gncOwnerGetName, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)gncOwnerGetGUID, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)gncOwnerGetGUID, NULL },
{ NULL },
};
Index: gncInvoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncInvoice.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -Lsrc/business/business-core/gncInvoice.c -Lsrc/business/business-core/gncInvoice.c -u -r1.87 -r1.88
--- src/business/business-core/gncInvoice.c
+++ src/business/business-core/gncInvoice.c
@@ -1363,6 +1363,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Invoice",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -1413,9 +1414,9 @@
{ INVOICE_TYPE, QOF_TYPE_STRING, (QofAccessFunc)gncInvoiceGetType, NULL },
{ INVOICE_TERMS, GNC_ID_BILLTERM, (QofAccessFunc)gncInvoiceGetTerms, NULL },
{ INVOICE_BILLTO, GNC_ID_OWNER, (QofAccessFunc)gncInvoiceGetBillTo, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncInvoiceGetActive, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncInvoiceGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncCustomer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncCustomer.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -Lsrc/business/business-core/gncCustomer.c -Lsrc/business/business-core/gncCustomer.c -u -r1.56 -r1.57
--- src/business/business-core/gncCustomer.c
+++ src/business/business-core/gncCustomer.c
@@ -536,6 +536,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Customer",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -551,9 +552,9 @@
{ CUSTOMER_NAME, QOF_TYPE_STRING, (QofAccessFunc)gncCustomerGetName, NULL },
{ CUSTOMER_ADDR, GNC_ADDRESS_MODULE_NAME, (QofAccessFunc)gncCustomerGetAddr, NULL },
{ CUSTOMER_SHIPADDR, GNC_ADDRESS_MODULE_NAME, (QofAccessFunc)gncCustomerGetShipAddr, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncCustomerGetActive, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncCustomerGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncVendor.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncVendor.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -Lsrc/business/business-core/gncVendor.c -Lsrc/business/business-core/gncVendor.c -u -r1.45 -r1.46
--- src/business/business-core/gncVendor.c
+++ src/business/business-core/gncVendor.c
@@ -486,6 +486,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Vendor",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -500,9 +501,9 @@
{ VENDOR_ID, QOF_TYPE_STRING, (QofAccessFunc)gncVendorGetID, NULL },
{ VENDOR_NAME, QOF_TYPE_STRING, (QofAccessFunc)gncVendorGetName, NULL },
{ VENDOR_ADDR, GNC_ADDRESS_MODULE_NAME, (QofAccessFunc)gncVendorGetAddr, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncVendorGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncVendorGetActive, NULL },
{ NULL },
};
Index: gncJob.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncJob.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -Lsrc/business/business-core/gncJob.c -Lsrc/business/business-core/gncJob.c -u -r1.41 -r1.42
--- src/business/business-core/gncJob.c
+++ src/business/business-core/gncJob.c
@@ -353,6 +353,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Job",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -369,9 +370,9 @@
{ JOB_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncJobGetActive, NULL },
{ JOB_REFERENCE, QOF_TYPE_STRING, (QofAccessFunc)gncJobGetReference, NULL },
{ JOB_OWNER, GNC_ID_OWNER, (QofAccessFunc)gncJobGetOwner, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncJobGetActive, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncJobGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncBillTerm.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncBillTerm.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/business/business-core/gncBillTerm.c -Lsrc/business/business-core/gncBillTerm.c -u -r1.36 -r1.37
--- src/business/business-core/gncBillTerm.c
+++ src/business/business-core/gncBillTerm.c
@@ -678,6 +678,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Billing Term",
+ new: NULL,
book_begin: _gncBillTermCreate,
book_end: _gncBillTermDestroy,
is_dirty: qof_collection_is_dirty,
@@ -689,8 +690,8 @@
gboolean gncBillTermRegister (void)
{
static QofParam params[] = {
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncEntry.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncEntry.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -Lsrc/business/business-core/gncEntry.c -Lsrc/business/business-core/gncEntry.c -u -r1.53 -r1.54
--- src/business/business-core/gncEntry.c
+++ src/business/business-core/gncEntry.c
@@ -1169,6 +1169,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Order/Invoice/Bill Entry",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -1193,8 +1194,8 @@
{ ENTRY_BILLABLE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncEntryGetBillable, NULL },
{ ENTRY_BILLTO, GNC_ID_OWNER, (QofAccessFunc)gncEntryGetBillTo, NULL },
{ ENTRY_ORDER, GNC_ID_ORDER, (QofAccessFunc)gncEntryGetOrder, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncTaxTable.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncTaxTable.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lsrc/business/business-core/gncTaxTable.c -Lsrc/business/business-core/gncTaxTable.c -u -r1.35 -r1.36
--- src/business/business-core/gncTaxTable.c
+++ src/business/business-core/gncTaxTable.c
@@ -799,6 +799,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Tax Table",
+ new: NULL,
book_begin: _gncTaxTableCreate,
book_end: _gncTaxTableDestroy,
is_dirty: qof_collection_is_dirty,
@@ -810,8 +811,8 @@
gboolean gncTaxTableRegister (void)
{
static QofParam params[] = {
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: gncOrder.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncOrder.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -Lsrc/business/business-core/gncOrder.c -Lsrc/business/business-core/gncOrder.c -u -r1.41 -r1.42
--- src/business/business-core/gncOrder.c
+++ src/business/business-core/gncOrder.c
@@ -425,6 +425,7 @@
interface_version: QOF_OBJECT_VERSION,
e_type: _GNC_MOD_NAME,
type_label: "Order",
+ new: NULL,
book_begin: NULL,
book_end: NULL,
is_dirty: qof_collection_is_dirty,
@@ -443,9 +444,9 @@
{ ORDER_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncOrderIsClosed, NULL },
{ ORDER_CLOSED, QOF_TYPE_DATE, (QofAccessFunc)gncOrderGetDateClosed, NULL },
{ ORDER_NOTES, QOF_TYPE_STRING, (QofAccessFunc)gncOrderGetNotes, NULL },
- { QOF_QUERY_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncOrderGetActive, NULL },
- { QOF_QUERY_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
- { QOF_QUERY_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
+ { QOF_PARAM_ACTIVE, QOF_TYPE_BOOLEAN, (QofAccessFunc)gncOrderGetActive, NULL },
+ { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
+ { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
{ NULL },
};
Index: test-object.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/test/test-object.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/engine/test/test-object.c -Lsrc/engine/test/test-object.c -u -r1.11 -r1.12
--- src/engine/test/test-object.c
+++ src/engine/test/test-object.c
@@ -22,15 +22,16 @@
static void test_foreach (QofBook *, const char *);
static QofObject bus_obj = {
- QOF_OBJECT_VERSION,
- TEST_MODULE_NAME,
- TEST_MODULE_DESC,
- NULL, /* create */
- NULL, /* destroy */
- NULL, /* is dirty */
- NULL, /* mark_clean */
- obj_foreach,
- printable,
+ interface_version: QOF_OBJECT_VERSION,
+ e_type: TEST_MODULE_NAME,
+ type_label: TEST_MODULE_DESC,
+ new: NULL,
+ book_begin: NULL,
+ book_end: NULL,
+ is_dirty: NULL,
+ mark_clean: NULL,
+ foreach: obj_foreach,
+ printable: printable,
};
static void
More information about the gnucash-changes
mailing list