GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
20  * *
21 \********************************************************************/
48 #ifndef QOF_OBJECT_H_
49 #define QOF_OBJECT_H_
50 
51 #include "qofbook.h"
52 #include "qofid.h"
53 
54 #ifdef __cplusplus
55 extern "C"
56 {
57 #endif
58 
63 #define QOF_OBJECT_VERSION 3
64 
65 #define QOF_MOD_OBJECT "qof.object"
66 
67 typedef struct _QofObject QofObject;
68 typedef void (*QofForeachCB) (gpointer obj, gpointer user_data);
69 typedef void (*QofForeachTypeCB) (QofObject *type, gpointer user_data);
70 typedef void (*QofForeachBackendTypeCB) (QofIdTypeConst type,
71  gpointer backend_data,
72  gpointer user_data);
73 
76 struct _QofObject
77 {
78  gint interface_version; /* of this object interface */
79  QofIdType e_type; /* the Object's QOF_ID */
80  const char * type_label; /* "Printable" type-label string */
81 
86  gpointer (*create)(QofBook *);
87 
91  void (*book_begin)(QofBook *);
92 
96  void (*book_end)(QofBook *);
97 
99  gboolean (*is_dirty)(const QofCollection *);
100 
102  void (*mark_clean)(QofCollection *);
103 
111  void (*foreach)(const QofCollection *, QofInstanceForeachCB, gpointer);
112 
115  const char * (*printable)(gpointer instance);
116 
125  int (*version_cmp)(gpointer instance_left, gpointer instance_right);
126 };
127 
128 /* -------------------------------------------------------------- */
129 
132 void qof_object_initialize (void);
133 void qof_object_shutdown (void);
137 gboolean qof_object_register (const QofObject *object);
138 
140 const QofObject * qof_object_lookup (QofIdTypeConst type_name);
141 
146 gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book);
147 
151 const char * qof_object_get_type_label (QofIdTypeConst type_name);
152 
154 const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance);
155 
159 void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
160 
166 void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
167  QofInstanceForeachCB cb, gpointer user_data);
168 
170 void qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book,
171  QofInstanceForeachCB cb, gpointer user_data);
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* QOF_OBJECT_H_ */
178 
void(* book_end)(QofBook *)
book_end is called when the book is being closed, to clean up (and free memory).
Definition: qofobject.h:96
const char * qof_object_get_type_label(QofIdTypeConst type_name)
Get the printable label for a type.
Definition: qofobject.cpp:263
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
QOF entity type identification system.
gpointer(* create)(QofBook *)
Create a new instance of this object type.
Definition: qofobject.h:86
void(* book_begin)(QofBook *)
book_begin is called from within the Book routines to create module-specific hooks in a book whenever...
Definition: qofobject.h:91
void qof_object_foreach_type(QofForeachTypeCB cb, gpointer user_data)
Invoke the callback 'cb' on every object class definition.
Definition: qofobject.cpp:153
void qof_object_foreach_sorted(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke callback 'cb' on each instance in guid orted order.
Definition: qofobject.cpp:223
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:80
This is the QofObject Class descriptor.
Definition: qofobject.h:76
const QofObject * qof_object_lookup(QofIdTypeConst type_name)
Lookup an object definition.
Definition: qofobject.cpp:322
void(* mark_clean)(QofCollection *)
Mark this object's book clean (for after a load)
Definition: qofobject.h:102
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback 'cb' on every instance ov a particular object type.
Definition: qofobject.cpp:185
gboolean(* is_dirty)(const QofCollection *)
Determine if there are any dirty items in this book.
Definition: qofobject.h:99
gpointer qof_object_new_instance(QofIdTypeConst type_name, QofBook *book)
Create an instance of the indicated type, returning a pointer to that instance.
Definition: qofobject.cpp:65
Encapsulate all the information about a dataset.
const char * qof_object_printable(QofIdTypeConst type_name, gpointer instance)
Definition: qofobject.cpp:248
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
Definition: qofobject.cpp:299
int(* version_cmp)(gpointer instance_left, gpointer instance_right)
Given a pair of items of this type, this routine returns value indicating which item is 'newer'...
Definition: qofobject.h:125