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 *
|
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 *
|
2001-08-07 18:36:04 -05:00
|
|
|
* *
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
#ifndef GNC_PRICEDB_P_H
|
|
|
|
#define GNC_PRICEDB_P_H
|
|
|
|
|
|
|
|
#include <glib.h>
|
2005-11-01 21:32:36 -06:00
|
|
|
#include "qof.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
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
/* 'public' data fields */
|
|
|
|
QofInstance inst; /* globally unique object identifier */
|
|
|
|
|
|
|
|
GNCPriceDB *db;
|
|
|
|
gnc_commodity *commodity;
|
|
|
|
gnc_commodity *currency;
|
2018-08-02 17:46:27 -05:00
|
|
|
time64 tmspec;
|
2015-09-03 18:22:14 -05:00
|
|
|
PriceSource source;
|
2010-02-17 23:31:54 -06:00
|
|
|
char *type;
|
|
|
|
gnc_numeric value;
|
|
|
|
|
|
|
|
/* 'private' object management fields */
|
|
|
|
guint32 refcount; /* garbage collection reference count */
|
2001-08-07 18:36:04 -05:00
|
|
|
};
|
|
|
|
|
2007-04-04 19:24:38 -05:00
|
|
|
struct _GncPriceClass
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
QofInstanceClass parent_class;
|
2007-04-04 19:24:38 -05:00
|
|
|
};
|
2001-08-07 18:36:04 -05:00
|
|
|
|
2001-10-05 04:54:41 -05:00
|
|
|
struct gnc_price_db_s
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
QofInstance inst; /* globally unique object identifier */
|
|
|
|
GHashTable *commodity_hash;
|
|
|
|
gboolean bulk_update; /* TRUE while reading XML file, etc. */
|
2001-08-07 18:36:04 -05:00
|
|
|
};
|
|
|
|
|
2007-04-04 19:24:38 -05:00
|
|
|
struct _GncPriceDBClass
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
QofInstanceClass parent_class;
|
2007-04-04 19:24:38 -05:00
|
|
|
};
|
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
/* 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.
|
|
|
|
*/
|
2010-02-17 23:31:54 -06:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LOOKUP_LATEST = 1,
|
|
|
|
LOOKUP_ALL,
|
|
|
|
LOOKUP_AT_TIME,
|
|
|
|
LOOKUP_NEAREST_IN_TIME,
|
|
|
|
LOOKUP_LATEST_BEFORE,
|
|
|
|
LOOKUP_EARLIEST_AFTER
|
2001-08-07 18:36:04 -05:00
|
|
|
} PriceLookupType;
|
|
|
|
|
2003-04-12 11:53:22 -05:00
|
|
|
typedef struct gnc_price_lookup_helper_s
|
|
|
|
{
|
2010-02-17 23:31:54 -06:00
|
|
|
GList **return_list;
|
2015-10-23 13:38:21 -05:00
|
|
|
gnc_commodity *key;
|
2018-08-02 17:46:27 -05:00
|
|
|
time64 time;
|
2003-04-12 11:53:22 -05:00
|
|
|
} GNCPriceLookupHelper;
|
|
|
|
|
2007-04-01 17:18:50 -05:00
|
|
|
#define gnc_price_set_guid(P,G) qof_instance_set_guid(QOF_INSTANCE(P),(G))
|
2001-08-07 18:36:04 -05:00
|
|
|
void gnc_pricedb_substitute_commodity(GNCPriceDB *db,
|
2010-02-17 23:31:54 -06:00
|
|
|
gnc_commodity *old_c,
|
|
|
|
gnc_commodity *new_c);
|
2001-08-07 18:36:04 -05:00
|
|
|
|
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
|
|
|
|
2003-06-26 21:51:10 -05:00
|
|
|
QofBackend * xaccPriceDBGetBackend (GNCPriceDB *prdb);
|
2003-06-10 19:43:28 -05:00
|
|
|
|
2001-08-07 18:36:04 -05:00
|
|
|
#endif
|