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 #define QOF_ID_NONE NULL
00087 #define QOF_ID_NULL "null"
00088
00089 #define QOF_ID_BOOK "Book"
00090 #define QOF_ID_SESSION "Session"
00091
00093 #define QOF_ENTITY(object) ((QofEntity *)(object))
00094
00096 #define QSTRCMP(da,db) ({ \
00097 gint val = 0; \
00098 if ((da) && (db)) { \
00099 if ((da) != (db)) { \
00100 val = strcmp ((da), (db)); \
00101 } \
00102 } else \
00103 if ((!(da)) && (db)) { \
00104 val = -1; \
00105 } else \
00106 if ((da) && (!(db))) { \
00107 val = 1; \
00108 } \
00109 val; \
00110 })
00111
00113 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
00114 (0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
00115
00118 #define QOF_CHECK_CAST(obj,e_type,c_type) ( \
00119 QOF_CHECK_TYPE((obj),(e_type)) ? \
00120 (c_type *) (obj) : \
00121 (c_type *) ({ \
00122 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
00123 "Error: Bad QofEntity at %s:%d", __FILE__, __LINE__); \
00124 (obj); \
00125 }))
00126
00128 typedef struct QofEntity_s QofEntity;
00137 typedef struct QofCollection_s QofCollection;
00138
00146 struct QofEntity_s
00147 {
00148 QofIdType e_type;
00149 GUID guid;
00150 QofCollection *collection;
00151 };
00152
00156 void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
00157
00160 void qof_entity_release (QofEntity *);
00164 const GUID *qof_entity_get_guid (QofEntity *);
00165
00170 QofCollection *qof_collection_new (QofIdType type);
00171
00173 guint qof_collection_count (QofCollection * col);
00174
00176 void qof_collection_destroy (QofCollection * col);
00177
00179 QofIdType qof_collection_get_type (QofCollection *);
00180
00182 QofEntity *
00183 qof_collection_lookup_entity (QofCollection *, const GUID *);
00184
00186 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
00187
00189 void
00190 qof_collection_foreach (QofCollection *, QofEntityForeachCB,
00191 gpointer user_data);
00192
00199 gpointer
00200 qof_collection_get_data (QofCollection * col);
00201
00203 void
00204 qof_collection_set_data (QofCollection * col, gpointer user_data);
00205
00207 gboolean
00208 qof_collection_is_dirty (QofCollection * col);
00209
00230 gboolean
00231 qof_collection_add_entity (QofCollection * coll, QofEntity * ent);
00232
00243 gboolean
00244 qof_collection_merge (QofCollection * target, QofCollection * merge);
00245
00257 gint
00258 qof_collection_compare (QofCollection * target, QofCollection * merge);
00259
00270 QofCollection *
00271 qof_collection_from_glist (QofIdType type, GList * glist);
00272
00276 #endif
00277