GnuCash  4.8a-80-g9825132ea+
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 #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 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* QOF_OBJECT_H_ */
179 
void(* book_end)(QofBook *)
book_end is called when the book is being closed, to clean up (and free memory).
Definition: qofobject.h:97
const char * qof_object_get_type_label(QofIdTypeConst type_name)
Get the printable label for a type.
Definition: qofobject.cpp:275
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
QOF entity type identification system.
gpointer(* create)(QofBook *)
Create a new instance of this object type.
Definition: qofobject.h:87
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:92
void qof_object_foreach_type(QofForeachTypeCB cb, gpointer user_data)
Invoke the callback 'cb' on every object class definition.
Definition: qofobject.cpp:165
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:235
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:85
This is the QofObject Class descriptor.
Definition: qofobject.h:77
const QofObject * qof_object_lookup(QofIdTypeConst type_name)
Lookup an object definition.
Definition: qofobject.cpp:340
void(* mark_clean)(QofCollection *)
Mark this object's book clean (for after a load)
Definition: qofobject.h:103
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:197
gboolean(* is_dirty)(const QofCollection *)
Determine if there are any dirty items in this book.
Definition: qofobject.h:100
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:77
Encapsulate all the information about a dataset.
Linking one entity to other entities of many possible types.
const char * qof_object_printable(QofIdTypeConst type_name, gpointer instance)
Definition: qofobject.cpp:260
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
Definition: qofobject.cpp:317
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:126