|
file | qofbook.h |
| Encapsulate all the information about a dataset.
|
|
|
gboolean | qof_book_register (void) |
|
QofBook * | qof_book_new (void) |
|
void | qof_book_destroy (QofBook *book) |
|
void | qof_book_mark_closed (QofBook *book) |
|
QofCollection * | qof_book_get_collection (QofBook *, QofIdType) |
|
void | qof_book_foreach_collection (QofBook *, QofCollectionForeachCB, gpointer) |
|
void | qof_book_set_data (QofBook *book, const gchar *key, gpointer data) |
|
void | qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data, QofBookFinalCB) |
|
gpointer | qof_book_get_data (QofBook *book, const gchar *key) |
|
gboolean | qof_book_shutting_down (QofBook *book) |
|
gboolean | qof_book_not_saved (QofBook *book) |
|
void | qof_book_mark_saved (QofBook *book) |
|
void | qof_book_kvp_changed (QofBook *book) |
|
gboolean | qof_book_equal (QofBook *book_1, QofBook *book_2) |
|
gint64 | qof_book_get_counter (QofBook *book, const gchar *counter_name) |
|
A QOF Book is a dataset. It provides a single handle through which all the various collections of entities can be found. In particular, given only the type of the entity, the collection can be found.
Books also provide the 'natural' place to working with a storage backend, as a book can encapsulate everything held in storage.
Return The kvp data for the book. Note that the book KVP data is persistent, and is stored/retrieved from the file/database. Thus, the book KVP is the correct place to store data that needs to be persistent accross sessions (or shared between multiple users). To store application runtime data, use qof_book_set_data() instead.
Definition at line 113 of file qofbook.h.
#define QOF_BOOK_LOOKUP_ENTITY |
( |
|
book, |
|
|
|
guid, |
|
|
|
e_type, |
|
|
|
c_type |
|
) |
| |
Value:
Encapsulates all the information about a dataset manipulated by QOF. This is the top-most structure used for anchoring data.
Lookup an entity by guid, returning pointer to the entity
Definition at line 50 of file qofbook.h.
GList of QofBook
Definition at line 64 of file qofbook.h.
typedef void(* QofCollectionForeachCB)(QofCollection *, gpointer user_data) |
Invoke the indicated callback on each collection in the book.
Definition at line 102 of file qofbook.h.
void qof_book_destroy |
( |
QofBook * |
book | ) |
|
End any editing sessions associated with book, and free all memory associated with it.
Definition at line 99 of file qofbook.c.
103 ENTER (
"book=%p", book);
110 qof_object_book_end (book);
119 LEAVE (
"book=%p", book);
The qof_book_equal() method returns TRUE if books are equal. XXX this routine is broken, and does not currently compare data.
Definition at line 125 of file qofbook.c.
127 if (book_1 == book_2)
129 if (!book_1 || !book_2)
Return The table of entities of the given type.
When an object's constructor calls qof_instance_init(), a reference to the object is stored in the book. The book stores all the references to initialized instances, sorted by type. This function returns a collection of the references for the specified type.
If the collection doesn't yet exist for the indicated type, it is created. Thus, this routine is gaurenteed to return a non-NULL value. (Unless the system malloc failed (out of memory) in which case what happens??).
Definition at line 220 of file qofbook.c.
224 if (!book || !entity_type)
226 col = g_hash_table_lookup (book->hash_of_collections, entity_type);
230 g_hash_table_insert (book->hash_of_collections,
gint64 qof_book_get_counter |
( |
QofBook * |
book, |
|
|
const gchar * |
counter_name |
|
) |
| |
This will 'get and increment' the named counter for this book. The return value is -1 on error or the incremented counter.
Definition at line 325 of file qofbook.c.
334 PWARN (
"No book!!!");
337 if (!counter_name || *counter_name ==
'\0')
339 PWARN (
"Invalid counter name.");
344 if (be && be->counter)
345 return ((be->counter) (be, counter_name));
350 PWARN (
"Book has no KVP_Frame");
367 value = kvp_value_new_gint64 (counter);
gpointer qof_book_get_data |
( |
QofBook * |
book, |
|
|
const gchar * |
key |
|
) |
| |
Retrieves arbitrary pointers to structs stored by qof_book_set_data.
Definition at line 212 of file qofbook.c.
216 return g_hash_table_lookup (book->
data_tables, (gpointer) key);
void qof_book_kvp_changed |
( |
QofBook * |
book | ) |
|
Call this function when you change the book kvp, to make sure the book is marked 'dirty'.
Definition at line 180 of file qofbook.c.
184 book->
inst.dirty = TRUE;
void qof_book_mark_closed |
( |
QofBook * |
book | ) |
|
Close a book to editing.
It is up to the application to check this flag, and once marked closed, books cannnot be marked as open.
Definition at line 265 of file qofbook.c.
void qof_book_mark_saved |
( |
QofBook * |
book | ) |
|
The qof_book_mark_saved() routine marks the book as having been saved (to a file, to a database). Used by backends to mark the notsaved flag as FALSE just after loading. Can also be used by the frontend when the used has said to abandon any changes.
Definition at line 144 of file qofbook.c.
149 book->
inst.dirty = FALSE;
150 qof_object_mark_clean (book);
Allocate, initialise and return a new QofBook. Books contain references to all of the top-level object containers.
Definition at line 75 of file qofbook.c.
84 LEAVE (
"book=%p", book);
gboolean qof_book_not_saved |
( |
QofBook * |
book | ) |
|
qof_book_not_saved() will return TRUE if any data in the book hasn't been saved to long-term storage. (Actually, that's not quite true. The book doesn't know anything about saving. Its just that whenever data is modified, the 'dirty' flag is set. This routine returns the value of the 'dirty' flag. Its up to the backend to periodically reset this flag, when it actually does save the data.)
Definition at line 135 of file qofbook.c.
140 return (book->
inst.dirty || qof_object_is_dirty (book));
gboolean qof_book_register |
( |
void |
| ) |
|
Register the book object with the QOF object system.
Register books with the framework
Definition at line 376 of file qofbook.c.
379 {QOF_PARAM_GUID, QOF_TYPE_GUID,
385 {NULL, NULL, NULL, NULL, NULL},
void qof_book_set_data |
( |
QofBook * |
book, |
|
|
const gchar * |
key, |
|
|
gpointer |
data |
|
) |
| |
The qof_book_set_data() allows arbitrary pointers to structs to be stored in QofBook. This is the "preferred" method for extending QofBook to hold new data types. This is also the ideal location to store other arbitrary runtime data that the application may need.
The book data differs from the book KVP in that the contents of the book KVP are persistent (are saved and restored to file or database), whereas the data pointers exist only at runtime.
Definition at line 191 of file qofbook.c.
195 g_hash_table_insert (book->
data_tables, (gpointer) key, data);
void qof_book_set_data_fin |
( |
QofBook * |
book, |
|
|
const gchar * |
key, |
|
|
gpointer |
data, |
|
|
QofBookFinalCB |
|
|
) |
| |
Same as qof_book_set_data(), except that the callback will be called when the book is destroyed. The argument to the callback will be the book followed by the data pointer.
Definition at line 199 of file qofbook.c.
204 g_hash_table_insert (book->
data_tables, (gpointer) key, data);
gboolean qof_book_shutting_down |
( |
QofBook * |
book | ) |
|
Is the book shutting down?
Definition at line 162 of file qofbook.c.