mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
-- 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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9965 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -146,10 +146,10 @@ int finishQuery(PGBackend *be);
|
||||
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); \
|
||||
|
||||
@@ -678,6 +678,7 @@ static QofObject gncBillTermDesc =
|
||||
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 @@ static QofObject gncBillTermDesc =
|
||||
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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -536,6 +536,7 @@ static QofObject gncCustomerDesc =
|
||||
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 @@ gboolean gncCustomerRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -403,6 +403,7 @@ static QofObject gncEmployeeDesc =
|
||||
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 @@ gboolean gncEmployeeRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -1169,6 +1169,7 @@ static QofObject gncEntryDesc =
|
||||
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 @@ gboolean gncEntryRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -1363,6 +1363,7 @@ static QofObject gncInvoiceDesc =
|
||||
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 @@ gboolean gncInvoiceRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -353,6 +353,7 @@ static QofObject gncJobDesc =
|
||||
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 @@ gboolean gncJobRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -425,6 +425,7 @@ static QofObject gncOrderDesc =
|
||||
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 @@ gboolean gncOrderRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ gboolean gncOwnerRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -799,6 +799,7 @@ static QofObject gncTaxTableDesc =
|
||||
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 @@ static QofObject gncTaxTableDesc =
|
||||
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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -486,6 +486,7 @@ static QofObject gncVendorDesc =
|
||||
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 @@ gboolean gncVendorRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -2836,6 +2836,7 @@ static QofObject account_object_def = {
|
||||
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 @@ gboolean xaccAccountRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
@@ -1263,6 +1263,7 @@ static QofObject group_object_def =
|
||||
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,
|
||||
|
||||
@@ -266,7 +266,7 @@ xaccQueryAddAccountGUIDMatch(Query *q, AccountGUIDList *guid_list,
|
||||
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 @@ xaccQueryAddGUIDMatch(Query * q, const GUID *guid,
|
||||
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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -269,6 +269,7 @@ static QofObject sxtt_object_def =
|
||||
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,
|
||||
|
||||
@@ -3187,6 +3187,7 @@ static QofObject split_object_def = {
|
||||
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 @@ gboolean xaccSplitRegister (void)
|
||||
{ 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 @@ static QofObject trans_object_def = {
|
||||
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 @@ gboolean xaccTransRegister (void)
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -1598,6 +1598,7 @@ static QofObject commodity_table_object_def =
|
||||
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,
|
||||
|
||||
@@ -361,8 +361,8 @@ gnc_lot_get_latest_split (GNCLot *lot)
|
||||
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 },
|
||||
|
||||
@@ -2057,6 +2057,7 @@ static QofObject pricedb_object_def =
|
||||
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,
|
||||
|
||||
@@ -221,6 +221,8 @@ qof_book_get_collection (QofBook *book, QofIdType entity_type)
|
||||
{
|
||||
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 @@ gboolean qof_book_register (void)
|
||||
{
|
||||
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 },
|
||||
};
|
||||
|
||||
|
||||
@@ -296,6 +296,7 @@ qof_gobject_register (QofType e_type, GObjectClass *obclass)
|
||||
/* 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;
|
||||
|
||||
@@ -182,6 +182,7 @@ qof_collection_get_type (QofCollection *col)
|
||||
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 @@ qof_collection_remove_entity (QofEntity *ent)
|
||||
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);
|
||||
|
||||
@@ -73,14 +73,16 @@ typedef const char * QofIdType;
|
||||
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_init (QofEntity *, QofIdType, QofCollection *);
|
||||
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 @@ void qof_collection_foreach (QofCollection *,
|
||||
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);
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -41,6 +41,22 @@ static GList *object_modules = NULL;
|
||||
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 @@ void qof_object_foreach_backend (const char *backend_name,
|
||||
|
||||
g_hash_table_foreach (ht, foreach_backend, &cb_data);
|
||||
}
|
||||
|
||||
/* ========================= END OF FILE =================== */
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
@{ */
|
||||
/** @file qofobject.h
|
||||
* @brief the Core Object Registration/Lookup Interface
|
||||
* @author Copyright (c) 2001,2002, Derek Atkins <warlord@MIT.EDU>
|
||||
* @author Copyright (c) 2001,2002 Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifndef QOF_OBJECT_H_
|
||||
@@ -61,8 +61,6 @@ typedef void (*QofForeachBackendTypeCB) (QofIdTypeConst type,
|
||||
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 @@ struct _QofObject
|
||||
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_initialize (void);
|
||||
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_type (QofForeachTypeCB cb, gpointer user_data);
|
||||
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,
|
||||
|
||||
@@ -1222,9 +1222,10 @@ void qof_query_set_book (QofQuery *q, QofBook *book)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,11 +105,11 @@ typedef enum {
|
||||
#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 */
|
||||
|
||||
@@ -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@linas.org>
|
||||
|
||||
*/
|
||||
|
||||
@@ -22,15 +22,16 @@ static void test_printable (const char *name, gpointer obj);
|
||||
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
|
||||
|
||||
@@ -110,9 +110,9 @@ foreach (@files)
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user