GnuCash 2.4.99
gnc-pricedb-p.h
00001 /********************************************************************
00002  * gnc-pricedb-p.h -- a simple price database for gnucash.          *
00003  * Copyright (C) 2001 Rob Browning                                  *
00004  * Copyright (C) 2003 Linas Vepstas <linas@linas.org>               *
00005  *                                                                  *
00006  * This program is free software; you can redistribute it and/or    *
00007  * modify it under the terms of the GNU General Public License as   *
00008  * published by the Free Software Foundation; either version 2 of   *
00009  * the License, or (at your option) any later version.              *
00010  *                                                                  *
00011  * This program is distributed in the hope that it will be useful,  *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00014  * GNU General Public License for more details.                     *
00015  *                                                                  *
00016  * You should have received a copy of the GNU General Public License*
00017  * along with this program; if not, contact:                        *
00018  *                                                                  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942       *
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00022  *                                                                  *
00023  *******************************************************************/
00024 
00025 #ifndef GNC_PRICEDB_P_H
00026 #define GNC_PRICEDB_P_H
00027 
00028 #include <glib.h>
00029 #include "qof.h"
00030 #include "gnc-engine.h"
00031 #include "gnc-pricedb.h"
00032 
00033 struct gnc_price_s
00034 {
00035     /* 'public' data fields */
00036     QofInstance inst;              /* globally unique object identifier */
00037 
00038     GNCPriceDB *db;
00039     gnc_commodity *commodity;
00040     gnc_commodity *currency;
00041     Timespec tmspec;
00042     char *source;
00043     char *type;
00044     gnc_numeric value;
00045 
00046     /* 'private' object management fields */
00047     guint32  refcount;             /* garbage collection reference count */
00048 };
00049 
00050 struct _GncPriceClass
00051 {
00052     QofInstanceClass parent_class;
00053 };
00054 
00055 struct gnc_price_db_s
00056 {
00057     QofInstance inst;              /* globally unique object identifier */
00058     GHashTable *commodity_hash;
00059     gboolean bulk_update;                /* TRUE while reading XML file, etc. */
00060 };
00061 
00062 struct _GncPriceDBClass
00063 {
00064     QofInstanceClass parent_class;
00065 };
00066 
00067 /* These structs define the kind of price lookup being done
00068  * so that it can be passed to the backend.  This is a rather
00069  * cheesy, low-brow interface.  It could stand improvement.
00070  */
00071 typedef enum
00072 {
00073     LOOKUP_LATEST = 1,
00074     LOOKUP_ALL,
00075     LOOKUP_AT_TIME,
00076     LOOKUP_NEAREST_IN_TIME,
00077     LOOKUP_LATEST_BEFORE,
00078     LOOKUP_EARLIEST_AFTER
00079 } PriceLookupType;
00080 
00081 
00082 struct gnc_price_lookup_s
00083 {
00084     PriceLookupType type;
00085     GNCPriceDB     *prdb;
00086     const gnc_commodity  *commodity;
00087     const gnc_commodity  *currency;
00088     Timespec        date;
00089 };
00090 
00091 
00092 typedef struct gnc_price_lookup_helper_s
00093 {
00094     GList    **return_list;
00095     Timespec time;
00096 } GNCPriceLookupHelper;
00097 
00098 #define  gnc_price_set_guid(P,G)  qof_instance_set_guid(QOF_INSTANCE(P),(G))
00099 void     gnc_pricedb_substitute_commodity(GNCPriceDB *db,
00100         gnc_commodity *old_c,
00101         gnc_commodity *new_c);
00102 
00104 gboolean gnc_pricedb_register (void);
00105 
00106 QofBackend * xaccPriceDBGetBackend (GNCPriceDB *prdb);
00107 
00108 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines