GnuCash 2.4.99
qofobject.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * qofobject.h -- the Core Object Registration/Lookup Interface     *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00048 #ifndef QOF_OBJECT_H_
00049 #define QOF_OBJECT_H_
00050 
00051 #include "qofbook.h"
00052 #include "qofid.h"
00053 #include "qofchoice.h"
00054 
00059 #define QOF_OBJECT_VERSION 3
00060 
00061 #define QOF_MOD_OBJECT "qof.object"
00062 
00063 typedef struct _QofObject QofObject;
00064 typedef void (*QofForeachCB) (gpointer obj, gpointer user_data);
00065 typedef void (*QofForeachTypeCB) (QofObject *type, gpointer user_data);
00066 typedef void (*QofForeachBackendTypeCB) (QofIdTypeConst type,
00067         gpointer backend_data,
00068         gpointer user_data);
00069 
00072 struct _QofObject
00073 {
00074     gint                interface_version; /* of this object interface */
00075     QofIdType           e_type;            /* the Object's QOF_ID */
00076     const char *        type_label;        /* "Printable" type-label string */
00077 
00082     gpointer            (*create)(QofBook *);
00083 
00087     void                (*book_begin)(QofBook *);
00088 
00092     void                (*book_end)(QofBook *);
00093 
00095     gboolean            (*is_dirty)(const QofCollection *);
00096 
00098     void                (*mark_clean)(QofCollection *);
00099 
00107     void                (*foreach)(const QofCollection *, QofInstanceForeachCB, gpointer);
00108 
00111     const char *        (*printable)(gpointer instance);
00112 
00121     int                 (*version_cmp)(gpointer instance_left, gpointer instance_right);
00122 };
00123 
00124 /* -------------------------------------------------------------- */
00125 
00128 void qof_object_initialize (void);
00129 void qof_object_shutdown (void);
00133 gboolean qof_object_register (const QofObject *object);
00134 
00136 const QofObject * qof_object_lookup (QofIdTypeConst type_name);
00137 
00142 gpointer qof_object_new_instance (QofIdTypeConst type_name, QofBook *book);
00143 
00147 const char * qof_object_get_type_label (QofIdTypeConst type_name);
00148 
00150 const char * qof_object_printable (QofIdTypeConst type_name, gpointer instance);
00151 
00155 void qof_object_foreach_type (QofForeachTypeCB cb, gpointer user_data);
00156 
00162 void qof_object_foreach (QofIdTypeConst type_name, QofBook *book,
00163                          QofInstanceForeachCB cb, gpointer user_data);
00164 
00166 void qof_object_foreach_sorted (QofIdTypeConst type_name, QofBook *book,
00167                                 QofInstanceForeachCB cb, gpointer user_data);
00168 
00170 gboolean qof_object_register_backend (QofIdTypeConst type_name,
00171                                       const char *backend_name,
00172                                       gpointer be_data);
00173 
00174 /*@ dependent @*/
00175 gpointer qof_object_lookup_backend (QofIdTypeConst type_name,
00176                                     const char *backend_name);
00177 
00178 void qof_object_foreach_backend (const char *backend_name,
00179                                  QofForeachBackendTypeCB cb,
00180                                  gpointer user_data);
00181 
00182 #endif /* QOF_OBJECT_H_ */
00183 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines