GnuCash  5.6-150-g038405b370+
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 
76 #include <string.h>
77 #include "guid.h"
78 
80 typedef const gchar * QofIdType;
82 typedef const gchar * QofIdTypeConst;
83 
84 typedef struct QofCollection_s QofCollection;
85 
86 #include "qofinstance.h"
87 
88 #ifdef __cplusplus
89 extern "C"
90 {
91 #endif
92 
93 #define QOF_ID_NONE NULL
94 #define QOF_ID_NULL "null"
95 
96 #define QOF_ID_BOOK "Book"
97 #define QOF_ID_SESSION "Session"
98 
99 #define QSTRCMP g_strcmp0
100 
102 #define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
103  (0 == QSTRCMP((type),(((QofInstance *)(obj))->e_type))))
104 
107 #define QOF_CHECK_CAST(obj,e_type,c_type) ( \
108  QOF_CHECK_TYPE((obj),(e_type)) ? \
109  (c_type *) (obj) : \
110  (c_type *) ({ \
111  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \
112  "Error: Bad QofInstance at %s:%d", __FILE__, __LINE__); \
113  (obj); \
114  }))
115 
116 
130 QofCollection * qof_collection_new (QofIdType type);
131 
133 guint qof_collection_count (const QofCollection *col);
134 
136 void qof_collection_destroy (QofCollection *col);
137 
139 QofIdType qof_collection_get_type (const QofCollection *);
140 
142 /*@ dependent @*/
143 QofInstance * qof_collection_lookup_entity (const QofCollection *, const GncGUID *);
144 
146 typedef void (*QofInstanceForeachCB) (QofInstance *, gpointer user_data);
147 
149 void qof_collection_foreach_sorted (const QofCollection *col, QofInstanceForeachCB cb_func,
150  gpointer user_data, GCompareFunc sort_fn);
151 
152 void qof_collection_foreach (const QofCollection *, QofInstanceForeachCB,
153  gpointer user_data);
154 
161 gpointer qof_collection_get_data (const QofCollection *col);
162 void qof_collection_set_data (QofCollection *col, gpointer user_data);
163 
165 gboolean qof_collection_is_dirty (const QofCollection *col);
166 
187 gboolean
188 qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
189 
190 void qof_collection_remove_entity (QofInstance *ent);
191 
203 gint
204 qof_collection_compare (QofCollection *target, QofCollection *merge);
205 
216 QofCollection*
217 qof_collection_from_glist (QofIdType type, const GList *glist);
218 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* QOF_ID_H */
227 
gboolean qof_collection_is_dirty(const QofCollection *col)
Return value of &#39;dirty&#39; flag on collection.
Definition: qofid.cpp:255
QofInstance * qof_collection_lookup_entity(const QofCollection *, const GncGUID *)
Find the entity going only from its guid.
Definition: qofid.cpp:212
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:82
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
Callback type for qof_collection_foreach.
Definition: qofid.h:146
globally unique ID User API
Object instance holds common fields that most gnucash objects use.
void qof_collection_foreach_sorted(const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data, GCompareFunc sort_fn)
Call the callback for each entity in the collection.
Definition: qofid.cpp:306
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
Definition: qofid.cpp:174
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:80
QofCollection * qof_collection_from_glist(QofIdType type, const GList *glist)
Create a secondary collection from a GList.
Definition: qofid.cpp:224
void qof_collection_destroy(QofCollection *col)
destroy the collection
Definition: qofid.cpp:59
QofIdType qof_collection_get_type(const QofCollection *)
return the type that the collection stores
Definition: qofid.cpp:73
gboolean qof_collection_add_entity(QofCollection *coll, QofInstance *ent)
Add an entity to a QOF_TYPE_COLLECT.
Definition: qofid.cpp:109
guint qof_collection_count(const QofCollection *col)
return the number of entities in the collection.
Definition: qofid.cpp:244
gpointer qof_collection_get_data(const QofCollection *col)
Store and retrieve arbitrary object-defined data.
Definition: qofid.cpp:289
The type used to store guids in C.
Definition: guid.h:75
QofCollection * qof_collection_new(QofIdType type)
create a new collection of entities of type
Definition: qofid.cpp:48