2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************
|
|
|
|
* gnc-engine.c -- top-level initialization for Gnucash Engine *
|
|
|
|
* Copyright 2000 Bill Gribble <grib@billgribble.com> *
|
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* *
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include "GNCIdP.h"
|
2002-02-03 14:01:08 -06:00
|
|
|
#include "QueryNewP.h"
|
|
|
|
#include "gncObjectP.h"
|
2001-08-07 18:36:04 -05:00
|
|
|
#include "gnc-engine.h"
|
2003-06-09 12:53:41 -05:00
|
|
|
#include "gnc-engine-util.h"
|
2001-08-07 18:36:04 -05: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
2002-05-24 21:50:24 -05:00
|
|
|
#include "AccountP.h"
|
2003-06-10 15:22:01 -05:00
|
|
|
#include "GroupP.h"
|
|
|
|
#include "TransactionP.h"
|
* 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
2002-05-24 21:50:24 -05:00
|
|
|
#include "gnc-book-p.h"
|
2002-06-27 23:20:46 -05:00
|
|
|
#include "gnc-lot-p.h"
|
* 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
2002-05-24 21:50:24 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
static GList * engine_init_hooks = NULL;
|
|
|
|
static int engine_is_initialized = 0;
|
2001-09-07 06:12:04 -05:00
|
|
|
|
|
|
|
/* GnuCash version functions */
|
|
|
|
unsigned int
|
|
|
|
gnucash_major_version (void)
|
|
|
|
{
|
|
|
|
return GNUCASH_MAJOR_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
gnucash_minor_version (void)
|
|
|
|
{
|
|
|
|
return GNUCASH_MINOR_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
gnucash_micro_version (void)
|
|
|
|
{
|
|
|
|
return GNUCASH_MICRO_VERSION;
|
|
|
|
}
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************
|
|
|
|
* gnc_engine_init
|
|
|
|
* initialize backend, load any necessary databases, etc.
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
void
|
2001-08-31 14:47:17 -05:00
|
|
|
gnc_engine_init(int argc, char ** argv)
|
|
|
|
{
|
2001-08-07 18:36:04 -05:00
|
|
|
gnc_engine_init_hook_t hook;
|
|
|
|
GList * cur;
|
|
|
|
|
|
|
|
if (1 == engine_is_initialized) return;
|
|
|
|
engine_is_initialized = 1;
|
|
|
|
|
|
|
|
/* initialize the string cache */
|
|
|
|
gnc_engine_get_string_cache();
|
|
|
|
|
|
|
|
xaccGUIDInit ();
|
2002-02-03 14:01:08 -06:00
|
|
|
gncObjectInitialize ();
|
|
|
|
gncQueryNewInit ();
|
2001-08-07 18:36:04 -05: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
2002-05-24 21:50:24 -05:00
|
|
|
/* Now register our core types */
|
|
|
|
xaccSplitRegister ();
|
|
|
|
xaccTransRegister ();
|
|
|
|
xaccAccountRegister ();
|
2003-06-10 15:22:01 -05:00
|
|
|
xaccGroupRegister ();
|
* 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
2002-05-24 21:50:24 -05:00
|
|
|
gnc_book_register ();
|
2002-06-27 23:20:46 -05:00
|
|
|
gnc_lot_register ();
|
* 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
2002-05-24 21:50:24 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
/* call any engine hooks */
|
2001-10-03 05:07:45 -05:00
|
|
|
for (cur = engine_init_hooks; cur; cur = cur->next)
|
|
|
|
{
|
2001-08-07 18:36:04 -05:00
|
|
|
hook = (gnc_engine_init_hook_t)cur->data;
|
2001-10-03 05:07:45 -05:00
|
|
|
|
|
|
|
if (hook)
|
2001-08-07 18:36:04 -05:00
|
|
|
(*hook)(argc, argv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* gnc_engine_shutdown
|
|
|
|
* shutdown backend, destroy any global data, etc.
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gnc_engine_shutdown (void)
|
|
|
|
{
|
2002-02-03 14:01:08 -06:00
|
|
|
gncQueryNewShutdown ();
|
|
|
|
|
2003-06-09 12:53:41 -05:00
|
|
|
gnc_engine_string_cache_destroy ();
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2002-02-03 14:01:08 -06:00
|
|
|
gncObjectShutdown ();
|
2001-08-07 18:36:04 -05:00
|
|
|
xaccGUIDShutdown ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* gnc_engine_add_init_hook
|
|
|
|
* add a startup hook
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gnc_engine_add_init_hook(gnc_engine_init_hook_t h) {
|
|
|
|
engine_init_hooks = g_list_append(engine_init_hooks, (gpointer)h);
|
|
|
|
}
|