2001-08-07 18:36:04 -05:00
|
|
|
/********************************************************************
|
|
|
|
* gnc-pricedb-p.h -- a simple price database for gnucash. *
|
|
|
|
* Copyright (C) 2001 Rob Browning *
|
2003-06-10 17:22:47 -05:00
|
|
|
* Copyright (C) 2003 Linas Vepstas <linas@linas.org> *
|
2001-08-07 18:36:04 -05:00
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* *
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
#ifndef GNC_PRICEDB_P_H
|
|
|
|
#define GNC_PRICEDB_P_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2001-11-25 02:31:26 -06:00
|
|
|
#include "GNCIdP.h"
|
2001-10-09 03:26:03 -05:00
|
|
|
#include "gnc-book.h"
|
2001-11-25 00:43:25 -06:00
|
|
|
#include "gnc-engine.h"
|
2001-08-07 18:36:04 -05:00
|
|
|
#include "gnc-pricedb.h"
|
|
|
|
|
2001-10-05 04:54:41 -05:00
|
|
|
struct gnc_price_s
|
|
|
|
{
|
2001-08-07 18:36:04 -05:00
|
|
|
/* 'public' data fields */
|
|
|
|
GUID guid; /* globally unique price id */
|
2002-01-01 21:18:46 -06:00
|
|
|
GNCBook *book; /* book to which this price belongs to */
|
2001-10-09 03:26:03 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
GNCPriceDB *db;
|
|
|
|
gnc_commodity *commodity;
|
|
|
|
gnc_commodity *currency;
|
2001-11-25 02:31:26 -06:00
|
|
|
Timespec tmspec;
|
2001-08-07 18:36:04 -05:00
|
|
|
char *source;
|
|
|
|
char *type;
|
|
|
|
gnc_numeric value;
|
|
|
|
gint32 version; /* version number, for syncing with backend */
|
|
|
|
guint32 version_check; /* data aging timestamp */
|
|
|
|
|
|
|
|
/* 'private' object management fields */
|
2001-11-25 03:05:23 -06:00
|
|
|
GNCEntityTable *entity_table; /* table in which price is stored */
|
2001-08-07 18:36:04 -05:00
|
|
|
guint32 refcount; /* garbage collection reference count */
|
|
|
|
gint32 editlevel; /* nesting level of begin/end edit calls */
|
|
|
|
gboolean not_saved; /* price edit saved flag */
|
|
|
|
gboolean do_free; /* price is going to be destroyed soon */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-05 04:54:41 -05:00
|
|
|
struct gnc_price_db_s
|
|
|
|
{
|
2001-08-07 18:36:04 -05:00
|
|
|
GHashTable *commodity_hash;
|
2001-11-25 00:43:25 -06:00
|
|
|
GNCBook *book; /* book to which this database and all the prices belong to */
|
2001-08-07 18:36:04 -05:00
|
|
|
gboolean dirty;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* These structs define the kind of price lookup being done
|
|
|
|
* so that it can be passed to the backend. This is a rather
|
|
|
|
* cheesy, low-brow interface. It could stand improvement.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
LOOKUP_LATEST = 1,
|
|
|
|
LOOKUP_ALL,
|
|
|
|
LOOKUP_AT_TIME,
|
|
|
|
LOOKUP_NEAREST_IN_TIME,
|
|
|
|
LOOKUP_LATEST_BEFORE,
|
|
|
|
LOOKUP_EARLIEST_AFTER
|
|
|
|
} PriceLookupType;
|
|
|
|
|
|
|
|
|
2001-10-05 04:54:41 -05:00
|
|
|
struct gnc_price_lookup_s
|
|
|
|
{
|
2001-08-07 18:36:04 -05:00
|
|
|
PriceLookupType type;
|
|
|
|
GNCPriceDB *prdb;
|
|
|
|
gnc_commodity *commodity;
|
|
|
|
gnc_commodity *currency;
|
|
|
|
Timespec date;
|
|
|
|
};
|
|
|
|
|
2003-04-12 11:53:22 -05:00
|
|
|
|
|
|
|
typedef struct gnc_price_lookup_helper_s
|
|
|
|
{
|
|
|
|
GList **return_list;
|
|
|
|
Timespec time;
|
|
|
|
} GNCPriceLookupHelper;
|
|
|
|
|
2003-06-09 22:02:59 -05:00
|
|
|
void gnc_pricedb_set_db(GNCBook *book, GNCPriceDB *db);
|
2003-04-12 11:53:22 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
void gnc_pricedb_mark_clean(GNCPriceDB *db);
|
|
|
|
void gnc_pricedb_substitute_commodity(GNCPriceDB *db,
|
|
|
|
gnc_commodity *old_c,
|
|
|
|
gnc_commodity *new_c);
|
|
|
|
void gnc_price_set_guid (GNCPrice *p, const GUID *guid);
|
|
|
|
|
2003-06-10 17:22:47 -05:00
|
|
|
/** register the pricedb object with the gncObject system */
|
|
|
|
gboolean gnc_pricedb_register (void);
|
2003-06-09 22:02:59 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#endif
|