GnuCash  5.6-150-g038405b370+
qofbook.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofbook.h -- Encapsulate all the information about a dataset. *
3  * This program is free software; you can redistribute it and/or *
4  * modify it under the terms of the GNU General Public License as *
5  * published by the Free Software Foundation; either version 2 of *
6  * the License, or (at your option) any later version. *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU General Public License*
14  * along with this program; if not, contact: *
15  * *
16  * Free Software Foundation Voice: +1-617-542-5942 *
17  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
18  * Boston, MA 02110-1301, USA gnu@gnu.org *
19  * *
20 \********************************************************************/
40 #ifndef QOF_BOOK_H
41 #define QOF_BOOK_H
42 
43 #include <glib.h>
44 #ifdef __cplusplus
45 class GncOptionDB;
46 #else
47 typedef struct GncOptionDB GncOptionDB;
48 #endif
49 /* We only want a few things exported to Guile */
50 #ifndef SWIG
51 
52 typedef struct _QofBookClass QofBookClass;
53 #ifndef __KVP_VALUE
54 typedef struct KvpValueImpl KvpValue;
55 #define __KVP_VALUE
56 #endif
57 
58 #include "qofid.h"
59 #include "qofinstance.h"
60 #include "qofbackend.h"
61 
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66 
67 /* --- type macros --- */
68 #define QOF_TYPE_BOOK (qof_book_get_type ())
69 #define QOF_BOOK(o) \
70  (G_TYPE_CHECK_INSTANCE_CAST ((o), QOF_TYPE_BOOK, QofBook))
71 #define QOF_BOOK_CLASS(k) \
72  (G_TYPE_CHECK_CLASS_CAST((k), QOF_TYPE_BOOK, QofBookClass))
73 #define QOF_IS_BOOK(o) \
74  (G_TYPE_CHECK_INSTANCE_TYPE ((o), QOF_TYPE_BOOK))
75 #define QOF_IS_BOOK_CLASS(k) \
76  (G_TYPE_CHECK_CLASS_TYPE ((k), QOF_TYPE_BOOK))
77 #define QOF_BOOK_GET_CLASS(o) \
78  (G_TYPE_INSTANCE_GET_CLASS ((o), QOF_TYPE_BOOK, QofBookClass))
79 
80 typedef void (*QofBookDirtyCB) (QofBook *, gboolean dirty, gpointer user_data);
81 
82 typedef void (*GncOptionSave) (GncOptionDB*, QofBook*, gboolean);
83 typedef void (*GncOptionLoad) (GncOptionDB*, QofBook*);
84 
86 {
87  QofInstanceClass parent_class;
88 };
89 
90 GType qof_book_get_type(void);
91 
101 #define QOF_BOOK_RETURN_ENTITY(book,guid,e_type,c_type) { \
102  QofInstance *val = NULL; \
103  if ((guid != NULL) && (book != NULL)) { \
104  const QofCollection *col; \
105  col = qof_book_get_collection (book, e_type); \
106  val = qof_collection_lookup_entity (col, guid); \
107  } \
108  return (c_type *) val; \
109 }
110 
111 
112 
114 typedef GList QofBookList;
115 
116 typedef void (*QofBookFinalCB) (QofBook *, gpointer key, gpointer user_data);
117 
119 gboolean qof_book_register (void);
120 
123 QofBook * qof_book_new (void);
124 
127 void qof_book_destroy (QofBook *book);
128 
134 void qof_book_mark_closed (QofBook *book);
135 
136 gboolean qof_book_is_open (const QofBook *book);
137 
138 void qof_book_swap_books_readonly (QofBook *book, QofBook *other);
139 
153 /*@ dependent @*/
154 QofCollection * qof_book_get_collection (const QofBook *, QofIdType);
155 
157 typedef void (*QofCollectionForeachCB) (QofCollection *, gpointer user_data);
158 void qof_book_foreach_collection (const QofBook *, QofCollectionForeachCB, gpointer);
159 
166 void qof_book_set_data (QofBook *book, const gchar *key, gpointer data);
167 
172 void qof_book_set_data_fin (QofBook *book, const gchar *key, gpointer data,
173  QofBookFinalCB);
174 
176 gpointer qof_book_get_data (const QofBook *book, const gchar *key);
177 
179 gboolean qof_book_is_readonly(const QofBook *book);
180 
182 void qof_book_mark_readonly(QofBook *book);
183 
185 gboolean qof_book_empty(const QofBook *book);
186 
187 #endif /* SWIG */
188 
190 gboolean qof_book_use_trading_accounts (const QofBook *book);
191 
192 void qof_book_reset_num_days_autoreadonly_cache (QofBook *book);
193 
196 gboolean qof_book_uses_autoreadonly (const QofBook *book);
197 
202 
211 GDate* qof_book_get_autoreadonly_gdate (const QofBook *book);
212 
216 void qof_book_set_default_invoice_report (QofBook *book, const gchar *guid,
217  const gchar *name);
218 
223 
228 
233 
236 gboolean qof_book_use_split_action_for_num_field (const QofBook *book);
237 
239 gboolean qof_book_shutting_down (const QofBook *book);
240 
248 gboolean qof_book_session_not_saved (const QofBook *book);
249 
250 /* The following functions are not useful in scripting languages */
251 #ifndef SWIG
252 
259 
265 
268 
272 void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data);
273 
277 gint64 qof_book_get_counter (QofBook *book, const char *counter_name);
278 
283 gchar *qof_book_increment_and_format_counter (QofBook *book, const char *counter_name);
284 
292 gchar * qof_book_normalize_counter_format(const gchar *format, gchar **err_msg);
293 
298 char *qof_book_get_counter_format (const QofBook *book,
299  const char *counter_name);
300 
301 const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
302 void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
303 const GncGUID* qof_book_get_guid_option(QofBook* book, GSList* path);
304 void qof_book_option_frame_delete (QofBook *book, const char* opt_name);
305 
308 GHashTable *qof_book_get_features (QofBook *book);
309 void qof_book_unset_feature (QofBook *book, const gchar *key);
310 void qof_book_set_feature (QofBook *book, const gchar *key, const gchar *descr);
311 
312 void qof_book_begin_edit(QofBook *book);
313 void qof_book_commit_edit(QofBook *book);
314 
315 /* Access functions for options. */
324 void qof_book_load_options (QofBook *book, GncOptionLoad load_cb,
325  GncOptionDB *odb);
332 void qof_book_save_options (QofBook *book, GncOptionSave save_cb,
333  GncOptionDB* odb, gboolean clear);
342 void qof_book_set_option (QofBook *book, KvpValue *value, GSList *path);
343 
351 KvpValue* qof_book_get_option (QofBook *book, GSList *path);
352 
359 void qof_book_options_delete (QofBook *book, GSList *path);
362 #define qof_book_get_guid(X) qof_entity_get_guid (QOF_INSTANCE(X))
363 
364 #ifdef __cplusplus
365 }
366 #endif
367 
368 #endif /* SWIG */
369 #endif /* QOF_BOOK_H */
370 
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.
API for data storage Backend.
gboolean qof_book_register(void)
Register the book object with the QOF object system.
Definition: qofbook.cpp:1415
void qof_book_load_options(QofBook *book, GncOptionLoad load_cb, GncOptionDB *odb)
Load a GncOptionsDB from KVP data.
Definition: qofbook.cpp:1334
void qof_book_set_option(QofBook *book, KvpValue *value, GSList *path)
Save a single option value.
Definition: qofbook.cpp:1379
void qof_book_set_dirty_cb(QofBook *book, QofBookDirtyCB cb, gpointer user_data)
Set the function to call when a book transitions from clean to dirty, or vice versa.
Definition: qofbook.cpp:426
void(* QofCollectionForeachCB)(QofCollection *, gpointer user_data)
Invoke the indicated callback on each collection in the book.
Definition: qofbook.h:157
time64 qof_book_get_session_dirty_time(const QofBook *book)
Retrieve the earliest modification time on the book.
Definition: qofbook.cpp:420
gdouble qof_book_get_default_invoice_report_timeout(const QofBook *book)
Get the length of time available to change the used Invoice Report when printing Invoices.
Definition: qofbook.cpp:1150
gchar * qof_book_increment_and_format_counter(QofBook *book, const char *counter_name)
This will increment the named counter for this book and format it.
Definition: qofbook.cpp:637
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
Definition: qofbook.cpp:986
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the &#39;Num&#39; field, FALSE if it uses transaction nu...
QofBook * qof_book_new(void)
Allocate, initialise and return a new QofBook.
Definition: qofbook.cpp:290
void qof_book_mark_closed(QofBook *book)
Close a book to editing.
Definition: qofbook.cpp:570
char * qof_book_get_counter_format(const QofBook *book, const char *counter_name)
Get the format string to use for the named counter.
Definition: qofbook.cpp:698
Object instance holds common fields that most gnucash objects use.
void qof_book_mark_readonly(QofBook *book)
Mark the book as read only.
Definition: qofbook.cpp:504
QOF entity type identification system.
GHashTable * qof_book_get_features(QofBook *book)
Access functions for reading and setting the used-features on this book.
Definition: qofbook.cpp:1254
gint64 qof_book_get_counter(QofBook *book, const char *counter_name)
This will get the named counter for this book.
Definition: qofbook.cpp:592
gboolean qof_book_empty(const QofBook *book)
Check if the book has had anything loaded into it.
Definition: qofbook.cpp:511
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:80
KvpValue * qof_book_get_option(QofBook *book, GSList *path)
Read a single option value.
Definition: qofbook.cpp:1392
GDate * qof_book_get_autoreadonly_gdate(const QofBook *book)
Returns the GDate that is the threshold for auto-read-only.
Definition: qofbook.cpp:1006
void qof_book_mark_session_saved(QofBook *book)
The qof_book_mark_saved() routine marks the book as having been saved (to a file, to a database)...
Definition: qofbook.cpp:383
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...
void qof_book_options_delete(QofBook *book, GSList *path)
Delete the options.
Definition: qofbook.cpp:1399
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.
Implements KvpValue using boost::variant.
Definition: kvp-value.hpp:52
gchar * qof_book_normalize_counter_format(const gchar *format, gchar **err_msg)
Validate a counter format string.
Definition: qofbook.cpp:753
gboolean qof_book_session_not_saved(const QofBook *book)
qof_book_not_saved() returns the value of the session_dirty flag, set when changes to any object in t...
Definition: qofbook.cpp:375
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
Definition: qofbook.cpp:397
QofBook reference.
Definition: qofbook-p.hpp:46
void qof_book_set_default_invoice_report(QofBook *book, const gchar *guid, const gchar *name)
Save the Invoice Report name / guid to be used as the default for printing Invoices.
Definition: qofbook.cpp:1044
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
Definition: qofbook.cpp:497
gchar * qof_book_get_default_invoice_report_name(const QofBook *book)
Get the name of the Invoice Report to be used as the default for printing Invoices.
Definition: qofbook.cpp:1119
GList QofBookList
GList of QofBook.
Definition: qofbook.h:114
QofCollection * qof_book_get_collection(const QofBook *, QofIdType)
Return The table of entities of the given type.
Definition: qofbook.cpp:521
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
gboolean qof_book_uses_autoreadonly(const QofBook *book)
Returns TRUE if the auto-read-only feature should be used, otherwise FALSE.
Definition: qofbook.cpp:974
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
Definition: qofbook.cpp:447
gchar * qof_book_get_default_invoice_report_guid(const QofBook *book)
Get the guid of the Invoice Report to be used as the default for printing Invoices.
Definition: qofbook.cpp:1090
The type used to store guids in C.
Definition: guid.h:75
gpointer qof_book_get_data(const QofBook *book, const gchar *key)
Retrieves arbitrary pointers to structs stored by qof_book_set_data.
gboolean qof_book_use_trading_accounts(const QofBook *book)
Returns flag indicating whether this book uses trading accounts.
Definition: qofbook.cpp:921
void qof_book_destroy(QofBook *book)
End any editing sessions associated with book, and free all memory associated with it...
Definition: qofbook.cpp:331
void qof_book_save_options(QofBook *book, GncOptionSave save_cb, GncOptionDB *odb, gboolean clear)
Save a GncOptionsDB back to the book&#39;s KVP.
Definition: qofbook.cpp:1340