From 9b9fef58ceab7f5d07b105e5d40be578e7e96761 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Tue, 10 Jun 2003 03:33:06 +0000 Subject: [PATCH] remove the commodities from the commodity table git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8524 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/gnc-book.c | 27 +++------------------------ src/engine/gnc-book.h | 3 --- src/engine/gnc-commodity.c | 23 ++++++++++++++++++++++- src/engine/gnc-commodity.h | 20 +++++++++++++++++++- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/src/engine/gnc-book.c b/src/engine/gnc-book.c index 8ccb37de6a..b3cfc4416c 100644 --- a/src/engine/gnc-book.c +++ b/src/engine/gnc-book.c @@ -66,24 +66,6 @@ static short module = MOD_ENGINE; /* ====================================================================== */ -#define GNC_COMMODITY_TABLE "gnc_commodity_table" -gnc_commodity_table * -gnc_book_get_commodity_table(GNCBook *book) -{ - if (!book) return NULL; -printf ("duude get commodity table\n"); - return gnc_book_get_data (book, GNC_COMMODITY_TABLE); -} - -static void -gnc_book_set_commodity_table(GNCBook *book, gnc_commodity_table *ct) -{ - if (!book) return; - gnc_book_set_data (book, GNC_COMMODITY_TABLE, ct); -} - -/* ====================================================================== */ - #define GNC_TOP_GROUP "gnc_top_group" AccountGroup * gnc_book_get_group (GNCBook *book) @@ -229,7 +211,7 @@ gnc_book_populate (GNCBook *book) { PWARN("unable to initialize book's commodity_table"); } - gnc_book_set_commodity_table (book, ct); + gnc_commodity_table_set_table (book, ct); gnc_book_set_group (book, xaccMallocAccountGroup(book)); @@ -246,7 +228,6 @@ gnc_book_depopulate (GNCBook *book) { AccountGroup *grp; gnc_commodity_table *ct; - GNCPriceDB *db; /* unhook the top-level group */ grp = gnc_book_get_group (book); @@ -255,13 +236,11 @@ gnc_book_depopulate (GNCBook *book) gnc_book_set_group (book, NULL); /* unhook the prices */ - db = gnc_book_get_pricedb (book); - gnc_pricedb_destroy (db); gnc_pricedb_set_db (book, NULL); - ct = gnc_book_get_commodity_table (book); + ct = gnc_commodity_table_get_table (book); gnc_commodity_table_destroy (ct); - gnc_book_set_commodity_table (book, NULL); + gnc_commodity_table_set_table (book, NULL); /* FIXME: destroy SX data members here, too */ } diff --git a/src/engine/gnc-book.h b/src/engine/gnc-book.h index 313cb56f7a..7b610292d0 100644 --- a/src/engine/gnc-book.h +++ b/src/engine/gnc-book.h @@ -58,9 +58,6 @@ kvp_frame * gnc_book_get_slots (GNCBook *book); /** \return The top-level group in the book.*/ AccountGroup * gnc_book_get_group (GNCBook *book); -/** \return The commodity table of the book. */ -gnc_commodity_table * gnc_book_get_commodity_table(GNCBook *book); - /** \return A GList of the scheduled transactions in the book. */ GList * gnc_book_get_schedxactions( GNCBook *book ); diff --git a/src/engine/gnc-commodity.c b/src/engine/gnc-commodity.c index f7794e228a..cdd153602b 100644 --- a/src/engine/gnc-commodity.c +++ b/src/engine/gnc-commodity.c @@ -1,7 +1,7 @@ /******************************************************************** * gnc-commodity.c -- api for tradable commodities (incl. currency) * * Copyright (C) 2000 Bill Gribble * - * Copyright (C) 2001 Linas Vepstas * + * Copyright (C) 2001 Linas Vepstas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -31,6 +31,7 @@ #include #include +#include "gnc-book.h" #include "gnc-commodity.h" #include "gnc-engine-util.h" #include "guid.h" @@ -510,6 +511,26 @@ gnc_commodity_table_new(void) return retval; } +/******************************************************************** + * book anchor functons + ********************************************************************/ + +#define GNC_COMMODITY_TABLE "gnc_commodity_table" +gnc_commodity_table * +gnc_commodity_table_get_table(GNCBook *book) +{ + if (!book) return NULL; +printf ("duude get commodity table\n"); + return gnc_book_get_data (book, GNC_COMMODITY_TABLE); +} + +void +gnc_commodity_table_set_table(GNCBook *book, gnc_commodity_table *ct) +{ + if (!book) return; + gnc_book_set_data (book, GNC_COMMODITY_TABLE, ct); +} + /******************************************************************** * gnc_commodity_get_size * get the size of the commodity table diff --git a/src/engine/gnc-commodity.h b/src/engine/gnc-commodity.h index 41779e39f3..609e055bc3 100644 --- a/src/engine/gnc-commodity.h +++ b/src/engine/gnc-commodity.h @@ -1,6 +1,5 @@ /******************************************************************** * gnc-commodity.h -- API for tradable commodities (incl. currency) * - * Copyright (C) 2000 Bill Gribble * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -41,6 +40,7 @@ #define GNC_COMMODITY_H #include +#include "gnc-book.h" #include "gnc-engine.h" /** The commodity namespace definitions are used to tag a commodity by @@ -408,17 +408,35 @@ gboolean gnc_commodity_is_iso(const gnc_commodity * cm); /** @} */ +/* =============================================================== */ /** @name Commodity Table Creation */ /** @{ */ /* gnc_commodity_table functions : operate on a database of commodity * info */ +/** You proably shouldn't be using gnc_commodity_table_new() directly, + * its for internal use only. You should probably be using + * gnc_commodity_table_get_table() + */ gnc_commodity_table * gnc_commodity_table_new(void); void gnc_commodity_table_destroy(gnc_commodity_table * table); + +/** Returns the commodity table assoicated with a book. + */ +gnc_commodity_table * gnc_commodity_table_get_table(GNCBook *book); + +/** You should probably not be using gnc_commodity_table_set_table() + * directly. Its for internal use only. + */ +void gnc_commodity_table_set_table(GNCBook *book, gnc_commodity_table *ct); + /** @} */ +/* XXX backwards compat function; remove me someday */ +#define gnc_book_get_commodity_table gnc_commodity_table_get_table + /** @name Commodity Table Comparison */ /** @{ */