GnuCash c935c2f+
Loading...
Searching...
No Matches
Typedefs | Functions | Variables
qofsession.cpp File Reference

Encapsulate a connection to a storage backend. More...

#include <glib.h>
#include <config.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "qof.h"
#include "qofobject-p.h"
#include "qofbook-p.hpp"
#include "qof-backend.hpp"
#include "qofsession.hpp"
#include "gnc-backend-prov.hpp"
#include "gnc-uri-utils.h"
#include <vector>
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <string>
#include <sstream>

Go to the source code of this file.

Typedefs

using ProviderVec = std::vector< QofBackendProvider_ptr >
 

Functions

ProviderVec & get_providers (void)
 
bool get_providers_initialized (void)
 
void qof_backend_register_provider (QofBackendProvider_ptr &&prov)
 Let the system know about a new provider of backends.
 
void qof_backend_unregister_all_providers ()
 
GList * qof_backend_get_registered_access_method_list (void)
 Return a list of strings for the registered access methods.
 
void qof_session_destroy (QofSession *session)
 
QofSession * qof_session_new (QofBook *book)
 
const char * qof_session_get_error_message (const QofSession *session)
 
QofBackendError qof_session_pop_error (QofSession *session)
 The qof_session_pop_error() routine can be used to obtain the reason for any failure.
 
QofBookqof_session_get_book (const QofSession *session)
 Returns the QofBook of this session.
 
const char * qof_session_get_file_path (const QofSession *session)
 The qof_session_get_file_path() routine returns the fully-qualified file path for the session.
 
void qof_session_ensure_all_data_loaded (QofSession *session)
 Ensure all of the data is loaded from the session.
 
const char * qof_session_get_url (const QofSession *session)
 
QofBackendqof_session_get_backend (const QofSession *session)
 Returns the qof session's backend.
 
void qof_session_begin (QofSession *session, const char *uri, SessionOpenMode mode)
 Begins a new session.
 
void qof_session_load (QofSession *session, QofPercentageFunc percentage_func)
 
void qof_session_save (QofSession *session, QofPercentageFunc percentage_func)
 The qof_session_save() method will commit all changes that have been made to the session.
 
void qof_session_safe_save (QofSession *session, QofPercentageFunc percentage_func)
 A special version of save used in the sql backend which moves the existing tables aside, then saves everything to new tables, then deletes the old tables after the save is completed without error.
 
gboolean qof_session_save_in_progress (const QofSession *session)
 The qof_session_not_saved() subroutine will return TRUE if any data in the session hasn't been saved to long-term storage.
 
void qof_session_end (QofSession *session)
 The qof_session_end() method will release the session lock.
 
void qof_session_swap_data (QofSession *session_1, QofSession *session_2)
 The qof_session_swap_data () method swaps the book of the two given sessions.
 
gboolean qof_session_events_pending (const QofSession *session)
 The qof_session_events_pending() method will return TRUE if the backend has pending events which must be processed to bring the engine up to date with the backend.
 
gboolean qof_session_process_events (QofSession *session)
 The qof_session_process_events() method will process any events indicated by the qof_session_events_pending() method.
 
gboolean qof_session_export (QofSession *tmp_session, QofSession *real_session, QofPercentageFunc percentage_func)
 
void init_static_qofsession_pointers (void)
 
void qof_session_load_backend (QofSession *session, const char *access_method)
 
void qof_session_set_uri (QofSession *session, char const *uri)
 
QofBackendError qof_session_get_error (QofSession *session)
 The qof_session_get_error() routine can be used to obtain the reason for any failure.
 

Variables

void(* p_qof_session_load_backend )(QofSession *, const char *access_method)
 
void(* p_qof_session_clear_error )(QofSession *)
 
void(* p_qof_session_destroy_backend )(QofSession *)
 
void(* p_qof_session_set_uri )(QofSession *, char const *uri)
 

Detailed Description

Encapsulate a connection to a storage backend.

HISTORY: Created by Linas Vepstas December 1998

Author
Copyright (c) 1998-2004 Linas Vepstas linas.nosp@m.@lin.nosp@m.as.or.nosp@m.g
Copyright (c) 2000 Dave Peticolas
Copyright (c) 2005 Neil Williams linux.nosp@m.@cod.nosp@m.ehelp.nosp@m..co..nosp@m.uk
Copyright (c) 2016 Aaron Laws

Definition in file qofsession.cpp.

Typedef Documentation

◆ ProviderVec

using ProviderVec = std::vector<QofBackendProvider_ptr>

Definition at line 67 of file qofsession.cpp.

Function Documentation

◆ get_providers()

ProviderVec & get_providers ( void  )

Definition at line 79 of file qofsession.cpp.

80{
81 return s_providers;
82}

◆ get_providers_initialized()

bool get_providers_initialized ( void  )

Definition at line 85 of file qofsession.cpp.

86{
87 return !s_providers.empty();
88}

◆ init_static_qofsession_pointers()

void init_static_qofsession_pointers ( void  )

Definition at line 719 of file qofsession.cpp.

720{
721 p_qof_session_load_backend = &qof_session_load_backend;
722 p_qof_session_clear_error = &qof_session_clear_error;
723 p_qof_session_destroy_backend = &qof_session_destroy_backend;
724 p_qof_session_set_uri = &qof_session_set_uri;
725}

◆ qof_backend_get_registered_access_method_list()

GList * qof_backend_get_registered_access_method_list ( void  )

Return a list of strings for the registered access methods.

The owner is responsible for freeing the list but not the strings.

Definition at line 104 of file qofsession.cpp.

105{
106 GList* list = NULL;
107 std::for_each(s_providers.begin(), s_providers.end(),
108 [&list](QofBackendProvider_ptr& provider) {
109 gpointer method = reinterpret_cast<gpointer>(const_cast<char*>(provider->access_method));
110 list = g_list_prepend(list, method);
111 });
112 return list;
113}

◆ qof_backend_register_provider()

void qof_backend_register_provider ( QofBackendProvider_ptr &&  prov)

Let the system know about a new provider of backends.

This function is typically called by the provider library at library load time. This function allows the backend library to tell the QOF infrastructure that it can handle URL's of a certain type. Note that a single backend library may register more than one provider, if it is capable of handling more than one URL access method.

Definition at line 91 of file qofsession.cpp.

92{
93 s_providers.emplace_back(std::move(prov));
94}

◆ qof_backend_unregister_all_providers()

void qof_backend_unregister_all_providers ( )

Definition at line 97 of file qofsession.cpp.

98{
99 s_providers.clear ();
100}

◆ qof_session_ensure_all_data_loaded()

void qof_session_ensure_all_data_loaded ( QofSession *  session)

Ensure all of the data is loaded from the session.

Definition at line 589 of file qofsession.cpp.

590{
591 if (session == nullptr) return;
592 return session->ensure_all_data_loaded ();
593}

◆ qof_session_events_pending()

gboolean qof_session_events_pending ( const QofSession *  session)

The qof_session_events_pending() method will return TRUE if the backend has pending events which must be processed to bring the engine up to date with the backend.

Definition at line 662 of file qofsession.cpp.

663{
664 if (!session) return false;
665 return session->events_pending ();
666}

◆ qof_session_export()

gboolean qof_session_export ( QofSession *  tmp_session,
QofSession *  real_session,
QofPercentageFunc  percentage_func 
)

Definition at line 676 of file qofsession.cpp.

679{
680 if ((!tmp_session) || (!real_session)) return FALSE;
681 return tmp_session->export_session (*real_session, percentage_func);
682}

◆ qof_session_load_backend()

void qof_session_load_backend ( QofSession *  session,
const char *  access_method 
)

Definition at line 688 of file qofsession.cpp.

689{
690 session->load_backend (access_method);
691}

◆ qof_session_process_events()

gboolean qof_session_process_events ( QofSession *  session)

The qof_session_process_events() method will process any events indicated by the qof_session_events_pending() method.

It returns TRUE if the engine was modified while engine events were suspended.

Definition at line 669 of file qofsession.cpp.

670{
671 if (!session) return FALSE;
672 return session->process_events ();
673}

◆ qof_session_set_uri()

void qof_session_set_uri ( QofSession *  session,
char const *  uri 
)

Definition at line 705 of file qofsession.cpp.

706{
707 if (!uri)
708 session->m_uri = "";
709 else
710 session->m_uri = uri;
711}

Variable Documentation

◆ p_qof_session_clear_error

void(* p_qof_session_clear_error) (QofSession *) ( QofSession *  )

Definition at line 714 of file qofsession.cpp.

◆ p_qof_session_destroy_backend

void(* p_qof_session_destroy_backend) (QofSession *) ( QofSession *  )

Definition at line 715 of file qofsession.cpp.

◆ p_qof_session_load_backend

void(* p_qof_session_load_backend) (QofSession *, const char *access_method) ( QofSession *  ,
const char *  access_method 
)

Definition at line 713 of file qofsession.cpp.

◆ p_qof_session_set_uri

void(* p_qof_session_set_uri) (QofSession *, char const *uri) ( QofSession *  ,
char const *  uri 
)

Definition at line 716 of file qofsession.cpp.