00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00040 #ifndef QOF_BOOK_H
00041 #define QOF_BOOK_H
00042
00043 typedef struct _QofBookClass QofBookClass;
00044
00045 #include "qofid.h"
00046 #include "kvp_frame.h"
00047 #include "qofinstance.h"
00048
00049
00050 #define QOF_TYPE_BOOK (qof_book_get_type ())
00051 #define QOF_BOOK(o) \
00052 (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
00053 #define QOF_BOOK_CLASS(k) \
00054 (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
00055 #define QOF_IS_BOOK(o) \
00056 (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
00057 #define QOF_IS_BOOK_CLASS(k) \
00058 (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
00059 #define QOF_BOOK_GET_CLASS(o) \
00060 (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
00061
00062 typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
00063
00064
00065 struct _QofBook
00066 {
00067 QofInstance inst;
00068
00069
00070
00071 time_t dirty_time;
00072
00073
00074
00075
00076 QofBookDirtyCB dirty_cb;
00077
00078
00079
00080 gpointer dirty_data;
00081
00082
00083
00084
00085
00086 GHashTable * hash_of_collections;
00087
00088
00089
00090
00091 GHashTable *data_tables;
00092
00093
00094 GHashTable *data_table_finalizers;
00095
00096
00097
00098
00099
00100 char book_open;
00101
00102
00103
00104
00105
00106
00107 gboolean shutting_down;
00108
00109
00110 gint32 version;
00111
00112
00113
00114
00115
00116 QofBackend *backend;
00117 };
00118
00119 struct _QofBookClass
00120 {
00121 QofInstanceClass parent_class;
00122 };
00123
00124 GType qof_book_get_type(void);
00125
00132 #define QOF_BOOK_LOOKUP_ENTITY(book,guid,e_type,c_type) ({ \
00133 QofInstance *val = NULL; \
00134 if (guid && book) { \
00135 QofCollection *col; \
00136 col = qof_book_get_collection (book, e_type); \
00137 val = qof_collection_lookup_entity (col, guid); \
00138 } \
00139 (c_type *) val; \
00140 })
00141
00143 typedef GList QofBookList;
00144
00145 typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
00146
00148 gboolean qof_book_register (void);
00149
00152 QofBook * qof_book_new (void);
00153
00156 void qof_book_destroy (QofBook *book);
00157
00163 void qof_book_mark_closed (QofBook *book);
00164
00178 QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
00179
00181 typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
00182 void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
00183
00191 #define qof_book_get_slots(book) qof_instance_get_slots(QOF_INSTANCE(book))
00192
00203 void qof_book_set_data (QofBook *book, const gchar *key, gpointer data);
00204
00209 void qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data,
00210 QofBookFinalCB);
00211
00213 gpointer qof_book_get_data (const QofBook *book, const gchar *key);
00214
00216 gboolean qof_book_shutting_down (const QofBook *book);
00217
00226 gboolean qof_book_not_saved (const QofBook *book);
00227
00233 void qof_book_mark_saved(QofBook *book);
00234
00239 void qof_book_mark_dirty(QofBook *book);
00240
00245 void qof_book_print_dirty (const QofBook *book);
00246
00248 time_t qof_book_get_dirty_time(const QofBook *book);
00249
00253 void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data);
00254
00257 void qof_book_kvp_changed (QofBook *book);
00258
00262 gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
00263
00267 gint64 qof_book_get_counter (const QofBook *book, const char *counter_name);
00268
00270 #define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
00271
00272 #endif
00273