QOF  0.8.7
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 
148 {
149  QofIdType e_type;
150  GUID guid;
151  QofCollection *collection;
152 };
153 
158 
166 
172 
174 guint qof_collection_count (QofCollection * col);
175 
178 
181 
183 QofEntity *
185 
187 typedef void (*QofEntityForeachCB) (QofEntity *, gpointer user_data);
188 
190 void
192  gpointer user_data);
193 
200 gpointer
202 
204 void
205 qof_collection_set_data (QofCollection * col, gpointer user_data);
206 
208 gboolean
210 
231 gboolean
233 
244 gboolean
246 
258 gint
260 
272 qof_collection_from_glist (QofIdType type, GList * glist);
273 
277 #endif /* QOF_ID_H */
278 
gboolean qof_collection_add_entity(QofCollection *coll, QofEntity *ent)
Add an entity to a QOF_TYPE_COLLECT.
Definition: qofid.c:182
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
Definition: qofid.c:264
const gchar * QofIdType
Definition: qofid.h:81
gboolean qof_collection_is_dirty(QofCollection *col)
Definition: qofid.c:333
void(* QofEntityForeachCB)(QofEntity *, gpointer user_data)
Definition: qofid.h:187
globally unique ID User API
struct QofCollection_s QofCollection
Definition: qofid.h:138
QofCollection * qof_collection_from_glist(QofIdType type, GList *glist)
Create a secondary collection from a GList.
Definition: qofid.c:303
guint qof_collection_count(QofCollection *col)
Definition: qofid.c:322
QofEntity * qof_collection_lookup_entity(QofCollection *, const GUID *)
Definition: qofid.c:292
void qof_collection_foreach(QofCollection *, QofEntityForeachCB, gpointer user_data)
Definition: qofid.c:392
void qof_collection_set_data(QofCollection *col, gpointer user_data)
Definition: qofid.c:365
void qof_entity_release(QofEntity *)
Definition: qofid.c:79
QofIdType qof_collection_get_type(QofCollection *)
Definition: qofid.c:146
Definition: guid.h:53
gpointer qof_collection_get_data(QofCollection *col)
Definition: qofid.c:359
const gchar * QofIdTypeConst
Definition: qofid.h:83
void qof_collection_destroy(QofCollection *col)
Definition: qofid.c:132
const GUID * qof_entity_get_guid(QofEntity *)
Definition: qofid.c:105
QofCollection * qof_collection_new(QofIdType type)
Definition: qofid.c:121
gboolean qof_collection_merge(QofCollection *target, QofCollection *merge)
Merge two QOF_TYPE_COLLECT of the same type.
Definition: qofid.c:216
void qof_entity_init(QofEntity *, QofIdType, QofCollection *)
Definition: qofid.c:49
const gchar * QofLogModule
Definition: qofid.h:85