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
00077 #include <string.h>
00078 #include "guid.h"
00079
00081 typedef const gchar *QofIdType;
00083 typedef const gchar *QofIdTypeConst;
00085 typedef const gchar *QofLogModule;
00086
00087 #define QOF_ID_NONE NULL
00088 #define QOF_ID_NULL "null"
00089
00090 #define QOF_ID_BOOK "Book"
00091 #define QOF_ID_SESSION "Session"
00092
00094 #define QOF_ENTITY(object) ((QofEntity *)(object))
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),(((QofEntity *)(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 QofEntity at %s:%d", __FILE__, __LINE__); \
00125 (obj); \
00126 }))
00127
00129 typedef struct QofEntity_s QofEntity;
00138 typedef struct QofCollection_s QofCollection;
00139
00147 struct QofEntity_s
00148 {
00149 QofIdType e_type;
00150 GUID guid;
00151 QofCollection *collection;
00152 };
00153
00157 void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
00158
00161 void qof_entity_release (QofEntity *);
00165 const GUID *qof_entity_get_guid (QofEntity *);
00166
00171 QofCollection *qof_collection_new (QofIdType type);
00172
00174 guint qof_collection_count (QofCollection * col);
00175
00177 void qof_collection_destroy (QofCollection * col);
00178
00180 QofIdType qof_collection_get_type (QofCollection *);
00181
00183 QofEntity *
00184 qof_collection_lookup_entity (QofCollection *, const GUID *);
00185
00187 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
00188
00190 void
00191 qof_collection_foreach (QofCollection *, QofEntityForeachCB,
00192 gpointer user_data);
00193
00200 gpointer
00201 qof_collection_get_data (QofCollection * col);
00202
00204 void
00205 qof_collection_set_data (QofCollection * col, gpointer user_data);
00206
00208 gboolean
00209 qof_collection_is_dirty (QofCollection * col);
00210
00231 gboolean
00232 qof_collection_add_entity (QofCollection * coll, QofEntity * ent);
00233
00244 gboolean
00245 qof_collection_merge (QofCollection * target, QofCollection * merge);
00246
00258 gint
00259 qof_collection_compare (QofCollection * target, QofCollection * merge);
00260
00271 QofCollection *
00272 qof_collection_from_glist (QofIdType type, GList * glist);
00273
00277 #endif
00278