GnuCash  4.8a-80-g9825132ea+
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 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
81 #include <string.h>
82 #include "guid.h"
83 
85 typedef const gchar * QofIdType;
87 typedef const gchar * QofIdTypeConst;
88 
89 typedef struct QofCollection_s QofCollection;
90 
91 #include "qofinstance.h"
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 (const QofCollection *, QofInstanceForeachCB,
150  gpointer user_data);
151 
158 gpointer qof_collection_get_data (const QofCollection *col);
159 void qof_collection_set_data (QofCollection *col, gpointer user_data);
160 
162 gboolean qof_collection_is_dirty (const QofCollection *col);
163 
184 gboolean
185 qof_collection_add_entity (QofCollection *coll, QofInstance *ent);
186 
187 void qof_collection_remove_entity (QofInstance *ent);
188 
200 gint
201 qof_collection_compare (QofCollection *target, QofCollection *merge);
202 
213 QofCollection*
214 qof_collection_from_glist (QofIdType type, const GList *glist);
215 
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 #endif /* QOF_ID_H */
224 
gboolean qof_collection_is_dirty(const QofCollection *col)
Return value of &#39;dirty&#39; flag on collection.
Definition: qofid.cpp:257
QofInstance * qof_collection_lookup_entity(const QofCollection *, const GncGUID *)
Find the entity going only from its guid.
Definition: qofid.cpp:215
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:87
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(const QofCollection *, QofInstanceForeachCB, gpointer user_data)
Call the callback for each entity in the collection.
Definition: qofid.cpp:323
gint qof_collection_compare(QofCollection *target, QofCollection *merge)
Compare two secondary collections.
Definition: qofid.cpp:177
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:85
QofCollection * qof_collection_from_glist(QofIdType type, const GList *glist)
Create a secondary collection from a GList.
Definition: qofid.cpp:226
void qof_collection_destroy(QofCollection *col)
destroy the collection
Definition: qofid.cpp:62
QofIdType qof_collection_get_type(const QofCollection *)
return the type that the collection stores
Definition: qofid.cpp:76
gboolean qof_collection_add_entity(QofCollection *coll, QofInstance *ent)
Add an entity to a QOF_TYPE_COLLECT.
Definition: qofid.cpp:112
guint qof_collection_count(const QofCollection *col)
return the number of entities in the collection.
Definition: qofid.cpp:246
gpointer qof_collection_get_data(const QofCollection *col)
Store and retrieve arbitrary object-defined data.
Definition: qofid.cpp:291
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:51