mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/engine/GNCId.c: Implement xaccForeachEntity() as a which
allows a traversal of all entities of a particular type. * Register GncObject_t descriptions for Splits, Transactions, and Accounts. Move the QueryObject definitions into the actual module sources for Transactions, Splits, Accounts, and Books. This allows QueryNew searches for Splits, Transactions, and Accounts. * gnc-engine.c: call the registration functions for Splits, Transactions, Accounts, and Books to enable searching using the new search subsystem. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6913 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
08e47f2b87
commit
47eaa5c35d
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2002-05-24 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/engine/GNCId.c: Implement xaccForeachEntity() as a which
|
||||
allows a traversal of all entities of a particular type.
|
||||
|
||||
* Register GncObject_t descriptions for Splits, Transactions, and
|
||||
Accounts. Move the QueryObject definitions into the actual module
|
||||
sources for Transactions, Splits, Accounts, and Books. This
|
||||
allows QueryNew searches for Splits, Transactions, and Accounts.
|
||||
|
||||
* gnc-engine.c: call the registration functions for Splits,
|
||||
Transactions, Accounts, and Books to enable searching using the
|
||||
new search subsystem.
|
||||
|
||||
2002-05-23 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome/reconcile-list.c: Encapsulate all list sorting logic
|
||||
|
@ -44,6 +44,9 @@
|
||||
#include "kvp-util-p.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "QueryObject.h"
|
||||
|
||||
static short module = MOD_ENGINE;
|
||||
|
||||
|
||||
@ -2716,5 +2719,53 @@ xaccAccountFindTransByDesc(Account *account, const char *description)
|
||||
return( trans );
|
||||
}
|
||||
|
||||
/* gncObject function implementation and registration */
|
||||
|
||||
static void
|
||||
account_foreach (GNCBook *book, foreachObjectCB cb, gpointer ud)
|
||||
{
|
||||
GNCEntityTable *et;
|
||||
|
||||
g_return_if_fail (book);
|
||||
g_return_if_fail (cb);
|
||||
|
||||
et = gnc_book_get_entity_table (book);
|
||||
xaccForeachEntity (et, GNC_ID_ACCOUNT, cb, ud);
|
||||
}
|
||||
|
||||
static GncObject_t account_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_ACCOUNT,
|
||||
"Account",
|
||||
NULL, /* book_begin */
|
||||
NULL, /* book_end */
|
||||
NULL, /* is_dirty */
|
||||
NULL, /* mark_clean */
|
||||
account_foreach, /* foreach */
|
||||
xaccAccountGetName /* printable */
|
||||
};
|
||||
|
||||
gboolean xaccAccountRegister (void)
|
||||
{
|
||||
static QueryObjectDef params[] = {
|
||||
{ ACCOUNT_KVP, QUERYCORE_KVP, (QueryAccess)xaccAccountGetSlots },
|
||||
{ ACCOUNT_NAME_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetName },
|
||||
{ ACCOUNT_CODE_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetCode },
|
||||
{ ACCOUNT_DESCRIPTION_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetDescription },
|
||||
{ ACCOUNT_NOTES_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetNotes },
|
||||
{ ACCOUNT_BALANCE_, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetBalance },
|
||||
{ ACCOUNT_CLEARED_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetClearedBalance },
|
||||
{ ACCOUNT_RECONCILED_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetReconciledBalance },
|
||||
{ ACCOUNT_TAX_RELATED, QUERYCORE_BOOLEAN, (QueryAccess)xaccAccountGetTaxRelated },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccAccountGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)xaccAccountGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_ACCOUNT, (QuerySort)xaccAccountOrder, params);
|
||||
|
||||
return gncObjectRegister (&account_object_def);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
@ -200,4 +200,7 @@ void xaccFreeAccount (Account *account);
|
||||
void xaccAccountSetVersion (Account*, gint32);
|
||||
gint32 xaccAccountGetVersion (Account*);
|
||||
|
||||
/* Register Accounts with the engine */
|
||||
gboolean xaccAccountRegister (void);
|
||||
|
||||
#endif /* XACC_ACCOUNT_P_H */
|
||||
|
@ -330,3 +330,37 @@ xaccRemoveEntity (GNCEntityTable *entity_table, const GUID * guid)
|
||||
entity_node_destroy (old_guid, node, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
struct _iterate {
|
||||
foreachObjectCB fcn;
|
||||
gpointer data;
|
||||
GNCIdType type;
|
||||
};
|
||||
|
||||
static void foreach_cb (gpointer key, gpointer item, gpointer arg)
|
||||
{
|
||||
struct _iterate *iter = arg;
|
||||
EntityNode *e_node = item;
|
||||
|
||||
/* Call the callback if this entity is of the proper type */
|
||||
if (!safe_strcmp (e_node->entity_type, iter->type))
|
||||
iter->fcn (e_node->entity, iter->data);
|
||||
}
|
||||
|
||||
void
|
||||
xaccForeachEntity (GNCEntityTable *entity_table, GNCIdType type,
|
||||
foreachObjectCB cb_func, gpointer user_data)
|
||||
{
|
||||
struct _iterate iter;
|
||||
|
||||
g_return_if_fail (entity_table);
|
||||
g_return_if_fail (type);
|
||||
g_return_if_fail (*type);
|
||||
g_return_if_fail (cb_func);
|
||||
|
||||
iter.fcn = cb_func;
|
||||
iter.data = user_data;
|
||||
iter.type = type;
|
||||
|
||||
g_hash_table_foreach (entity_table->hash, foreach_cb, &iter);
|
||||
}
|
||||
|
@ -71,4 +71,7 @@ const GUID * xaccGUIDNULL (void);
|
||||
GUID * xaccGUIDMalloc (void);
|
||||
void xaccGUIDFree (GUID *guid);
|
||||
|
||||
/* Callback type for xaccForeachEntity */
|
||||
typedef void (*foreachObjectCB) (gpointer object, gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
@ -70,6 +70,10 @@ void xaccRemoveEntity (GNCEntityTable *entity_table, const GUID * guid);
|
||||
GNCIdType xaccGUIDTypeEntityTable (const GUID * guid,
|
||||
GNCEntityTable *entity_table);
|
||||
|
||||
/* Call a function for each object of type 'type' in the entity table */
|
||||
void xaccForeachEntity (GNCEntityTable *entity_table, GNCIdType type,
|
||||
foreachObjectCB cb_func, gpointer user_data);
|
||||
|
||||
/* Initialize and shutdown the GNC Id system. */
|
||||
void xaccGUIDInit (void);
|
||||
void xaccGUIDShutdown (void);
|
||||
|
@ -16,124 +16,12 @@
|
||||
#include "QueryObjectP.h"
|
||||
#include "QueryNew.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
|
||||
static short module = MOD_QUERY;
|
||||
|
||||
static GHashTable *paramTable = NULL;
|
||||
static GHashTable *sortTable = NULL;
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
static gpointer split_account_guid_getter (gpointer obj)
|
||||
{
|
||||
Split *s = obj;
|
||||
Account *acc;
|
||||
|
||||
if (!s) return NULL;
|
||||
acc = xaccSplitGetAccount (s);
|
||||
if (!acc) return NULL;
|
||||
return ((gpointer)xaccAccountGetGUID (acc));
|
||||
}
|
||||
|
||||
static void init_split (void)
|
||||
{
|
||||
static const QueryObjectDef params[] = {
|
||||
{ SPLIT_KVP, QUERYCORE_KVP, (QueryAccess)xaccSplitGetSlots },
|
||||
{ SPLIT_DATE_RECONCILED, QUERYCORE_DATE,
|
||||
(QueryAccess)xaccSplitRetDateReconciledTS },
|
||||
{ "d-share-amount", QUERYCORE_DOUBLE,
|
||||
(QueryAccess)DxaccSplitGetShareAmount },
|
||||
{ "d-share-int64", QUERYCORE_INT64, (QueryAccess)xaccSplitGetGUID },
|
||||
{ SPLIT_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccSplitGetBalance },
|
||||
{ SPLIT_CLEARED_BALANCE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetClearedBalance },
|
||||
{ SPLIT_RECONCILED_BALANCE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetReconciledBalance },
|
||||
{ SPLIT_MEMO, QUERYCORE_STRING, (QueryAccess)xaccSplitGetMemo },
|
||||
{ SPLIT_ACTION, QUERYCORE_STRING, (QueryAccess)xaccSplitGetAction },
|
||||
{ SPLIT_RECONCILE, QUERYCORE_CHAR, (QueryAccess)xaccSplitGetReconcile },
|
||||
{ SPLIT_AMOUNT, QUERYCORE_NUMERIC, (QueryAccess)xaccSplitGetAmount },
|
||||
{ SPLIT_SHARE_PRICE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetSharePrice },
|
||||
{ SPLIT_VALUE, QUERYCORE_DEBCRED, (QueryAccess)xaccSplitGetValue },
|
||||
{ SPLIT_TYPE, QUERYCORE_STRING, (QueryAccess)xaccSplitGetType },
|
||||
{ SPLIT_VOIDED_AMOUNT, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitVoidFormerAmount },
|
||||
{ SPLIT_VOIDED_VALUE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitVoidFormerValue },
|
||||
{ SPLIT_TRANS, GNC_ID_TRANS, (QueryAccess)xaccSplitGetParent },
|
||||
{ SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QueryAccess)xaccSplitGetAccount },
|
||||
{ SPLIT_ACCOUNT_GUID, QUERYCORE_GUID, split_account_guid_getter },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccSplitGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess) xaccSplitGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_SPLIT, (QuerySort)xaccSplitDateOrder, params);
|
||||
}
|
||||
|
||||
static void init_txn (void)
|
||||
{
|
||||
static QueryObjectDef params[] = {
|
||||
{ TRANS_KVP, QUERYCORE_KVP, (QueryAccess)xaccTransGetSlots },
|
||||
{ TRANS_NUM, QUERYCORE_STRING, (QueryAccess)xaccTransGetNum },
|
||||
{ TRANS_DESCRIPTON, QUERYCORE_STRING, (QueryAccess)xaccTransGetDescription },
|
||||
{ TRANS_DATE_ENTERED, QUERYCORE_DATE, (QueryAccess)xaccTransRetDateEnteredTS },
|
||||
{ TRANS_DATE_POSTED, QUERYCORE_DATE, (QueryAccess)xaccTransRetDatePostedTS },
|
||||
{ TRANS_DATE_DUE, QUERYCORE_DATE, (QueryAccess)xaccTransRetDateDueTS },
|
||||
{ TRANS_TYPE, QUERYCORE_CHAR, (QueryAccess)xaccTransGetTxnType },
|
||||
{ TRANS_VOID_STATUS, QUERYCORE_BOOLEAN, (QueryAccess)xaccTransGetVoidStatus },
|
||||
{ TRANS_VOID_REASON, QUERYCORE_STRING, (QueryAccess)xaccTransGetVoidReason },
|
||||
{ TRANS_VOID_TIME, QUERYCORE_DATE, (QueryAccess)xaccTransGetVoidTime },
|
||||
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QueryAccess)xaccTransGetSplitList },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccTransGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)xaccTransGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_TRANS, (QuerySort)xaccTransOrder, params);
|
||||
}
|
||||
|
||||
static void init_account (void)
|
||||
{
|
||||
static QueryObjectDef params[] = {
|
||||
{ ACCOUNT_KVP, QUERYCORE_KVP, (QueryAccess)xaccAccountGetSlots },
|
||||
{ ACCOUNT_NAME_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetName },
|
||||
{ ACCOUNT_CODE_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetCode },
|
||||
{ ACCOUNT_DESCRIPTION_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetDescription },
|
||||
{ ACCOUNT_NOTES_, QUERYCORE_STRING, (QueryAccess)xaccAccountGetNotes },
|
||||
{ ACCOUNT_BALANCE_, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetBalance },
|
||||
{ ACCOUNT_CLEARED_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetClearedBalance },
|
||||
{ ACCOUNT_RECONCILED_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccAccountGetReconciledBalance },
|
||||
{ ACCOUNT_TAX_RELATED, QUERYCORE_BOOLEAN, (QueryAccess)xaccAccountGetTaxRelated },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccAccountGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)xaccAccountGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_ACCOUNT, (QuerySort)xaccAccountOrder, params);
|
||||
}
|
||||
|
||||
static void init_book (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);
|
||||
}
|
||||
|
||||
static void init_tables (void)
|
||||
{
|
||||
init_split ();
|
||||
init_txn ();
|
||||
init_account ();
|
||||
init_book ();
|
||||
}
|
||||
|
||||
static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_hash_table_destroy (value);
|
||||
@ -178,8 +66,6 @@ void gncQueryObjectInit(void)
|
||||
|
||||
paramTable = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
sortTable = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
init_tables ();
|
||||
}
|
||||
|
||||
void gncQueryObjectShutdown (void)
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "gnc-lot-p.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "gncObject.h"
|
||||
#include "QueryObject.h"
|
||||
|
||||
/*
|
||||
* The "force_double_entry" flag determines how
|
||||
@ -3110,5 +3112,131 @@ xaccTransGetVoidTime(Transaction *tr)
|
||||
|
||||
return void_time;
|
||||
}
|
||||
|
||||
/* gncObject function implementation */
|
||||
static void
|
||||
do_foreach (GNCBook *book, GNCIdType type, foreachObjectCB cb, gpointer ud)
|
||||
{
|
||||
GNCEntityTable *et;
|
||||
|
||||
g_return_if_fail (book);
|
||||
g_return_if_fail (cb);
|
||||
|
||||
et = gnc_book_get_entity_table (book);
|
||||
xaccForeachEntity (et, type, cb, ud);
|
||||
}
|
||||
|
||||
static void
|
||||
split_foreach (GNCBook *book, foreachObjectCB fcn, gpointer user_data)
|
||||
{
|
||||
do_foreach (book, GNC_ID_SPLIT, fcn, user_data);
|
||||
}
|
||||
|
||||
/* hook into the gncObject registry */
|
||||
|
||||
static GncObject_t split_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_SPLIT,
|
||||
"Split",
|
||||
NULL, /* book_begin */
|
||||
NULL, /* book_end */
|
||||
NULL, /* is_dirty */
|
||||
NULL, /* mark_clean */
|
||||
split_foreach, /* foreach */
|
||||
xaccSplitGetMemo /* printable */
|
||||
};
|
||||
|
||||
static gpointer split_account_guid_getter (gpointer obj)
|
||||
{
|
||||
Split *s = obj;
|
||||
Account *acc;
|
||||
|
||||
if (!s) return NULL;
|
||||
acc = xaccSplitGetAccount (s);
|
||||
if (!acc) return NULL;
|
||||
return ((gpointer)xaccAccountGetGUID (acc));
|
||||
}
|
||||
|
||||
gboolean xaccSplitRegister (void)
|
||||
{
|
||||
static const QueryObjectDef params[] = {
|
||||
{ SPLIT_KVP, QUERYCORE_KVP, (QueryAccess)xaccSplitGetSlots },
|
||||
{ SPLIT_DATE_RECONCILED, QUERYCORE_DATE,
|
||||
(QueryAccess)xaccSplitRetDateReconciledTS },
|
||||
{ "d-share-amount", QUERYCORE_DOUBLE,
|
||||
(QueryAccess)DxaccSplitGetShareAmount },
|
||||
{ "d-share-int64", QUERYCORE_INT64, (QueryAccess)xaccSplitGetGUID },
|
||||
{ SPLIT_BALANCE, QUERYCORE_NUMERIC, (QueryAccess)xaccSplitGetBalance },
|
||||
{ SPLIT_CLEARED_BALANCE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetClearedBalance },
|
||||
{ SPLIT_RECONCILED_BALANCE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetReconciledBalance },
|
||||
{ SPLIT_MEMO, QUERYCORE_STRING, (QueryAccess)xaccSplitGetMemo },
|
||||
{ SPLIT_ACTION, QUERYCORE_STRING, (QueryAccess)xaccSplitGetAction },
|
||||
{ SPLIT_RECONCILE, QUERYCORE_CHAR, (QueryAccess)xaccSplitGetReconcile },
|
||||
{ SPLIT_AMOUNT, QUERYCORE_NUMERIC, (QueryAccess)xaccSplitGetAmount },
|
||||
{ SPLIT_SHARE_PRICE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitGetSharePrice },
|
||||
{ SPLIT_VALUE, QUERYCORE_DEBCRED, (QueryAccess)xaccSplitGetValue },
|
||||
{ SPLIT_TYPE, QUERYCORE_STRING, (QueryAccess)xaccSplitGetType },
|
||||
{ SPLIT_VOIDED_AMOUNT, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitVoidFormerAmount },
|
||||
{ SPLIT_VOIDED_VALUE, QUERYCORE_NUMERIC,
|
||||
(QueryAccess)xaccSplitVoidFormerValue },
|
||||
{ SPLIT_TRANS, GNC_ID_TRANS, (QueryAccess)xaccSplitGetParent },
|
||||
{ SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QueryAccess)xaccSplitGetAccount },
|
||||
{ SPLIT_ACCOUNT_GUID, QUERYCORE_GUID, split_account_guid_getter },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccSplitGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess) xaccSplitGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_SPLIT, (QuerySort)xaccSplitDateOrder, params);
|
||||
|
||||
return gncObjectRegister (&split_object_def);
|
||||
}
|
||||
|
||||
static void
|
||||
trans_foreach (GNCBook *book, foreachObjectCB fcn, gpointer user_data)
|
||||
{
|
||||
do_foreach (book, GNC_ID_TRANS, fcn, user_data);
|
||||
}
|
||||
|
||||
static GncObject_t trans_object_def = {
|
||||
GNC_OBJECT_VERSION,
|
||||
GNC_ID_TRANS,
|
||||
"Transaction",
|
||||
NULL, /* book_begin */
|
||||
NULL, /* book_end */
|
||||
NULL, /* is_dirty */
|
||||
NULL, /* mark_clean */
|
||||
trans_foreach, /* foreach */
|
||||
xaccTransGetDescription /* printable */
|
||||
};
|
||||
|
||||
gboolean xaccTransRegister (void)
|
||||
{
|
||||
static QueryObjectDef params[] = {
|
||||
{ TRANS_KVP, QUERYCORE_KVP, (QueryAccess)xaccTransGetSlots },
|
||||
{ TRANS_NUM, QUERYCORE_STRING, (QueryAccess)xaccTransGetNum },
|
||||
{ TRANS_DESCRIPTON, QUERYCORE_STRING, (QueryAccess)xaccTransGetDescription },
|
||||
{ TRANS_DATE_ENTERED, QUERYCORE_DATE, (QueryAccess)xaccTransRetDateEnteredTS },
|
||||
{ TRANS_DATE_POSTED, QUERYCORE_DATE, (QueryAccess)xaccTransRetDatePostedTS },
|
||||
{ TRANS_DATE_DUE, QUERYCORE_DATE, (QueryAccess)xaccTransRetDateDueTS },
|
||||
{ TRANS_TYPE, QUERYCORE_CHAR, (QueryAccess)xaccTransGetTxnType },
|
||||
{ TRANS_VOID_STATUS, QUERYCORE_BOOLEAN, (QueryAccess)xaccTransGetVoidStatus },
|
||||
{ TRANS_VOID_REASON, QUERYCORE_STRING, (QueryAccess)xaccTransGetVoidReason },
|
||||
{ TRANS_VOID_TIME, QUERYCORE_DATE, (QueryAccess)xaccTransGetVoidTime },
|
||||
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QueryAccess)xaccTransGetSplitList },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)xaccTransGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)xaccTransGetGUID },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
gncQueryObjectRegister (GNC_ID_TRANS, (QuerySort)xaccTransOrder, params);
|
||||
|
||||
return gncObjectRegister (&trans_object_def);
|
||||
}
|
||||
|
||||
/************************ END OF ************************************\
|
||||
\************************* FILE *************************************/
|
||||
|
@ -257,4 +257,9 @@ gint32 xaccTransGetVersion (Transaction*);
|
||||
gnc_commodity * xaccTransFindOldCommonCurrency (Transaction *trans,
|
||||
GNCBook *book);
|
||||
|
||||
/* Code to register Split and Transaction types with the engine */
|
||||
gboolean xaccSplitRegister (void);
|
||||
gboolean xaccTransRegister (void);
|
||||
|
||||
|
||||
#endif /* XACC_TRANSACTION_P_H */
|
||||
|
@ -109,4 +109,7 @@ GNCEntityTable * gnc_book_get_entity_table (GNCBook *book);
|
||||
*/
|
||||
void gnc_book_mark_saved(GNCBook *book);
|
||||
|
||||
/* Register books with the engine */
|
||||
gboolean gnc_book_register (void);
|
||||
|
||||
#endif /* GNC_BOOK_P_H */
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "gnc-event-p.h"
|
||||
#include "gnc-module.h"
|
||||
#include "gncObjectP.h"
|
||||
#include "QueryObject.h"
|
||||
|
||||
static short module = MOD_IO;
|
||||
|
||||
@ -497,4 +498,20 @@ gnc_book_get_counter (GNCBook *book, const char *counter_name)
|
||||
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 =============================== */
|
||||
|
@ -30,6 +30,10 @@
|
||||
#include "gncObjectP.h"
|
||||
#include "gnc-engine.h"
|
||||
|
||||
#include "TransactionP.h"
|
||||
#include "AccountP.h"
|
||||
#include "gnc-book-p.h"
|
||||
|
||||
static GList * engine_init_hooks = NULL;
|
||||
static int engine_is_initialized = 0;
|
||||
GCache * gnc_string_cache = NULL;
|
||||
@ -75,6 +79,12 @@ gnc_engine_init(int argc, char ** argv)
|
||||
gncObjectInitialize ();
|
||||
gncQueryNewInit ();
|
||||
|
||||
/* Now register our core types */
|
||||
xaccSplitRegister ();
|
||||
xaccTransRegister ();
|
||||
xaccAccountRegister ();
|
||||
gnc_book_register ();
|
||||
|
||||
/* call any engine hooks */
|
||||
for (cur = engine_init_hooks; cur; cur = cur->next)
|
||||
{
|
||||
|
@ -17,7 +17,6 @@
|
||||
#define GNC_OBJECT_VERSION 1
|
||||
|
||||
typedef struct _gncObjectDef GncObject_t;
|
||||
typedef void (*foreachObjectCB) (gpointer object, gpointer user_data);
|
||||
typedef void (*foreachTypeCB) (GncObject_t *type, gpointer user_data);
|
||||
typedef void (*foreachBackendTypeCB) (GNCIdTypeConst type,
|
||||
gpointer backend_data,
|
||||
|
Loading…
Reference in New Issue
Block a user