2005-11-07 09:45:58 -06:00
|
|
|
/********************************************************************\
|
|
|
|
* qofobject.c -- the Core Object Registration/Lookup Interface *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 2 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License*
|
|
|
|
* along with this program; if not, contact: *
|
|
|
|
* *
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
2005-11-16 23:35:02 -06:00
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
2005-11-07 09:45:58 -06:00
|
|
|
* *
|
|
|
|
\********************************************************************/
|
|
|
|
/*
|
|
|
|
* qofobject.c -- the Core Object Object Registry
|
|
|
|
* Copyright (C) 2001 Derek Atkins
|
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
2014-04-25 15:41:11 -05:00
|
|
|
extern "C"
|
|
|
|
{
|
2017-10-26 04:14:21 -05:00
|
|
|
#include <config.h>
|
2005-11-07 09:45:58 -06:00
|
|
|
#include <glib.h>
|
2014-04-25 15:41:11 -05:00
|
|
|
}
|
|
|
|
|
2006-01-08 11:51:29 -06:00
|
|
|
#include "qof.h"
|
2005-11-07 09:45:58 -06:00
|
|
|
#include "qofobject-p.h"
|
|
|
|
|
|
|
|
static QofLogModule log_module = QOF_MOD_OBJECT;
|
|
|
|
|
|
|
|
static gboolean object_is_initialized = FALSE;
|
|
|
|
static GList *object_modules = NULL;
|
|
|
|
static GList *book_list = NULL;
|
|
|
|
|
2011-08-07 16:30:17 -05:00
|
|
|
/*
|
|
|
|
* These getters are used in tests to reach static vars from outside
|
|
|
|
* They should be removed when no longer needed
|
|
|
|
*/
|
|
|
|
|
2014-04-25 15:41:11 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2011-08-07 16:30:17 -05:00
|
|
|
gboolean get_object_is_initialized( void );
|
|
|
|
GList* get_object_modules( void );
|
|
|
|
GList* get_book_list( void );
|
|
|
|
|
2014-04-25 15:41:11 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-07 16:30:17 -05:00
|
|
|
gboolean
|
2011-08-22 02:10:56 -05:00
|
|
|
get_object_is_initialized( void )
|
|
|
|
{
|
|
|
|
return object_is_initialized;
|
|
|
|
}
|
2011-08-07 16:30:17 -05:00
|
|
|
|
|
|
|
GList*
|
2011-08-22 02:10:56 -05:00
|
|
|
get_object_modules( void )
|
|
|
|
{
|
|
|
|
return object_modules;
|
|
|
|
}
|
2011-08-07 16:30:17 -05:00
|
|
|
|
|
|
|
GList*
|
2011-08-22 02:10:56 -05:00
|
|
|
get_book_list( void )
|
|
|
|
{
|
|
|
|
return book_list;
|
|
|
|
}
|
2011-08-07 16:30:17 -05:00
|
|
|
|
|
|
|
/*********/
|
|
|
|
|
2005-11-07 09:45:58 -06:00
|
|
|
gpointer
|
|
|
|
qof_object_new_instance (QofIdTypeConst type_name, QofBook *book)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
const QofObject *obj;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!type_name) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
obj = qof_object_lookup (type_name);
|
|
|
|
if (!obj) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (obj->create)
|
|
|
|
return (obj->create (book));
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void qof_object_book_begin (QofBook *book)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
if (!book) return;
|
|
|
|
ENTER (" ");
|
|
|
|
for (l = object_modules; l; l = l->next)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
QofObject *obj = static_cast<QofObject*>(l->data);
|
2009-09-18 14:40:57 -05:00
|
|
|
if (obj->book_begin)
|
|
|
|
obj->book_begin (book);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remember this book for later */
|
|
|
|
book_list = g_list_prepend (book_list, book);
|
|
|
|
LEAVE (" ");
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void qof_object_book_end (QofBook *book)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
if (!book) return;
|
|
|
|
ENTER (" ");
|
|
|
|
for (l = object_modules; l; l = l->next)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
QofObject *obj = static_cast<QofObject*>(l->data);
|
2009-09-18 14:40:57 -05:00
|
|
|
if (obj->book_end)
|
|
|
|
obj->book_end (book);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove it from the list */
|
|
|
|
book_list = g_list_remove (book_list, book);
|
|
|
|
LEAVE (" ");
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
gboolean
|
2006-08-17 23:48:18 -05:00
|
|
|
qof_object_is_dirty (const QofBook *book)
|
2005-11-07 09:45:58 -06:00
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *l;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!book) return FALSE;
|
|
|
|
for (l = object_modules; l; l = l->next)
|
2005-11-07 09:45:58 -06:00
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
QofObject *obj = static_cast<QofObject*>(l->data);
|
2009-09-18 14:40:57 -05:00
|
|
|
if (obj->is_dirty)
|
|
|
|
{
|
|
|
|
QofCollection *col;
|
|
|
|
col = qof_book_get_collection (book, obj->e_type);
|
|
|
|
if (obj->is_dirty (col)) return TRUE;
|
|
|
|
}
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
2009-09-18 14:40:57 -05:00
|
|
|
return FALSE;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
void
|
2005-11-07 09:45:58 -06:00
|
|
|
qof_object_mark_clean (QofBook *book)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *l;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!book) return;
|
|
|
|
for (l = object_modules; l; l = l->next)
|
2005-11-07 09:45:58 -06:00
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
QofObject *obj = static_cast<QofObject*>(l->data);
|
2009-09-18 14:40:57 -05:00
|
|
|
if (obj->mark_clean)
|
|
|
|
{
|
|
|
|
QofCollection *col;
|
|
|
|
col = qof_book_get_collection (book, obj->e_type);
|
|
|
|
(obj->mark_clean) (col);
|
|
|
|
}
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *l;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!cb) return;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
for (l = object_modules; l; l = l->next)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
QofObject *obj = static_cast<QofObject*>(l->data);
|
2009-09-18 14:40:57 -05:00
|
|
|
(cb) (obj, user_data);
|
|
|
|
}
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
gboolean
|
2006-01-08 11:51:29 -06:00
|
|
|
qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
const QofObject *obj;
|
|
|
|
|
|
|
|
obj = qof_object_lookup(type_name);
|
|
|
|
if ((obj->create == NULL) || (obj->foreach == NULL))
|
|
|
|
{
|
|
|
|
if (warn)
|
|
|
|
{
|
|
|
|
PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-01-08 11:51:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
void
|
|
|
|
qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
|
2007-04-01 17:18:50 -05:00
|
|
|
QofInstanceForeachCB cb, gpointer user_data)
|
2005-11-07 09:45:58 -06:00
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
QofCollection *col;
|
|
|
|
const QofObject *obj;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!book || !type_name)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
PINFO ("type=%s", type_name);
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
obj = qof_object_lookup (type_name);
|
|
|
|
if (!obj)
|
|
|
|
{
|
|
|
|
PERR ("No object of type %s", type_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
col = qof_book_get_collection (book, obj->e_type);
|
|
|
|
if (!obj)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (obj->foreach)
|
|
|
|
{
|
|
|
|
obj->foreach (col, cb, user_data);
|
|
|
|
}
|
2005-11-07 09:45:58 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
static void
|
2012-03-11 16:55:53 -05:00
|
|
|
do_prepend (QofInstance *qof_p, gpointer list_p)
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
GList **list = static_cast<GList**>(list_p);
|
2012-03-11 16:55:53 -05:00
|
|
|
*list = g_list_prepend(*list, qof_p);
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
|
|
|
|
{
|
|
|
|
GList *list = NULL;
|
|
|
|
GList *iter;
|
|
|
|
|
2012-03-11 16:55:53 -05:00
|
|
|
qof_object_foreach(type_name, book, do_prepend, &list);
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
|
|
|
|
list = g_list_sort(list, qof_instance_guid_compare);
|
|
|
|
|
|
|
|
for (iter = list; iter; iter = iter->next)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
cb(static_cast<QofInstance*>(iter->data), user_data);
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(list);
|
2012-03-11 16:55:53 -05:00
|
|
|
|
|
|
|
// FIXME: Apparently this is a memory leak, as this g_list_free doesn't
|
|
|
|
// free all of the allocated memory of g_list_append in do_append(). Why?!?
|
|
|
|
// Does g_list_sort have special side-effects on the memory of the list?
|
|
|
|
// Subsequently, I've changed the g_list_append into g_list_prepend, but
|
|
|
|
// solely for performance reasons. To my surprise, this also makes the
|
|
|
|
// dubious memory leak go away. But again why?!?
|
Bug #638225: Sort when saving as XML
Patch by Jim Radford (with code beautified and re-indented by myself):
The attached patches sort the slots, lots, book accounts, bill terms,
customers, employees, entries, invoices, jobs, orders, tax tables and
vendors before saving them to the GnuCash XML file.
This is an attempt to make saves more idempotent thereby facilitating
the use of a revision control system on the GnuCash XML files.
With these patches most of the needless and seemingly random churn is
gone and I can add or remove a transaction and expect
there to be no unrelated changes to the GnuCash file.
I've been using and refining this patches for the last few years, so it has
received quite a bit of testing.
David Fraser adds: Without specific testing, I'm using this on an average-sized gnucash file
(5.7MB) without noticing any particular slowdown in saving, but a wonderful
reduction in diffs when comparing changes.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20067 57a11ea4-9604-0410-9ed3-97b8803252fd
2011-01-11 14:40:19 -06:00
|
|
|
}
|
|
|
|
|
2005-11-07 09:45:58 -06:00
|
|
|
const char *
|
|
|
|
qof_object_printable (QofIdTypeConst type_name, gpointer obj)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
const QofObject *b_obj;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!type_name || !obj) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
b_obj = qof_object_lookup (type_name);
|
|
|
|
if (!b_obj) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (b_obj->printable)
|
|
|
|
return (b_obj->printable (obj));
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * qof_object_get_type_label (QofIdTypeConst type_name)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
const QofObject *obj;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!type_name) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
obj = qof_object_lookup (type_name);
|
|
|
|
if (!obj) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
return (obj->type_label);
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
g_hash_table_destroy (static_cast<GHashTable*>(value));
|
2009-09-18 14:40:57 -05:00
|
|
|
return TRUE;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* INITIALIZATION and PRIVATE FUNCTIONS */
|
|
|
|
|
|
|
|
void qof_object_initialize (void)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
if (object_is_initialized) return;
|
|
|
|
object_is_initialized = TRUE;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void qof_object_shutdown (void)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
g_return_if_fail (object_is_initialized == TRUE);
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
g_list_free (object_modules);
|
|
|
|
object_modules = NULL;
|
|
|
|
g_list_free (book_list);
|
|
|
|
book_list = NULL;
|
|
|
|
object_is_initialized = FALSE;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Register new types of object objects.
|
|
|
|
* Return TRUE if successful,
|
|
|
|
* return FALSE if it fails, invalid arguments, or if the object
|
|
|
|
* already exists
|
|
|
|
*/
|
|
|
|
gboolean qof_object_register (const QofObject *object)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
g_return_val_if_fail (object_is_initialized, FALSE);
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!object) return FALSE;
|
|
|
|
g_return_val_if_fail (object->interface_version == QOF_OBJECT_VERSION, FALSE);
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (g_list_index (object_modules, (gpointer)object) == -1)
|
|
|
|
object_modules = g_list_prepend (object_modules, (gpointer)object);
|
|
|
|
else
|
|
|
|
return FALSE;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
/* Now initialize all the known books */
|
|
|
|
if (object->book_begin && book_list)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
for (node = book_list; node; node = node->next)
|
2014-04-25 15:41:11 -05:00
|
|
|
object->book_begin (static_cast<QofBook*>(node->data));
|
2009-09-18 14:40:57 -05:00
|
|
|
}
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
return TRUE;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
const QofObject * qof_object_lookup (QofIdTypeConst name)
|
|
|
|
{
|
2009-09-18 14:40:57 -05:00
|
|
|
GList *iter;
|
|
|
|
const QofObject *obj;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
g_return_val_if_fail (object_is_initialized, NULL);
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
if (!name) return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
|
2009-09-18 14:40:57 -05:00
|
|
|
for (iter = object_modules; iter; iter = iter->next)
|
|
|
|
{
|
2014-04-25 15:41:11 -05:00
|
|
|
obj = static_cast<QofObject*>(iter->data);
|
2012-08-07 12:24:55 -05:00
|
|
|
if (!g_strcmp0 (obj->e_type, name))
|
2009-09-18 14:40:57 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
return NULL;
|
2005-11-07 09:45:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================= END OF FILE =================== */
|