GnuCash 2.4.99
qofid.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * qofid.h -- QOF entity type identification system                 *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00022 
00023 #ifndef QOF_ID_H
00024 #define QOF_ID_H
00025 
00076 #include <string.h>
00077 #include "guid.h"
00078 
00080 typedef const gchar * QofIdType;
00082 typedef const gchar * QofIdTypeConst;
00084 typedef const gchar* QofLogModule;
00085 
00086 typedef struct QofCollection_s QofCollection;
00087 
00088 #include "qofinstance.h"
00089 
00090 #define QOF_ID_NONE           NULL
00091 #define QOF_ID_NULL           "null"
00092 
00093 #define QOF_ID_BOOK           "Book"
00094 #define QOF_ID_SESSION        "Session"
00095 
00097 #ifndef _MSC_VER
00098 # define QSTRCMP(da,db) ({                \
00099   gint val = 0;                          \
00100   if ((da) && (db)) {                    \
00101     if ((da) != (db)) {                  \
00102       val = strcmp ((da), (db));         \
00103     }                                    \
00104   } else                                 \
00105   if ((!(da)) && (db)) {                 \
00106     val = -1;                            \
00107   } else                                 \
00108   if ((da) && (!(db))) {                 \
00109     val = 1;                             \
00110   }                                      \
00111   val; /* block assumes value of last statement */  \
00112 })
00113 #else
00114 /* MSVC: Simply use g_strcmp */
00115 # define QSTRCMP g_strcmp0
00116 #endif
00117 
00119 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
00120   (0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
00121 
00124 #define QOF_CHECK_CAST(obj,e_type,c_type) (                   \
00125   QOF_CHECK_TYPE((obj),(e_type)) ?                            \
00126   (c_type *) (obj) :                                          \
00127   (c_type *) ({                                               \
00128      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,               \
00129        "Error: Bad QofInstance at %s:%d", __FILE__, __LINE__);  \
00130      (obj);                                                   \
00131   }))
00132 
00133 
00151 gboolean qof_get_alt_dirty_mode (void);
00152 
00159 void qof_set_alt_dirty_mode (gboolean enabled);
00160 
00165 QofCollection * qof_collection_new (QofIdType type);
00166 
00168 guint qof_collection_count (const QofCollection *col);
00169 
00171 void qof_collection_destroy (QofCollection *col);
00172 
00174 QofIdType qof_collection_get_type (const QofCollection *);
00175 
00177 /*@ dependent @*/
00178 QofInstance * qof_collection_lookup_entity (const QofCollection *, const GncGUID *);
00179 
00181 typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
00182 
00184 void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
00185                              gpointer user_data);
00186 
00193 gpointer qof_collection_get_data (const QofCollection *col);
00194 void qof_collection_set_data (QofCollection *col, gpointer user_data);
00195 
00197 gboolean qof_collection_is_dirty (const QofCollection *col);
00198 
00219 gboolean
00220 qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
00221 
00222 void qof_collection_remove_entity (QofInstance *ent);
00223 
00235 gint
00236 qof_collection_compare (QofCollection *target, QofCollection *merge);
00237 
00248 QofCollection*
00249 qof_collection_from_glist (QofIdType type, const GList *glist);
00250 
00254 #endif /* QOF_ID_H */
00255 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines