00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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 #define QSTRCMP(da,db) ({ \
00098 gint val = 0; \
00099 if ((da) && (db)) { \
00100 if ((da) != (db)) { \
00101 val = strcmp ((da), (db)); \
00102 } \
00103 } else \
00104 if ((!(da)) && (db)) { \
00105 val = -1; \
00106 } else \
00107 if ((da) && (!(db))) { \
00108 val = 1; \
00109 } \
00110 val; \
00111 })
00112
00114 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
00115 (0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
00116
00119 #define QOF_CHECK_CAST(obj,e_type,c_type) ( \
00120 QOF_CHECK_TYPE((obj),(e_type)) ? \
00121 (c_type *) (obj) : \
00122 (c_type *) ({ \
00123 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
00124 "Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
00125 (obj); \
00126 }))
00127
00128
00145 gboolean qof_get_alt_dirty_mode (void);
00146
00153 void qof_set_alt_dirty_mode (gboolean enabled);
00154
00159 QofCollection * qof_collection_new (QofIdType type);
00160
00162 guint qof_collection_count (const QofCollection *col);
00163
00165 void qof_collection_destroy (QofCollection *col);
00166
00168 QofIdType qof_collection_get_type (const QofCollection *);
00169
00171 QofInstance * qof_collection_lookup_entity (const QofCollection *, const GUID *);
00172
00174 typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
00175
00177 void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
00178 gpointer user_data);
00179
00186 gpointer qof_collection_get_data (const QofCollection *col);
00187 void qof_collection_set_data (QofCollection *col, gpointer user_data);
00188
00190 gboolean qof_collection_is_dirty (const QofCollection *col);
00191
00212 gboolean
00213 qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
00214
00215 void qof_collection_remove_entity (QofInstance *ent);
00216
00227 gboolean
00228 qof_collection_merge (QofCollection *target, QofCollection *merge);
00229
00241 gint
00242 qof_collection_compare (QofCollection *target, QofCollection *merge);
00243
00254 QofCollection*
00255 qof_collection_from_glist (QofIdType type, const GList *glist);
00256
00260 #endif
00261