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 * qof_collection_lookup_entity (QofCollection *, const GUID *);
00183
00185 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
00186
00188 void qof_collection_foreach (QofCollection *, QofEntityForeachCB,
00189 gpointer user_data);
00190
00197 gpointer qof_collection_get_data (QofCollection *col);
00198 void qof_collection_set_data (QofCollection *col, gpointer user_data);
00199
00201 gboolean qof_collection_is_dirty (QofCollection *col);
00202
00223 gboolean
00224 qof_collection_add_entity (QofCollection *coll, QofEntity *ent);
00225
00236 gboolean
00237 qof_collection_merge (QofCollection *target, QofCollection *merge);
00238
00250 gint
00251 qof_collection_compare (QofCollection *target, QofCollection *merge);
00252
00263 QofCollection*
00264 qof_collection_from_glist (QofIdType type, GList *glist);
00265
00269 #endif
00270