29 #include "gncla-dir.h" 35 #include "qof-backend.hpp" 37 G_GNUC_UNUSED
static QofLogModule log_module = QOF_MOD_BACKEND;
39 #define QOF_CONFIG_DESC "desc" 40 #define QOF_CONFIG_TIP "tip" 46 GModuleVec QofBackend::c_be_registry{};
52 qof_instance_mark_clean(instance);
59 if (m_last_err != ERR_BACKEND_NO_ERR)
return;
67 auto err = m_last_err;
68 m_last_err = ERR_BACKEND_NO_ERR;
75 return m_last_err != ERR_BACKEND_NO_ERR;
87 return std::move(m_error_msg);
93 if (!g_module_supported ())
95 PWARN(
"Modules not supported.");
99 auto absdir = directory;
100 auto pkgdir = gnc_path_get_pkglibdir ();
101 if (!absdir || !g_path_is_absolute(absdir))
103 auto fullpath = g_module_build_path (absdir, module_name);
105 if (!g_file_test (fullpath, G_FILE_TEST_EXISTS) &&
106 g_strcmp0 (G_MODULE_SUFFIX,
"so") == 0)
108 auto modname = g_strdup_printf (
"lib%s.dylib", module_name);
110 fullpath = g_build_filename (absdir, modname,
nullptr);
113 auto backend = g_module_open (fullpath, G_MODULE_BIND_LAZY);
118 PINFO (
"%s: %s\n", PROJECT_NAME, g_module_error ());
121 void (*module_init_func)(void);
122 if (g_module_symbol (backend,
"qof_backend_module_init",
123 reinterpret_cast<void**>(&module_init_func)))
126 g_module_make_resident (backend);
127 c_be_registry.push_back(backend);
132 QofBackend::release_backends()
134 for (
auto backend : c_be_registry)
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();
146 if (qof_be ==
nullptr)
return ERR_BACKEND_NO_ERR;
153 if (qof_be ==
nullptr)
return;
160 if (qof_be ==
nullptr)
return FALSE;
167 if (qof_be ==
nullptr)
return;
180 QofBackend::release_backends();
#define qof_instance_is_dirty
Return value of is_dirty flag.
const std::string && get_message()
Retrieve and clear the stored error message.
void set_message(std::string &&)
Set a descriptive message that can be displayed to the user when there's an error.
#define PINFO(format, args...)
Print an informational note.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
void qof_backend_set_error(QofBackend *qof_be, QofBackendError err)
Set the error on the specified QofBackend.
QofBackendError qof_backend_get_error(QofBackend *qof_be)
Get the last backend error.
virtual void commit(QofInstance *)
Commits the changes from the engine to the backend data storage.
#define PWARN(format, args...)
Log a warning.
static bool register_backend(const char *, const char *)
Class methods for dynamically loading the several backends and for freeing them at shutdown...
void qof_finalize_backend_libraries(void)
Finalize all loaded backend shareable libraries.
gboolean qof_load_backend_library(const gchar *directory, const gchar *module_name)
Load a QOF-compatible backend shared library.
bool check_error()
Report if there is an error.
void set_error(QofBackendError err)
Set the error value only if there isn't already an error already.
QofBackendError get_error()
Retrieve the currently-stored error and clear it.