GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Enumerator | Functions | Variables

Private interfaces, not meant to be used by applications. More...

Files

file  qofobject-p.h
 the Core Object Registration/Lookup Private Interface
 

Data Structures

struct  QofBackend
 
struct  QofBook
 QofBook reference. More...
 
struct  QofBookTestFunctions
 

Functions

 QofBackend::QofBackend (const QofBackend &)=delete
 
 QofBackend::QofBackend (const QofBackend &&)=delete
 
virtual void QofBackend::session_begin (QofSession *session, const char *new_uri, SessionOpenMode mode)=0
 Open the file or connect to the server.
 
virtual void QofBackend::session_end ()=0
 
virtual void QofBackend::load (QofBook *, QofBackendLoadType)=0
 Load the minimal set of application data needed for the application to be operable at initial startup.
 
virtual void QofBackend::begin (QofInstance *)
 Called when the engine is about to make a change to a data structure.
 
virtual void QofBackend::commit (QofInstance *)
 Commits the changes from the engine to the backend data storage.
 
virtual void QofBackend::rollback (QofInstance *)
 Revert changes in the engine and unlock the backend.
 
virtual void QofBackend::sync (QofBook *)=0
 Synchronizes the engine contents to the backend.
 
virtual void QofBackend::safe_sync (QofBook *)=0
 Perform a sync in a way that prevents data loss on a DBI backend.
 
virtual void QofBackend::export_coa (QofBook *)
 Extract the chart of accounts from the current database and create a new database with it.
 
void QofBackend::set_error (QofBackendError err)
 Set the error value only if there isn't already an error already.
 
QofBackendError QofBackend::get_error ()
 Retrieve the currently-stored error and clear it.
 
bool QofBackend::check_error ()
 Report if there is an error.
 
void QofBackend::set_message (std::string &&)
 Set a descriptive message that can be displayed to the user when there's an error.
 
const std::string && QofBackend::get_message ()
 Retrieve and clear the stored error message.
 
void QofBackend::set_percentage (QofBePercentageFunc pctfn)
 Store and retrieve a backend-specific function for determining the progress in completing a long operation, for use with a progress meter.
 
QofBePercentageFunc QofBackend::get_percentage ()
 
const std::string & QofBackend::get_uri ()
 Retrieve the backend's storage URI.
 
static bool QofBackend::register_backend (const char *, const char *)
 Class methods for dynamically loading the several backends and for freeing them at shutdown.
 
static void QofBackend::release_backends ()
 

Variables

QofBePercentageFunc QofBackend::m_percentage
 
std::string QofBackend::m_fullpath
 Each backend resolves a fully-qualified file path.
 
QofInstance QofBook::inst
 
gboolean QofBook::session_dirty
 
time64 QofBook::dirty_time
 
QofBookDirtyCB QofBook::dirty_cb
 
gpointer QofBook::dirty_data
 
GHashTable * QofBook::hash_of_collections
 
GHashTable * QofBook::data_tables
 
GHashTable * QofBook::data_table_finalizers
 
gboolean QofBook::read_only
 
char QofBook::book_open
 
gboolean QofBook::shutting_down
 
gint32 QofBook::version
 
QofBackendQofBook::backend
 
gboolean QofBook::cached_num_field_source
 
gboolean QofBook::cached_num_field_source_isvalid
 
gint QofBook::cached_num_days_autoreadonly
 
gboolean QofBook::cached_num_days_autoreadonly_isvalid
 
gboolean(* QofBookTestFunctions::get_session_dirty )(const QofBook *)
 
gboolean(* QofBookTestFunctions::get_read_only )(const QofBook *)
 
QofBookDirtyCB(* QofBookTestFunctions::get_dirty_cb )(const QofBook *)
 
void(* QofBookTestFunctions::set_shutting_down )(QofBook *, gboolean)
 
gpointer(* QofBookTestFunctions::get_dirty_data )(const QofBook *)
 
GHashTable *(* QofBookTestFunctions::get_collections )(const QofBook *)
 
GHashTable *(* QofBookTestFunctions::get_data_tables )(const QofBook *)
 
GHashTable *(* QofBookTestFunctions::get_data_table_finalizers )(const QofBook *)
 
char(* QofBookTestFunctions::get_book_open )(const QofBook *)
 
int(* QofBookTestFunctions::get_version )(const QofBook *)
 

Backend_Private

Pseudo-object defining how the engine can interact with different back-ends (which may be SQL databases, or network interfaces to remote QOF servers.

File-io is just one type of backend).

The callbacks will be called at the appropriate times during a book session to allow the backend to store the data as needed.

enum  QofBackendLoadType { LOAD_TYPE_INITIAL_LOAD , LOAD_TYPE_LOAD_ALL }
 
using GModuleVec = std::vector< GModule * >
 

Book_Private

QofBookTestFunctions_utest_qofbook_fill_functions (void)
 
void qof_book_set_backend (QofBook *book, QofBackend *be)
 
gboolean qof_book_register (void)
 
gchar * qof_book_normalize_counter_format_internal (const gchar *p, const gchar *gint64_format, gchar **err_msg)
 Validate a counter format string with a given format specifier.
 
void qof_book_print_dirty (const QofBook *book)
 This debugging function can be used to traverse the book structure and all subsidiary structures, printing out which structures have been marked dirty.
 

Class_Private

void qof_class_init (void)
 
void qof_class_shutdown (void)
 
QofSortFunc qof_class_get_default_sort (QofIdTypeConst obj_name)
 

Entity_Private

void qof_collection_insert_entity (QofCollection *, QofInstance *)
 Take entity, remove it from whatever collection its currently in, and place it in a new collection.
 
void qof_collection_mark_clean (QofCollection *)
 reset value of dirty flag
 
void qof_collection_mark_dirty (QofCollection *)
 
void qof_collection_print_dirty (const QofCollection *col, gpointer dummy)
 

Objects_Private

void qof_object_book_begin (QofBook *book)
 To be called from within the book.
 
void qof_object_book_end (QofBook *book)
 
gboolean qof_object_is_dirty (const QofBook *book)
 
void qof_object_mark_clean (QofBook *book)
 
gboolean qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
 check an object can be created and supports iteration
 

Detailed Description

Private interfaces, not meant to be used by applications.

Typedef Documentation

◆ GModuleVec

using GModuleVec = std::vector<GModule*>

Definition at line 169 of file qof-backend.hpp.

Enumeration Type Documentation

◆ QofBackendLoadType

enum QofBackendLoadType

Definition at line 163 of file qof-backend.hpp.

164{
165 LOAD_TYPE_INITIAL_LOAD,
166 LOAD_TYPE_LOAD_ALL
167} QofBackendLoadType;

Function Documentation

◆ _utest_qofbook_fill_functions()

QofBookTestFunctions * _utest_qofbook_fill_functions ( void  )

Definition at line 1444 of file qofbook.cpp.

1445{
1446 QofBookTestFunctions *func = g_new (QofBookTestFunctions, 1);
1447
1448 func->get_session_dirty = get_session_dirty;
1449 func->get_read_only = get_read_only;
1450 func->get_dirty_cb = get_dirty_cb;
1451 func->set_shutting_down = set_shutting_down;
1452 func->get_dirty_data = get_dirty_data;
1453 func->get_collections = get_collections;
1454 func->get_data_tables = get_data_tables;
1455 func->get_data_table_finalizers = get_data_table_finalizers;
1456 func->get_book_open = get_book_open;
1457 func->get_version = get_version;
1458 return func;
1459}

◆ begin()

virtual void QofBackend::begin ( QofInstance )
inlinevirtual

Called when the engine is about to make a change to a data structure.

It could provide an advisory lock on data, but no backend does this.

Reimplemented in GncSqlBackend.

Definition at line 217 of file qof-backend.hpp.

217{}

◆ check_error()

bool QofBackend::check_error ( )

Report if there is an error.

Definition at line 73 of file qof-backend.cpp.

74{
75 return m_last_err != ERR_BACKEND_NO_ERR;
76}

◆ commit()

void QofBackend::commit ( QofInstance instance)
virtual

Commits the changes from the engine to the backend data storage.

Reimplemented in GncSqlBackend, and GncXmlBackend.

Definition at line 49 of file qof-backend.cpp.

50{
51 if (qof_instance_is_dirty(instance))
52 qof_instance_mark_clean(instance);
53}
#define qof_instance_is_dirty
Return value of is_dirty flag.

◆ export_coa()

virtual void QofBackend::export_coa ( QofBook )
inlinevirtual

Extract the chart of accounts from the current database and create a new database with it.

Implemented only in the XML backend at present.

Reimplemented in GncXmlBackend.

Definition at line 250 of file qof-backend.hpp.

250{}

◆ get_error()

QofBackendError QofBackend::get_error ( )

Retrieve the currently-stored error and clear it.

Definition at line 64 of file qof-backend.cpp.

65{
66 /* use 'stack-pop' semantics */
67 auto err = m_last_err;
68 m_last_err = ERR_BACKEND_NO_ERR;
69 return err;
70}

◆ get_message()

const std::string && QofBackend::get_message ( )

Retrieve and clear the stored error message.

Definition at line 85 of file qof-backend.cpp.

86{
87 return std::move(m_error_msg);
88}

◆ get_percentage()

QofBePercentageFunc QofBackend::get_percentage ( )
inline

Definition at line 271 of file qof-backend.hpp.

271{ return m_percentage; }

◆ get_uri()

const std::string & QofBackend::get_uri ( )
inline

Retrieve the backend's storage URI.

Definition at line 274 of file qof-backend.hpp.

274{ return m_fullpath; }
std::string m_fullpath
Each backend resolves a fully-qualified file path.

◆ load()

virtual void QofBackend::load ( QofBook ,
QofBackendLoadType   
)
pure virtual

Load the minimal set of application data needed for the application to be operable at initial startup.

It is assumed that the application will perform a 'run_query()' to obtain any additional data that it needs. For file-based backends, it is acceptable for the backend to return all data at load time; for SQL-based backends, it is acceptable for the backend to return no data.

Thus, for example, the old GnuCash postgres backend returned the account tree, all currencies, and the pricedb, as these were needed at startup. It did not have to return any transactions whatsoever, as these were obtained at a later stage when a user opened a register, resulting in a query being sent to the backend. The current DBI backend on the other hand loads the entire database into memory.

(Its OK to send over entities at this point, but one should be careful of the network load; also, its possible that whatever is sent is not what the user wanted anyway, which is why its better to wait for the query).

Implemented in GncDbiBackend< Type >, GncSqlBackend, and GncXmlBackend.

◆ qof_book_normalize_counter_format_internal()

gchar * qof_book_normalize_counter_format_internal ( const gchar *  p,
const gchar *  gint64_format,
gchar **  err_msg 
)

Validate a counter format string with a given format specifier.

If valid, returns a normalized format string, that is whatever long int specifier was used will be replaced with the value of the posix "PRIx64" macro. If not valid returns NULL and optionally set an error message is a non-null err_msg parameter was passed. The caller should free the returned format string and error message with g_free.

Definition at line 785 of file qofbook.cpp.

787{
788 const gchar *conv_start, *base, *tmp = nullptr;
789 gchar *normalized_str = nullptr, *aux_str = nullptr;
790
791 /* Validate a counter format. This is a very simple "parser" that
792 * simply checks for a single gint64 conversion specification,
793 * allowing all modifiers and flags that printf(3) specifies (except
794 * for the * width and precision, which need an extra argument). */
795 base = p;
796
797 /* Skip a prefix of any character except % */
798 while (*p)
799 {
800 /* Skip two adjacent percent marks, which are literal percent
801 * marks */
802 if (p[0] == '%' && p[1] == '%')
803 {
804 p += 2;
805 continue;
806 }
807 /* Break on a single percent mark, which is the start of the
808 * conversion specification */
809 if (*p == '%')
810 break;
811 /* Skip all other characters */
812 p++;
813 }
814
815 if (!*p)
816 {
817 if (err_msg)
818 *err_msg = g_strdup("Format string ended without any conversion specification");
819 return nullptr;
820 }
821
822 /* Store the start of the conversion for error messages */
823 conv_start = p;
824
825 /* Skip the % */
826 p++;
827
828 /* See whether we have already reached the correct format
829 * specification (e.g. "li" on Unix, "I64i" on Windows). */
830 tmp = strstr(p, gint64_format);
831
832 if (!tmp)
833 {
834 if (err_msg)
835 *err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format);
836 return nullptr;
837 }
838
839 /* Skip any number of flag characters */
840 while (*p && (tmp != p) && strchr("#0- +'I", *p))
841 {
842 p++;
843 tmp = strstr(p, gint64_format);
844 }
845
846 /* Skip any number of field width digits,
847 * and precision specifier digits (including the leading dot) */
848 while (*p && (tmp != p) && strchr("0123456789.", *p))
849 {
850 p++;
851 tmp = strstr(p, gint64_format);
852 }
853
854 if (!*p)
855 {
856 if (err_msg)
857 *err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);
858 return nullptr;
859 }
860
861 /* See if the format string starts with the correct format
862 * specification. */
863 tmp = strstr(p, gint64_format);
864 if (tmp == nullptr)
865 {
866 if (err_msg)
867 *err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
868 return nullptr;
869 }
870 else if (tmp != p)
871 {
872 if (err_msg)
873 *err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
874 return nullptr;
875 }
876
877 /* Copy the string we have so far and add normalized format specifier for long int */
878 aux_str = g_strndup (base, p - base);
879 normalized_str = g_strconcat (aux_str, PRIi64, nullptr);
880 g_free (aux_str);
881
882 /* Skip length modifier / conversion specifier */
883 p += strlen(gint64_format);
884 tmp = p;
885
886 /* Skip a suffix of any character except % */
887 while (*p)
888 {
889 /* Skip two adjacent percent marks, which are literal percent
890 * marks */
891 if (p[0] == '%' && p[1] == '%')
892 {
893 p += 2;
894 continue;
895 }
896 /* Break on a single percent mark, which is the start of the
897 * conversion specification */
898 if (*p == '%')
899 {
900 if (err_msg)
901 *err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
902 g_free (normalized_str);
903 return nullptr;
904 }
905 /* Skip all other characters */
906 p++;
907 }
908
909 /* Add the suffix to our normalized string */
910 aux_str = normalized_str;
911 normalized_str = g_strconcat (aux_str, tmp, nullptr);
912 g_free (aux_str);
913
914 /* If we end up here, the string was valid, so return no error
915 * message */
916 return normalized_str;
917}

◆ qof_book_print_dirty()

void qof_book_print_dirty ( const QofBook book)

This debugging function can be used to traverse the book structure and all subsidiary structures, printing out which structures have been marked dirty.

Definition at line 411 of file qofbook.cpp.

412{
414 PINFO("book is dirty.");
415 qof_book_foreach_collection
416 (book, (QofCollectionForeachCB)qof_collection_print_dirty, nullptr);
417}
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(* QofCollectionForeachCB)(QofCollection *, gpointer user_data)
Invoke the indicated callback on each collection in the book.
Definition qofbook.h:157
#define PINFO(format, args...)
Print an informational note.
Definition qoflog.h:256

◆ qof_book_register()

gboolean qof_book_register ( void  )

Definition at line 1415 of file qofbook.cpp.

1416{
1417 static QofParam params[] =
1418 {
1419 { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, nullptr },
1420 { QOF_PARAM_KVP, QOF_TYPE_KVP, (QofAccessFunc)qof_instance_get_slots, nullptr },
1421 { nullptr },
1422 };
1423
1424 qof_class_register (QOF_ID_BOOK, nullptr, params);
1425
1426 return TRUE;
1427}
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Definition qofclass.h:123
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
Definition qofclass.cpp:86
const GncGUID * qof_entity_get_guid(gconstpointer ent)
#define QOF_PARAM_KVP
"Known" Object Parameters – some objects might support these
Definition qofquery.h:112

◆ qof_book_set_backend()

void qof_book_set_backend ( QofBook book,
QofBackend be 
)

Definition at line 457 of file qofbook.cpp.

458{
459 if (!book) return;
460 ENTER ("book=%p be=%p", book, be);
461 book->backend = be;
462 LEAVE (" ");
463}
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ qof_class_get_default_sort()

QofSortFunc qof_class_get_default_sort ( QofIdTypeConst  obj_name)

Definition at line 75 of file qofclass.cpp.

76{
77 if (!obj_name) return NULL;
78 return reinterpret_cast<QofSortFunc>(g_hash_table_lookup (sortTable,
79 obj_name));
80}
int(* QofSortFunc)(gconstpointer, gconstpointer)
This function is the default sort function for a particular object type.
Definition qofclass.h:168

◆ qof_class_init()

void qof_class_init ( void  )

Definition at line 54 of file qofclass.cpp.

55{
56 if (initialized) return;
57 initialized = TRUE;
58
59 classTable = g_hash_table_new (g_str_hash, g_str_equal);
60 sortTable = g_hash_table_new (g_str_hash, g_str_equal);
61}

◆ qof_class_shutdown()

void qof_class_shutdown ( void  )

Definition at line 64 of file qofclass.cpp.

65{
66 if (!initialized) return;
67 initialized = FALSE;
68
69 g_hash_table_foreach_remove (classTable, clear_table, NULL);
70 g_hash_table_destroy (classTable);
71 g_hash_table_destroy (sortTable);
72}

◆ qof_collection_insert_entity()

void qof_collection_insert_entity ( QofCollection *  col,
QofInstance ent 
)

Take entity, remove it from whatever collection its currently in, and place it in a new collection.

To be used only for moving entity from one book to another.

Definition at line 95 of file qofid.cpp.

96{
97 const GncGUID *guid;
98
99 if (!col || !ent) return;
100 guid = qof_instance_get_guid(ent);
101 if (guid_equal(guid, guid_null())) return;
102 g_return_if_fail (col->e_type == ent->e_type);
103 qof_collection_remove_entity (ent);
104 g_hash_table_insert (col->hash_of_entities, (gpointer)guid, ent);
105 qof_instance_set_collection(ent, col);
106}
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition guid.cpp:165
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition guid.cpp:237
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
QofIdType e_type
Entity type.
Definition qofinstance.h:75
The type used to store guids in C.
Definition guid.h:75

◆ qof_collection_mark_clean()

void qof_collection_mark_clean ( QofCollection *  col)

reset value of dirty flag

Definition at line 238 of file qofid.cpp.

239{
240 if (col)
241 {
242 col->is_dirty = FALSE;
243 }
244}

◆ qof_collection_mark_dirty()

void qof_collection_mark_dirty ( QofCollection *  col)

Definition at line 247 of file qofid.cpp.

248{
249 if (col)
250 {
251 col->is_dirty = TRUE;
252 }
253}

◆ qof_collection_print_dirty()

void qof_collection_print_dirty ( const QofCollection *  col,
gpointer  dummy 
)

Definition at line 256 of file qofid.cpp.

257{
258 if (col->is_dirty)
259 printf("%s collection is dirty.\n", col->e_type);
260 qof_collection_foreach(col, (QofInstanceForeachCB)qof_instance_print_dirty, NULL);
261}
void(* QofInstanceForeachCB)(QofInstance *, gpointer user_data)
Callback type for qof_collection_foreach.
Definition qofid.h:146

◆ qof_object_book_begin()

void qof_object_book_begin ( QofBook book)

To be called from within the book.

Definition at line 80 of file qofobject.cpp.

81{
82 GList *l;
83
84 if (!book) return;
85 ENTER (" ");
86 for (l = object_modules; l; l = l->next)
87 {
88 QofObject *obj = static_cast<QofObject*>(l->data);
89 if (obj->book_begin)
90 obj->book_begin (book);
91 }
92
93 /* Remember this book for later */
94 book_list = g_list_prepend (book_list, book);
95 LEAVE (" ");
96}

◆ qof_object_book_end()

void qof_object_book_end ( QofBook book)

Definition at line 98 of file qofobject.cpp.

99{
100 GList *l;
101
102 if (!book) return;
103 ENTER (" ");
104 for (l = object_modules; l; l = l->next)
105 {
106 QofObject *obj = static_cast<QofObject*>(l->data);
107 if (obj->book_end)
108 obj->book_end (book);
109 }
110
111 /* Remove it from the list */
112 book_list = g_list_remove (book_list, book);
113 LEAVE (" ");
114}

◆ qof_object_compliance()

gboolean qof_object_compliance ( QofIdTypeConst  type_name,
gboolean  warn 
)

check an object can be created and supports iteration

Parameters
type_nameobject to check
warnIf called only once per operation, pass TRUE to log objects that fail the compliance check. To prevent repeated log messages when calling more than once, pass FALSE.
Returns
TRUE if object can be created and supports iteration, else FALSE.

Definition at line 167 of file qofobject.cpp.

168{
169 const QofObject *obj;
170
171 obj = qof_object_lookup(type_name);
172 if ((obj->create == nullptr) || (obj->foreach == nullptr))
173 {
174 if (warn)
175 {
176 PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
177 }
178 return FALSE;
179 }
180 return TRUE;
181}
const QofObject * qof_object_lookup(QofIdTypeConst name)
Lookup an object definition.

◆ qof_object_is_dirty()

gboolean qof_object_is_dirty ( const QofBook book)

Definition at line 117 of file qofobject.cpp.

118{
119 GList *l;
120
121 if (!book) return FALSE;
122 for (l = object_modules; l; l = l->next)
123 {
124 QofObject *obj = static_cast<QofObject*>(l->data);
125 if (obj->is_dirty)
126 {
127 QofCollection *col;
128 col = qof_book_get_collection (book, obj->e_type);
129 if (obj->is_dirty (col)) return TRUE;
130 }
131 }
132 return FALSE;
133}
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition qofbook.cpp:521

◆ qof_object_mark_clean()

void qof_object_mark_clean ( QofBook book)

Definition at line 136 of file qofobject.cpp.

137{
138 GList *l;
139
140 if (!book) return;
141 for (l = object_modules; l; l = l->next)
142 {
143 QofObject *obj = static_cast<QofObject*>(l->data);
144 if (obj->mark_clean)
145 {
146 QofCollection *col;
147 col = qof_book_get_collection (book, obj->e_type);
148 (obj->mark_clean) (col);
149 }
150 }
151}

◆ QofBackend()

QofBackend::QofBackend ( )
inline

Definition at line 177 of file qof-backend.hpp.

177 :
178 m_percentage{nullptr}, m_fullpath{}, m_last_err{ERR_BACKEND_NO_ERR},
179 m_error_msg{} {}

◆ register_backend()

bool QofBackend::register_backend ( const char *  directory,
const char *  module_name 
)
static

Class methods for dynamically loading the several backends and for freeing them at shutdown.

Definition at line 91 of file qof-backend.cpp.

92{
93 if (!g_module_supported ())
94 {
95 PWARN("Modules not supported.");
96 return false;
97 }
98
99 auto absdir = directory;
100 auto pkgdir = gnc_path_get_pkglibdir ();
101 if (!absdir || !g_path_is_absolute(absdir))
102 absdir = pkgdir;
103 auto fullpath = g_module_build_path (absdir, module_name);
104/* Darwin modules can have either .so or .dylib for a suffix */
105 if (!g_file_test (fullpath, G_FILE_TEST_EXISTS) &&
106 g_strcmp0 (G_MODULE_SUFFIX, "so") == 0)
107 {
108 auto modname = g_strdup_printf ("lib%s.dylib", module_name);
109 g_free (fullpath);
110 fullpath = g_build_filename (absdir, modname, nullptr);
111 g_free (modname);
112 }
113 auto backend = g_module_open (fullpath, G_MODULE_BIND_LAZY);
114 g_free (fullpath);
115 g_free (pkgdir);
116 if (!backend)
117 {
118 PINFO ("%s: %s\n", PROJECT_NAME, g_module_error ());
119 return false;
120 }
121 void (*module_init_func)(void);
122 if (g_module_symbol (backend, "qof_backend_module_init",
123 reinterpret_cast<void**>(&module_init_func)))
124 module_init_func ();
125
126 g_module_make_resident (backend);
127 c_be_registry.push_back(backend);
128 return TRUE;
129}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250

◆ release_backends()

void QofBackend::release_backends ( )
static

Definition at line 132 of file qof-backend.cpp.

133{
134 for (auto backend : c_be_registry)
135 {
136 void (*module_finalize_func)(void);
137 if (g_module_symbol(backend, "qof_backend_module_finalize",
138 reinterpret_cast<void**>(&module_finalize_func)))
139 module_finalize_func();
140 }
141}

◆ rollback()

virtual void QofBackend::rollback ( QofInstance )
inlinevirtual

Revert changes in the engine and unlock the backend.

Reimplemented in GncSqlBackend.

Definition at line 225 of file qof-backend.hpp.

225{}

◆ safe_sync()

virtual void QofBackend::safe_sync ( QofBook )
pure virtual

Perform a sync in a way that prevents data loss on a DBI backend.

Implemented in GncDbiBackend< Type >, GncDbiBackend< Type >, and GncXmlBackend.

◆ session_begin()

virtual void QofBackend::session_begin ( QofSession *  session,
const char *  new_uri,
SessionOpenMode  mode 
)
pure virtual

Open the file or connect to the server.

Parameters
sessionThe QofSession that will control the backend.
new_uriThe location of the data store that the backend will use.
modeThe session open mode. See qof_session_begin().

Implemented in GncDbiBackend< Type >, GncDbiBackend< Type >, and GncXmlBackend.

◆ set_error()

void QofBackend::set_error ( QofBackendError  err)

Set the error value only if there isn't already an error already.

Definition at line 56 of file qof-backend.cpp.

57{
58 /* use stack-push semantics. Only the earliest error counts */
59 if (m_last_err != ERR_BACKEND_NO_ERR) return;
60 m_last_err = err;
61}

◆ set_message()

void QofBackend::set_message ( std::string &&  msg)

Set a descriptive message that can be displayed to the user when there's an error.

Definition at line 79 of file qof-backend.cpp.

80{
81 m_error_msg = msg;
82}

◆ set_percentage()

void QofBackend::set_percentage ( QofBePercentageFunc  pctfn)
inline

Store and retrieve a backend-specific function for determining the progress in completing a long operation, for use with a progress meter.

Definition at line 270 of file qof-backend.hpp.

270{ m_percentage = pctfn; }

◆ sync()

virtual void QofBackend::sync ( QofBook )
pure virtual

Synchronizes the engine contents to the backend.

This should done by using version numbers (hack alert – the engine does not currently contain version numbers). If the engine contents are newer than what is in the backend, the data is stored to the backend. If the engine contents are older, then the engine contents are updated.

Note that this sync operation is only meant to apply to the current contents of the engine. This routine is not intended to be used to fetch entity data from the backend.

File based backends tend to use sync as if it was called dump. Data is written out into the backend, overwriting the previous data. Database backends should implement a more intelligent solution.

Implemented in GncSqlBackend, and GncXmlBackend.

Variable Documentation

◆ backend

QofBackend* QofBook::backend

Definition at line 113 of file qofbook-p.hpp.

◆ book_open

char QofBook::book_open

Definition at line 97 of file qofbook-p.hpp.

◆ cached_num_days_autoreadonly

gint QofBook::cached_num_days_autoreadonly

Definition at line 125 of file qofbook-p.hpp.

◆ cached_num_days_autoreadonly_isvalid

gboolean QofBook::cached_num_days_autoreadonly_isvalid

Definition at line 127 of file qofbook-p.hpp.

◆ cached_num_field_source

gboolean QofBook::cached_num_field_source

Definition at line 118 of file qofbook-p.hpp.

◆ cached_num_field_source_isvalid

gboolean QofBook::cached_num_field_source_isvalid

Definition at line 120 of file qofbook-p.hpp.

◆ data_table_finalizers

GHashTable* QofBook::data_table_finalizers

Definition at line 85 of file qofbook-p.hpp.

◆ data_tables

GHashTable* QofBook::data_tables

Definition at line 82 of file qofbook-p.hpp.

◆ dirty_cb

QofBookDirtyCB QofBook::dirty_cb

Definition at line 67 of file qofbook-p.hpp.

◆ dirty_data

gpointer QofBook::dirty_data

Definition at line 71 of file qofbook-p.hpp.

◆ dirty_time

time64 QofBook::dirty_time

Definition at line 62 of file qofbook-p.hpp.

◆ get_book_open

char(* QofBookTestFunctions::get_book_open) (const QofBook *)

Definition at line 142 of file qofbook-p.hpp.

◆ get_collections

GHashTable *(* QofBookTestFunctions::get_collections) (const QofBook *)

Definition at line 139 of file qofbook-p.hpp.

◆ get_data_table_finalizers

GHashTable *(* QofBookTestFunctions::get_data_table_finalizers) (const QofBook *)

Definition at line 141 of file qofbook-p.hpp.

◆ get_data_tables

GHashTable *(* QofBookTestFunctions::get_data_tables) (const QofBook *)

Definition at line 140 of file qofbook-p.hpp.

◆ get_dirty_cb

QofBookDirtyCB(* QofBookTestFunctions::get_dirty_cb) (const QofBook *)

Definition at line 136 of file qofbook-p.hpp.

◆ get_dirty_data

gpointer(* QofBookTestFunctions::get_dirty_data) (const QofBook *)

Definition at line 138 of file qofbook-p.hpp.

◆ get_read_only

gboolean(* QofBookTestFunctions::get_read_only) (const QofBook *)

Definition at line 135 of file qofbook-p.hpp.

◆ get_session_dirty

gboolean(* QofBookTestFunctions::get_session_dirty) (const QofBook *)

Definition at line 134 of file qofbook-p.hpp.

◆ get_version

int(* QofBookTestFunctions::get_version) (const QofBook *)

Definition at line 143 of file qofbook-p.hpp.

◆ hash_of_collections

GHashTable* QofBook::hash_of_collections

Definition at line 77 of file qofbook-p.hpp.

◆ inst

QofInstance QofBook::inst

Definition at line 48 of file qofbook-p.hpp.

◆ m_fullpath

std::string QofBackend::m_fullpath
protected

Each backend resolves a fully-qualified file path.

This holds the filepath and communicates it to the frontends.

Definition at line 286 of file qof-backend.hpp.

◆ m_percentage

QofBePercentageFunc QofBackend::m_percentage
protected

Definition at line 282 of file qof-backend.hpp.

◆ read_only

gboolean QofBook::read_only

Definition at line 91 of file qofbook-p.hpp.

◆ session_dirty

gboolean QofBook::session_dirty

Definition at line 58 of file qofbook-p.hpp.

◆ set_shutting_down

void(* QofBookTestFunctions::set_shutting_down) (QofBook *, gboolean)

Definition at line 137 of file qofbook-p.hpp.

◆ shutting_down

gboolean QofBook::shutting_down

Definition at line 104 of file qofbook-p.hpp.

◆ version

gint32 QofBook::version

Definition at line 107 of file qofbook-p.hpp.