merge from entity-mess branch: minor tweaks to bring into line

with entity reworjk in engine.  Add GPL licenses to some of the files.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9533 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-10-17 04:32:04 +00:00
parent dc8c81714b
commit 5b7d9cae9e
20 changed files with 260 additions and 206 deletions

View File

@ -44,6 +44,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
@ -432,7 +433,7 @@ void gncBillTermChanged (GncBillTerm *term)
void gncBillTermBeginEdit (GncBillTerm *term)
{
GNC_BEGIN_EDIT (&term->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&term->inst);
}
static void gncBillTermOnError (QofInstance *inst, QofBackendError errcode)
@ -451,16 +452,14 @@ static inline void on_done (QofInstance *inst) {}
void gncBillTermCommitEdit (GncBillTerm *term)
{
GNC_COMMIT_EDIT_PART1 (&term->inst);
GNC_COMMIT_EDIT_PART2 (&term->inst, _GNC_MOD_NAME, gncBillTermOnError,
GNC_COMMIT_EDIT_PART2 (&term->inst, gncBillTermOnError,
on_done, bill_free);
}
/* Get Functions */
GncBillTerm * gncBillTermLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (qof_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP(GncBillTerm);
}
GncBillTerm *gncBillTermLookupByName (QofBook *book, const char *name)
@ -714,16 +713,16 @@ static void _gncBillTermMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncBillTermForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncBillTermForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);
gncBusinessForeach (book, _GNC_MOD_NAME, (QofEntityForeachCB) cb, user_data);
}
static QofObject gncBillTermDesc =
{
interface_version: QOF_OBJECT_VERSION,
name: _GNC_MOD_NAME,
e_type: _GNC_MOD_NAME,
type_label: "Billing Term",
book_begin: _gncBillTermCreate,
book_end: _gncBillTermDestroy,

View File

@ -21,8 +21,17 @@ typedef struct _gncBookInfo {
} GncBookInfo;
#define gncBusinessForeach(book,mod_name,cb,user_data) \
qof_entity_foreach(qof_book_get_entity_table(book), mod_name, cb, user_data)
#define gncBusinessForeach(book,mod_name,cb,userdata) \
qof_collection_foreach(qof_book_get_collection((book), (mod_name)), ((QofEntityForeachCB)(cb)), (userdata))
/** another temporary hack for entity lookup */
#define ELOOKUP(c_type) { \
QofCollection *col; \
if (!guid || !book) return NULL; \
col = qof_book_get_collection (book, _GNC_MOD_NAME); \
return (c_type *) qof_collection_lookup_entity (col, guid); \
}
void gncBusinessCreate (QofBook *book, QofIdType mod_name);

View File

@ -43,6 +43,7 @@
#include "qofid-p.h"
#include "qofid.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquerycore.h"
#include "qofquery.h"
@ -398,7 +399,7 @@ void gncCustomerRemoveJob (GncCustomer *cust, GncJob *job)
void gncCustomerBeginEdit (GncCustomer *cust)
{
GNC_BEGIN_EDIT (&cust->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&cust->inst);
}
static inline void gncCustomerOnError (QofInstance *inst, QofBackendError errcode)
@ -422,7 +423,7 @@ static inline void cust_free (QofInstance *inst)
void gncCustomerCommitEdit (GncCustomer *cust)
{
GNC_COMMIT_EDIT_PART1 (&cust->inst);
GNC_COMMIT_EDIT_PART2 (&cust->inst, _GNC_MOD_NAME, gncCustomerOnError,
GNC_COMMIT_EDIT_PART2 (&cust->inst, gncCustomerOnError,
gncCustomerOnDone, cust_free);
}
@ -539,9 +540,7 @@ GncCustomer * gncCustomerLookupDirect (GUID guid, QofBook *book)
GncCustomer * gncCustomerLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP (GncCustomer);
}
gboolean gncCustomerIsDirty (GncCustomer *cust)
@ -585,7 +584,7 @@ static void _gncCustomerMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncCustomerForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncCustomerForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -21,6 +21,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
#include "qofquerycore.h"
@ -283,23 +284,7 @@ Account * gncEmployeeGetCCard (GncEmployee *employee)
GncEmployee * gncEmployeeLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
}
GUID gncEmployeeRetGUID (GncEmployee *employee)
{
if (!employee)
return *guid_null();
return employee->inst.entity.guid;
}
GncEmployee * gncEmployeeLookupDirect (GUID guid, QofBook *book)
{
if (!book) return NULL;
return gncEmployeeLookup (book, &guid);
ELOOKUP(GncEmployee);
}
gboolean gncEmployeeIsDirty (GncEmployee *employee)
@ -310,7 +295,7 @@ gboolean gncEmployeeIsDirty (GncEmployee *employee)
void gncEmployeeBeginEdit (GncEmployee *employee)
{
GNC_BEGIN_EDIT (&employee->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&employee->inst);
}
static inline void gncEmployeeOnError (QofInstance *employee, QofBackendError errcode)
@ -334,7 +319,7 @@ static inline void emp_free (QofInstance *inst)
void gncEmployeeCommitEdit (GncEmployee *employee)
{
GNC_COMMIT_EDIT_PART1 (&employee->inst);
GNC_COMMIT_EDIT_PART2 (&employee->inst, _GNC_MOD_NAME, gncEmployeeOnError,
GNC_COMMIT_EDIT_PART2 (&employee->inst, gncEmployeeOnError,
gncEmployeeOnDone, emp_free);
}
@ -370,7 +355,7 @@ static void _gncEmployeeMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncEmployeeForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncEmployeeForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -9,7 +9,8 @@
typedef struct _gncEmployee GncEmployee;
#include "gnc-book.h"
#include "qofbook.h"
#include "qofid.h"
#include "gncAddress.h"
#include "Account.h"
@ -35,7 +36,6 @@ void gncEmployeeSetCCard (GncEmployee *employee, Account* ccard_acc);
/* Get Functions */
QofBook * gncEmployeeGetBook (GncEmployee *employee);
const GUID * gncEmployeeGetGUID (GncEmployee *employee);
const char * gncEmployeeGetID (GncEmployee *employee);
const char * gncEmployeeGetUsername (GncEmployee *employee);
GncAddress * gncEmployeeGetAddr (GncEmployee *employee);
@ -50,8 +50,6 @@ Account * gncEmployeeGetCCard (GncEmployee *employee);
GncEmployee * gncEmployeeLookup (QofBook *book, const GUID *guid);
gboolean gncEmployeeIsDirty (GncEmployee *employee);
GUID gncEmployeeRetGUID (GncEmployee *employee);
GncEmployee * gncEmployeeLookupDirect (GUID guid, QofBook *book);
void gncEmployeeBeginEdit (GncEmployee *employee);
void gncEmployeeCommitEdit (GncEmployee *employee);
@ -61,4 +59,9 @@ int gncEmployeeCompare (GncEmployee *a, GncEmployee *b);
#define EMPLOYEE_USERNAME "username"
#define EMPLOYEE_ADDR "addr"
/** deprecated routines */
// const GUID * gncEmployeeGetGUID (GncEmployee *employee);
#define gncEmployeeRetGUID(E) (*(qof_entity_get_guid(QOF_ENTITY(E))))
#define gncEmployeeLookupDirect(G,B) gncEmployeeLookup((B),&(G))
#endif /* GNC_EMPLOYEE_H_ */

View File

@ -20,6 +20,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
#include "qofquerycore.h"
@ -734,9 +735,7 @@ GncOrder * gncEntryGetOrder (GncEntry *entry)
GncEntry * gncEntryLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP(GncEntry);
}
/*
@ -1080,7 +1079,7 @@ gboolean gncEntryIsOpen (GncEntry *entry)
void gncEntryBeginEdit (GncEntry *entry)
{
GNC_BEGIN_EDIT (&entry->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&entry->inst);
}
static inline void gncEntryOnError (QofInstance *entry, QofBackendError errcode)
@ -1088,9 +1087,8 @@ static inline void gncEntryOnError (QofInstance *entry, QofBackendError errcode)
PERR("Entry QofBackend Failure: %d", errcode);
}
static inline void gncEntryOnDone (QofInstance *inst)
{
}
static inline void gncEntryOnDone (QofInstance *inst) {}
static inline void entry_free (QofInstance *inst)
{
GncEntry *entry = (GncEntry *)inst;
@ -1100,7 +1098,7 @@ static inline void entry_free (QofInstance *inst)
void gncEntryCommitEdit (GncEntry *entry)
{
GNC_COMMIT_EDIT_PART1 (&entry->inst);
GNC_COMMIT_EDIT_PART2 (&entry->inst, _GNC_MOD_NAME, gncEntryOnError,
GNC_COMMIT_EDIT_PART2 (&entry->inst, gncEntryOnError,
gncEntryOnDone, entry_free);
}
@ -1148,7 +1146,7 @@ static void _gncEntryMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncEntryForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncEntryForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncInvoice.c -- the Core Business Invoice *
* *
* 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 *
* *
\********************************************************************/
/*
* gncInvoice.c -- the Core Business Invoice
* Copyright (C) 2001,2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@ -20,6 +41,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquerycore.h"
#include "qofquery.h"
@ -144,15 +166,14 @@ static void gncInvoiceFree (GncInvoice *invoice)
g_free (invoice);
}
/* Set Functions */
void gncInvoiceSetGUID (GncInvoice *invoice, const GUID *guid)
GncInvoice *
gncInvoiceLookup(QofBook *book, const GUID *guid)
{
if (!invoice || !guid) return;
qof_entity_set_guid(&invoice->inst.entity, guid);
ELOOKUP(GncInvoice);
}
/* Set Functions */
void gncInvoiceSetID (GncInvoice *invoice, const char *id)
{
if (!invoice || !id) return;
@ -588,9 +609,7 @@ GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot)
if (!value) return NULL;
guid = kvp_value_get_guid (value);
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
return gncInvoiceLookup(book, guid);
}
static void
@ -614,7 +633,8 @@ gncInvoiceAttachToTxn (GncInvoice *invoice, Transaction *txn)
gncInvoiceSetPostedTxn (invoice, txn);
}
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn)
GncInvoice *
gncInvoiceGetInvoiceFromTxn (Transaction *txn)
{
KvpFrame *kvp;
KvpValue *value;
@ -629,9 +649,7 @@ GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn)
if (!value) return NULL;
guid = kvp_value_get_guid (value);
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
return gncInvoiceLookup(book,guid);
}
struct lotmatch {
@ -1207,40 +1225,17 @@ gboolean gncInvoiceIsPaid (GncInvoice *invoice)
return gnc_lot_is_closed(invoice->posted_lot);
}
GUID gncInvoiceRetGUID (GncInvoice *invoice)
{
if (!invoice)
return *guid_null();
return invoice->inst.entity.guid;
}
GncInvoice * gncInvoiceLookupDirect (GUID guid, QofBook *book)
{
if (!book) return NULL;
return gncInvoiceLookup (book, &guid);
}
GncInvoice * gncInvoiceLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
}
void gncInvoiceBeginEdit (GncInvoice *invoice)
{
GNC_BEGIN_EDIT (&invoice->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&invoice->inst);
}
static void inline gncInvoiceOnError (QofInstance *inst, QofBackendError errcode)
static inline void gncInvoiceOnError (QofInstance *inst, QofBackendError errcode)
{
PERR("Invoice QofBackend Failure: %d", errcode);
}
static void gncInvoiceOnDone (QofInstance *invoice)
{
}
static inline void gncInvoiceOnDone (QofInstance *invoice) { }
static inline void invoice_free (QofInstance *inst)
{
@ -1251,7 +1246,7 @@ static inline void invoice_free (QofInstance *inst)
void gncInvoiceCommitEdit (GncInvoice *invoice)
{
GNC_COMMIT_EDIT_PART1 (&invoice->inst);
GNC_COMMIT_EDIT_PART2 (&invoice->inst, _GNC_MOD_NAME, gncInvoiceOnError,
GNC_COMMIT_EDIT_PART2 (&invoice->inst, gncInvoiceOnError,
gncInvoiceOnDone, invoice_free);
}
@ -1292,12 +1287,12 @@ static gboolean _gncInvoiceIsDirty (QofBook *book)
return gncBusinessIsDirty (book, _GNC_MOD_NAME);
}
static void _gncInvoiceMarkClean (QofBook *book)
static inline void _gncInvoiceMarkClean (QofBook *book)
{
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncInvoiceForeach (QofBook *book, QofEntityForeachCB cb,
static inline void _gncInvoiceForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncInvoice.h -- the Core Business Invoice 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 *
* *
\********************************************************************/
/*
* gncInvoice.h -- the Core Business Invoice Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@ -113,9 +134,6 @@ GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn);
/* Given a LOT, find and return the Invoice attached to the lot */
GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
GUID gncInvoiceRetGUID (GncInvoice *invoice);
GncInvoice * gncInvoiceLookupDirect (GUID guid, QofBook *book);
GncInvoice * gncInvoiceLookup (QofBook *book, const GUID *guid);
gboolean gncInvoiceIsDirty (GncInvoice *invoice);
void gncInvoiceBeginEdit (GncInvoice *invoice);
@ -146,5 +164,7 @@ gboolean gncInvoiceIsPaid (GncInvoice *invoice);
/** deprecated functions */
#define gncInvoiceGetBook(x) qof_instance_get_book(QOF_INSTANCE(x))
#define gncInvoiceGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
#define gncInvoiceRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x))))
#define gncInvoiceLookupDirect(G,B) gncInvoiceLookup((B),&(G))
#endif /* GNC_INVOICE_H_ */

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncInvoiceP.h -- the Core Busines Invoice 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 *
* *
\********************************************************************/
/*
* gncInvoiceP.h -- the Core Busines Invoice Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@ -11,14 +32,15 @@
#include "Account.h"
#include "Transaction.h"
#include "gnc-lot.h"
#include "qofid-p.h"
gboolean gncInvoiceRegister (void);
gint64 gncInvoiceNextID (QofBook *book);
void gncInvoiceSetGUID (GncInvoice *invoice, const GUID *guid);
void gncInvoiceSetDirty (GncInvoice *invoice, gboolean dirty);
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot);
void gncInvoiceSetPaidTxn (GncInvoice *invoice, Transaction *txn);
#define gncInvoiceSetGUID(I,G) qof_entity_set_guid(QOF_ENTITY(I),(G))
#endif /* GNC_INVOICEP_H_ */

View File

@ -41,6 +41,7 @@
#include "qofbook.h"
#include "qofclass.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofid.h"
#include "qofid-p.h"
#include "qofobject.h"
@ -269,7 +270,7 @@ void gncJobSetActive (GncJob *job, gboolean active)
void gncJobBeginEdit (GncJob *job)
{
GNC_BEGIN_EDIT (&job->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&job->inst);
}
static void gncJobOnError (QofInstance *inst, QofBackendError errcode)
@ -288,7 +289,7 @@ static inline void gncJobOnDone (QofInstance *qof) { }
void gncJobCommitEdit (GncJob *job)
{
GNC_COMMIT_EDIT_PART1 (&job->inst);
GNC_COMMIT_EDIT_PART2 (&job->inst, _GNC_MOD_NAME, gncJobOnError,
GNC_COMMIT_EDIT_PART2 (&job->inst, gncJobOnError,
gncJobOnDone, job_free);
}
@ -319,14 +320,6 @@ GncOwner * gncJobGetOwner (GncJob *job)
return &(job->owner);
}
GUID gncJobRetGUID (GncJob *job)
{
const GUID *guid = qof_instance_get_guid (&job->inst);
if (guid)
return *guid;
return *guid_null ();
}
gboolean gncJobGetActive (GncJob *job)
{
if (!job) return FALSE;
@ -335,15 +328,7 @@ gboolean gncJobGetActive (GncJob *job)
GncJob * gncJobLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
}
GncJob * gncJobLookupDirect (GUID guid, QofBook *book)
{
if (!book) return NULL;
return gncJobLookup (book, &guid);
ELOOKUP(GncJob);
}
/* Other functions */
@ -379,7 +364,7 @@ static void _gncJobMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncJobForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncJobForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -59,9 +59,6 @@ const char * gncJobGetReference (GncJob *job);
GncOwner * gncJobGetOwner (GncJob *job);
gboolean gncJobGetActive (GncJob *job);
GUID gncJobRetGUID (GncJob *job);
GncJob *gncJobLookupDirect (GUID guid, QofBook *book);
GncJob * gncJobLookup (QofBook *book, const GUID *guid);
gboolean gncJobIsDirty (GncJob *job);
@ -78,5 +75,7 @@ int gncJobCompare (const GncJob *a, const GncJob *b);
/** deprecated functions */
#define gncJobGetBook(x) qof_instance_get_book(QOF_INSTANCE(x))
#define gncJobGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
#define gncJobRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x))))
#define gncJobLookupDirect(G,B) gncJobLookup((B),&(G))
#endif /* GNC_JOB_H_ */

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncOrder.c -- the Core Business Order *
* *
* 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 *
* *
\********************************************************************/
/*
* gncOrder.c -- the Core Business Order
* Copyright (C) 2001,2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@ -18,6 +39,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
#include "qofquerycore.h"
@ -123,13 +145,6 @@ static void gncOrderFree (GncOrder *order)
/* Set Functions */
void gncOrderSetGUID (GncOrder *order, const GUID *guid)
{
if (!order || !guid) return;
qof_entity_set_guid(&order->inst.entity, guid);
}
void gncOrderSetID (GncOrder *order, const char *id)
{
if (!order || !id) return;
@ -285,9 +300,7 @@ GList * gncOrderGetEntries (GncOrder *order)
GncOrder * gncOrderLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP(GncOrder);
}
gboolean gncOrderIsClosed (GncOrder *order)
@ -299,7 +312,7 @@ gboolean gncOrderIsClosed (GncOrder *order)
void gncOrderBeginEdit (GncOrder *order)
{
GNC_BEGIN_EDIT (&order->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&order->inst);
}
static inline void gncOrderOnError (QofInstance *order, QofBackendError errcode)
@ -307,9 +320,7 @@ static inline void gncOrderOnError (QofInstance *order, QofBackendError errcode)
PERR("Order QofBackend Failure: %d", errcode);
}
static inline void gncOrderOnDone (QofInstance *order)
{
}
static inline void gncOrderOnDone (QofInstance *order) {}
static inline void order_free (QofInstance *inst)
{
@ -320,7 +331,7 @@ static inline void order_free (QofInstance *inst)
void gncOrderCommitEdit (GncOrder *order)
{
GNC_COMMIT_EDIT_PART1 (&order->inst);
GNC_COMMIT_EDIT_PART2 (&order->inst, _GNC_MOD_NAME, gncOrderOnError,
GNC_COMMIT_EDIT_PART2 (&order->inst, gncOrderOnError,
gncOrderOnDone, order_free);
}
@ -366,7 +377,7 @@ static void _gncOrderMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncOrderForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncOrderForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncOrder.h -- the Core Business Order 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 *
* *
\********************************************************************/
/*
* gncOrder.h -- the Core Business Order Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncOrderP.h -- the Core Busines Order 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 *
* *
\********************************************************************/
/*
* gncOrderP.h -- the Core Busines Order Interface
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
@ -8,10 +29,12 @@
#define GNC_ORDERP_H_
#include "gncOrder.h"
#include "qofid-p.h"
gboolean gncOrderRegister (void);
gint64 gncOrderNextID (QofBook *book);
void gncOrderSetGUID (GncOrder *order, const GUID *guid);
void gncOrderSetDirty (GncOrder *order, gboolean dirty);
#define gncOrderSetGUID(O,G) qof_entity_set_guid(QOF_ENTITY(O),(G))
#endif /* GNC_ORDERP_H_ */

View File

@ -1,5 +1,26 @@
/********************************************************************\
* gncOwner.h -- Business Interface: Object OWNERs *
* *
* 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 *
* *
\********************************************************************/
/*
* gncOwner.h -- Business Interface: Object OWNERs
* Copyright (C) 2001, 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/

View File

@ -41,6 +41,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
#include "qofquerycore.h"
@ -539,20 +540,17 @@ void gncTaxTableChanged (GncTaxTable *table)
void gncTaxTableBeginEdit (GncTaxTable *table)
{
GNC_BEGIN_EDIT (&table->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&table->inst);
}
static void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode)
static inline void gncTaxTableOnError (QofInstance *inst, QofBackendError errcode)
{
PERR("TaxTable QofBackend Failure: %d", errcode);
}
static void gncTaxTableOnDone (QofInstance *inst)
{
inst->dirty = FALSE;
}
static inline void gncTaxTableOnDone (QofInstance *inst) {}
static void table_free (QofInstance *inst)
static inline void table_free (QofInstance *inst)
{
GncTaxTable *table = (GncTaxTable *) inst;
gncTaxTableFree (table);
@ -561,7 +559,7 @@ static void table_free (QofInstance *inst)
void gncTaxTableCommitEdit (GncTaxTable *table)
{
GNC_COMMIT_EDIT_PART1 (&table->inst);
GNC_COMMIT_EDIT_PART2 (&table->inst, _GNC_MOD_NAME, gncTaxTableOnError,
GNC_COMMIT_EDIT_PART2 (&table->inst, gncTaxTableOnError,
gncTaxTableOnDone, table_free);
}
@ -570,9 +568,7 @@ void gncTaxTableCommitEdit (GncTaxTable *table)
/* Get Functions */
GncTaxTable * gncTaxTableLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (qof_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP(GncTaxTable);
}
GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name)
@ -791,20 +787,6 @@ void gncAccountValueDestroy (GList *list)
g_list_free (list);
}
GUID gncTaxTableRetGUID (GncTaxTable *table)
{
if (!table)
return *guid_null();
return table->inst.entity.guid;
}
GncTaxTable *gncTaxTableLookupDirect (GUID guid, QofBook *book)
{
if (!book) return NULL;
return gncTaxTableLookup (book, &guid);
}
/* Package-Private functions */
static void _gncTaxTableCreate (QofBook *book)
@ -839,7 +821,7 @@ static void _gncTaxTableMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncTaxTableForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncTaxTableForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);
@ -848,7 +830,7 @@ static void _gncTaxTableForeach (QofBook *book, QofEntityForeachCB cb,
static QofObject gncTaxTableDesc =
{
interface_version: QOF_OBJECT_VERSION,
name: _GNC_MOD_NAME,
e_type: _GNC_MOD_NAME,
type_label: "Tax Table",
book_begin: _gncTaxTableCreate,
book_end: _gncTaxTableDestroy,

View File

@ -106,9 +106,6 @@ gnc_numeric gncTaxTableEntryGetAmount (GncTaxTableEntry *entry);
int gncTaxTableCompare (GncTaxTable *a, GncTaxTable *b);
int gncTaxTableEntryCompare (GncTaxTableEntry *a, GncTaxTableEntry *b);
GUID gncTaxTableRetGUID (GncTaxTable *table);
GncTaxTable *gncTaxTableLookupDirect (GUID guid, QofBook *book);
/************************************************/
struct _gncAccountValue {
@ -131,9 +128,10 @@ gnc_numeric gncAccountValueTotal (GList *list);
/** Destroy a list of accountvalues */
void gncAccountValueDestroy (GList *list);
/** deprecated routine */
#define gncTaxTableGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
#define gncTaxTableRetGUID(x) (*(qof_instance_get_guid(QOF_INSTANCE(x))))
#define gncTaxTableLookupDirect(G,B) gncTaxTableLookup((B), &(G))
#endif /* GNC_TAXTABLE_H_ */
/** @} */

View File

@ -42,6 +42,7 @@
#include "qofid.h"
#include "qofid-p.h"
#include "qofinstance.h"
#include "qofinstance-p.h"
#include "qofobject.h"
#include "qofquery.h"
#include "qofquerycore.h"
@ -354,7 +355,7 @@ void gncVendorRemoveJob (GncVendor *vendor, GncJob *job)
void gncVendorBeginEdit (GncVendor *vendor)
{
GNC_BEGIN_EDIT (&vendor->inst, _GNC_MOD_NAME);
GNC_BEGIN_EDIT (&vendor->inst);
}
static inline void gncVendorOnError (QofInstance *vendor, QofBackendError errcode)
@ -377,7 +378,7 @@ static inline void vendor_free (QofInstance *inst)
void gncVendorCommitEdit (GncVendor *vendor)
{
GNC_COMMIT_EDIT_PART1 (&vendor->inst);
GNC_COMMIT_EDIT_PART2 (&vendor->inst, _GNC_MOD_NAME, gncVendorOnError,
GNC_COMMIT_EDIT_PART2 (&vendor->inst, gncVendorOnError,
gncVendorOnDone, vendor_free);
}
@ -410,25 +411,9 @@ GList * gncVendorGetJoblist (GncVendor *vendor, gboolean show_all)
}
}
GUID gncVendorRetGUID (GncVendor *vendor)
{
if (!vendor)
return *guid_null();
return vendor->inst.entity.guid;
}
GncVendor * gncVendorLookupDirect (GUID guid, QofBook *book)
{
if (!book) return NULL;
return gncVendorLookup (book, &guid);
}
GncVendor * gncVendorLookup (QofBook *book, const GUID *guid)
{
if (!book || !guid) return NULL;
return qof_entity_lookup (gnc_book_get_entity_table (book),
guid, _GNC_MOD_NAME);
ELOOKUP (GncVendor);
}
gboolean gncVendorIsDirty (GncVendor *vendor)
@ -460,7 +445,7 @@ static void _gncVendorMarkClean (QofBook *book)
gncBusinessSetDirtyFlag (book, _GNC_MOD_NAME, FALSE);
}
static void _gncVendorForeach (QofBook *book, QofEntityForeachCB cb,
static void _gncVendorForeach (QofBook *book, QofForeachCB cb,
gpointer user_data)
{
gncBusinessForeach (book, _GNC_MOD_NAME, cb, user_data);

View File

@ -60,9 +60,6 @@ GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor);
*/
GList * gncVendorGetJoblist (GncVendor *vendor, gboolean show_all);
GUID gncVendorRetGUID (GncVendor *vendor);
GncVendor * gncVendorLookupDirect (GUID guid, QofBook *book);
GncVendor * gncVendorLookup (QofBook *book, const GUID *guid);
gboolean gncVendorIsDirty (GncVendor *vendor);
int gncVendorCompare (GncVendor *a, GncVendor *b);
@ -74,5 +71,7 @@ int gncVendorCompare (GncVendor *a, GncVendor *b);
/** deprecated functions */
#define gncVendorGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
#define gncVendorGetGUID(X) qof_instance_get_guid (QOF_INSTANCE(X))
#define gncVendorRetGUID(X) (*(qof_instance_get_guid (QOF_INSTANCE(X))))
#define gncVendorLookupDirect(G,B) gncVendorLookup((B),&(G))
#endif /* GNC_VENDOR_H_ */

View File

@ -14,23 +14,23 @@
static int count = 0;
static void
test_string_fcn (GNCBook *book, const char *message,
test_string_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, const char *str),
const char * (*get)(GncEmployee *));
static void
test_numeric_fcn (GNCBook *book, const char *message,
test_numeric_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gnc_numeric),
gnc_numeric (*get)(GncEmployee *));
static void
test_bool_fcn (GNCBook *book, const char *message,
test_bool_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gboolean),
gboolean (*get) (GncEmployee *));
#if 0
static void
test_gint_fcn (GNCBook *book, const char *message,
test_gint_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gint),
gint (*get) (GncEmployee *));
#endif
@ -38,10 +38,10 @@ test_gint_fcn (GNCBook *book, const char *message,
static void
test_employee (void)
{
GNCBook *book;
QofBook *book;
GncEmployee *employee;
book = gnc_book_new ();
book = qof_book_new ();
/* Test creation/destruction */
{
@ -106,7 +106,7 @@ test_employee (void)
}
static void
test_string_fcn (GNCBook *book, const char *message,
test_string_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, const char *str),
const char * (*get)(GncEmployee *))
{
@ -125,7 +125,7 @@ test_string_fcn (GNCBook *book, const char *message,
}
static void
test_numeric_fcn (GNCBook *book, const char *message,
test_numeric_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gnc_numeric),
gnc_numeric (*get)(GncEmployee *))
{
@ -144,7 +144,7 @@ test_numeric_fcn (GNCBook *book, const char *message,
}
static void
test_bool_fcn (GNCBook *book, const char *message,
test_bool_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gboolean),
gboolean (*get) (GncEmployee *))
{
@ -166,7 +166,7 @@ test_bool_fcn (GNCBook *book, const char *message,
#if 0
static void
test_gint_fcn (GNCBook *book, const char *message,
test_gint_fcn (QofBook *book, const char *message,
void (*set) (GncEmployee *, gint),
gint (*get) (GncEmployee *))
{