QOF: qofid.h Source File

QOF 0.7.5

qofid.h
Go to the documentation of this file.
1 /********************************************************************\
2 * qofid.h -- QOF entity type identification system *
3 * *
4 * This program is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation; either version 2 of *
7 * the License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License*
15 * along with this program; if not, contact: *
16 * *
17 * Free Software Foundation Voice: +1-617-542-5942 *
18 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19 * Boston, MA 02110-1301, USA gnu@gnu.org *
20 * *
21 \********************************************************************/
22
23 #ifndef QOF_ID_H
24 #define QOF_ID_H
25
77 #include <string.h>
78 #include "guid.h"
79
81 typedef const gchar *QofIdType;
83 typedef const gchar *QofIdTypeConst;
85 typedef const gchar *QofLogModule;
86
87 #define QOF_ID_NONE NULL
88 #define QOF_ID_NULL "null"
89
90 #define QOF_ID_BOOK "Book"
91 #define QOF_ID_SESSION "Session"
92
94 #define QOF_ENTITY(object) ((QofEntity *)(object))
95
97 #define QSTRCMP(da,db) ({ \
98 gint val = 0; \
99 if ((da) && (db)) { \
100 if ((da) != (db)) { \
101 val = strcmp ((da), (db)); \
102 } \
103 } else \
104 if ((!(da)) && (db)) { \
105 val = -1; \
106 } else \
107 if ((da) && (!(db))) { \
108 val = 1; \
109 } \
110 val; /* block assumes value of last statment */ \
111 })
112
114 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
115 (0 == QSTRCMP((type),(((QofEntity *)(obj))->e_type))))
116
119 #define QOF_CHECK_CAST(obj,e_type,c_type) ( \
120 QOF_CHECK_TYPE((obj),(e_type)) ? \
121 (c_type *) (obj) : \
122 (c_type *) ({ \
123 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
124 "Error: Bad QofEntity at %s:%d", __FILE__, __LINE__); \
125 (obj); \
126 }))
127
129 typedef struct QofEntity_s QofEntity;
138 typedef struct QofCollection_s QofCollection;
139
147 struct QofEntity_s
148 {
149 QofIdType e_type;
150 GUID guid;
151 QofCollection *collection;
152 };
153
157 void qof_entity_init (QofEntity *, QofIdType, QofCollection *);
158
161 void qof_entity_release (QofEntity *);
165 const GUID *qof_entity_get_guid (QofEntity *);
166
171 QofCollection *qof_collection_new (QofIdType type);
172
174 guint qof_collection_count (QofCollection * col);
175
177 void qof_collection_destroy (QofCollection * col);
178
180 QofIdType qof_collection_get_type (QofCollection *);
181
183 QofEntity *
184 qof_collection_lookup_entity (QofCollection *, const GUID *);
185
187 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
188
190 void
191 qof_collection_foreach (QofCollection *, QofEntityForeachCB,
192 gpointer user_data);
193
200 gpointer
201 qof_collection_get_data (QofCollection * col);
202
204 void
205 qof_collection_set_data (QofCollection * col, gpointer user_data);
206
208 gboolean
209 qof_collection_is_dirty (QofCollection * col);
210
231 gboolean
232 qof_collection_add_entity (QofCollection * coll, QofEntity * ent);
233
244 gboolean
245 qof_collection_merge (QofCollection * target, QofCollection * merge);
246
258 gint
259 qof_collection_compare (QofCollection * target, QofCollection * merge);
260
271 QofCollection *
272 qof_collection_from_glist (QofIdType type, GList * glist);
273
277 #endif /* QOF_ID_H */
278
qof_collection_add_entity
gboolean qof_collection_add_entity(QofCollection *coll, QofEntity *ent)
Add an entity to a QOF_TYPE_COLLECT.
Definition: qofid.c:211
qof_collection_compare
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
Definition: qofid.c:293
QofIdType
const gchar * QofIdType
Definition: qofid.h:81
qof_collection_is_dirty
gboolean qof_collection_is_dirty(QofCollection *col)
Definition: qofid.c:362
QofEntity_s
Definition: qofid.h:147
QofEntityForeachCB
void(* QofEntityForeachCB)(QofEntity *, gpointer user_data)
Definition: qofid.h:187
guid.h
globally unique ID User API
QofCollection
struct QofCollection_s QofCollection
Definition: qofid.h:138
qof_collection_from_glist
QofCollection * qof_collection_from_glist(QofIdType type, GList *glist)
Create a secondary collection from a GList.
Definition: qofid.c:332
qof_collection_count
guint qof_collection_count(QofCollection *col)
Definition: qofid.c:351
qof_collection_lookup_entity
QofEntity * qof_collection_lookup_entity(QofCollection *, const GUID *)
Definition: qofid.c:321
qof_collection_foreach
void qof_collection_foreach(QofCollection *, QofEntityForeachCB, gpointer user_data)
Definition: qofid.c:421
qof_collection_set_data
void qof_collection_set_data(QofCollection *col, gpointer user_data)
Definition: qofid.c:394
qof_entity_release
void qof_entity_release(QofEntity *)
Definition: qofid.c:79
qof_collection_get_type
QofIdType qof_collection_get_type(QofCollection *)
Definition: qofid.c:175
_GUID
Definition: guid.h:53
qof_collection_get_data
gpointer qof_collection_get_data(QofCollection *col)
Definition: qofid.c:388
QofIdTypeConst
const gchar * QofIdTypeConst
Definition: qofid.h:83
qof_collection_destroy
void qof_collection_destroy(QofCollection *col)
Definition: qofid.c:161
qof_entity_get_guid
const GUID * qof_entity_get_guid(QofEntity *)
Definition: qofid.c:105
qof_collection_new
QofCollection * qof_collection_new(QofIdType type)
Definition: qofid.c:150
qof_collection_merge
gboolean qof_collection_merge(QofCollection *target, QofCollection *merge)
Merge two QOF_TYPE_COLLECT of the same type.
Definition: qofid.c:245
qof_entity_init
void qof_entity_init(QofEntity *, QofIdType, QofCollection *)
Definition: qofid.c:49
QofLogModule
const gchar * QofLogModule
Definition: qofid.h:85