GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qofobject.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofobject.h -- the Core Object Registration/Lookup Interface *
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 [email protected] *
20  * *
21 \********************************************************************/
48 #ifndef QOF_OBJECT_H_
49 #define QOF_OBJECT_H_
50 
51 #include "qofbook.h"
52 #include "qofid.h"
53 #include "qofchoice.h"
54 
55 #ifdef __cplusplus
56 extern "C"
57 {
58 #endif
59 
64 #define QOF_OBJECT_VERSION 3
65 
66 #define QOF_MOD_OBJECT "qof.object"
67 
68 typedef struct _QofObject QofObject;
69 typedef void (*QofForeachCB) (gpointer obj, gpointer user_data);
70 typedef void (*QofForeachTypeCB) (QofObject *type, gpointer user_data);
71 typedef void (*QofForeachBackendTypeCB) (QofIdTypeConst type,
72  gpointer backend_data,
73  gpointer user_data);
74 
77 struct _QofObject
78 {
79  gint interface_version; /* of this object interface */
80  QofIdType e_type; /* the Object's QOF_ID */
81  const char * type_label; /* "Printable" type-label string */
82 
87  gpointer (*create)(QofBook *);
88 
92  void (*book_begin)(QofBook *);
93 
97  void (*book_end)(QofBook *);
98 
100  gboolean (*is_dirty)(const QofCollection *);
101 
103  void (*mark_clean)(QofCollection *);
104 
112  void (*foreach)(const QofCollection *, QofInstanceForeachCB, gpointer);
113 
116  const char * (*printable)(gpointer instance);
117 
126  int (*version_cmp)(gpointer instance_left, gpointer instance_right);
127 };
128 
129 /* -------------------------------------------------------------- */
130 
133 void qof_object_initialize (void);
134 void qof_object_shutdown (void);
138 gboolean qof_object_register (const QofObject *object);
139 
141 const QofObject * qof_object_lookup (QofIdTypeConst type_name);
142 
147 gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book);
148 
152 const char * qof_object_get_type_label (QofIdTypeConst type_name);
153 
155 const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance);
156 
160 void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
161 
167 void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
168  QofInstanceForeachCB cb, gpointer user_data);
169 
171 void qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book,
172  QofInstanceForeachCB cb, gpointer user_data);
173 
175 gboolean qof_object_register_backend (QofIdTypeConst type_name,
176  const char *backend_name,
177  gpointer be_data);
178 
179 /*@ dependent @*/
180 gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
181  const char *backend_name);
182 
183 void qof_object_foreach_backend (const char *backend_name,
184  QofForeachBackendTypeCB cb,
185  gpointer user_data);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif /* QOF_OBJECT_H_ */
192 
void(* mark_clean)(QofCollection *)
Definition: qofobject.h:103
gboolean qof_object_register_backend(QofIdTypeConst type_name, const char *backend_name, gpointer be_data)
void(* book_end)(QofBook *)
Definition: qofobject.h:97
const char * qof_object_get_type_label(QofIdTypeConst type_name)
const gchar * QofIdTypeConst
Definition: qofid.h:87
int(* version_cmp)(gpointer instance_left, gpointer instance_right)
Definition: qofobject.h:126
gpointer(* create)(QofBook *)
Definition: qofobject.h:87
QOF entity type identification system.
void qof_object_foreach_type(QofForeachTypeCB cb, gpointer user_data)
void qof_object_foreach_sorted(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
const gchar * QofIdType
Definition: qofid.h:85
const QofObject * qof_object_lookup(QofIdTypeConst type_name)
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
void(* book_begin)(QofBook *)
Definition: qofobject.h:92
gpointer qof_object_new_instance(QofIdTypeConst type_name, QofBook *book)
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
Definition: qofid.h:186
Encapsulate all the information about a dataset.
gboolean(* is_dirty)(const QofCollection *)
Definition: qofobject.h:100
Linking one entity to other entities of many possible types.
const char * qof_object_printable(QofIdTypeConst type_name, gpointer instance)
gboolean qof_object_register(const QofObject *object)