This is a singleton. More...
Inherits sigc::trackable.
Public Types | |
typedef ConnectionPoolBackends::Backend | Backend |
typedef Backend::type_vec_const_fields | type_vec_const_fields |
typedef sigc::slot< void > | type_void_slot |
typedef Backend::SlotProgress | SlotProgress |
This callback should show UI to indicate that work is still happening. | |
typedef Backend::InitErrors | InitErrors |
typedef Backend::StartupErrors | StartupErrors |
typedef sigc::slot< Document* > | SlotGetDocument |
Specify a callback that the ConnectionPool can call to get a pointer to the document. | |
Public Member Functions | |
void | setup_from_document (const Document* document) |
Make the ConnectionPool use the correct backend, with the necessary details, as required by the document. | |
void | set_avahi_publish_callbacks (const type_void_slot& slot_begin, const type_void_slot& slot_progress, const type_void_slot& slot_done) |
Set callbacks that will be called to show UI while starting to advertise on the network via Avahi. | |
bool | get_ready_to_connect () const |
void | set_ready_to_connect (bool val=true) |
void | set_backend (std::auto_ptr< Backend > backend) |
Backend* | get_backend () |
const Backend* | get_backend () const |
sharedptr< SharedConnection > | connect () |
This method will return a SharedConnection, either by opening a new connection or returning an already-open connection. | |
void | create_database (const Glib::ustring& database_name) |
Creates a new database. | |
bool | save_backup (const SlotProgress& slot_progress, const std::string& path_dir) |
Save a backup of the database in a tarball. | |
bool | convert_backup (const SlotProgress& slot_progress, const std::string& path_dir) |
Use a backup of the database in a tarball to create tables and data in an existing empty database. | |
void | set_user (const Glib::ustring& value) |
void | set_password (const Glib::ustring& value) |
void | set_database (const Glib::ustring& value) |
Glib::ustring | get_user () const |
Glib::ustring | get_password () const |
Glib::ustring | get_database () const |
Field::sql_format | get_sql_format () const |
const FieldTypes* | get_field_types () const |
Glib::ustring | get_string_find_operator () const |
InitErrors | initialize (const SlotProgress& slot_progress, bool network_shared=false) |
Do one-time initialization, such as creating required database files on disk for later use by their own database server instance. | |
StartupErrors | startup (const SlotProgress& slot_progress, bool network_shared=false) |
Start a database server instance for the existing database files. | |
bool | cleanup (const SlotProgress& slot_progress) |
Stop the database server instance for the database files. | |
virtual bool | set_network_shared (const SlotProgress& slot_progress, bool network_shared=true) |
Change the database server's configration to allow or prevent access from other users on the network. | |
bool | add_column (const Glib::ustring& table_name, const sharedptr< const Field >& field) |
bool | drop_column (const Glib::ustring& table_name, const Glib::ustring& field_name) |
bool | change_column (const Glib::ustring& table_name, const sharedptr< const Field >& field_old, const sharedptr< const Field >& field) |
bool | change_columns (const Glib::ustring& table_name, const type_vec_const_fields& old_fields, const type_vec_const_fields& fields) |
void | set_get_document_func (const SlotGetDocument& slot) |
Static Public Member Functions | |
static ConnectionPool* | get_instance () |
Get the singleton instance. | |
static void | delete_instance () |
Delete the singleton so it doesn't show up as leaked memory in, for instance, valgrind. | |
static sharedptr < SharedConnection > | get_and_connect () |
static EpcContents* | on_publisher_document_requested (EpcPublisher* publisher, const gchar* key, gpointer user_data) |
static gboolean | on_publisher_document_authentication (EpcAuthContext* context, const gchar* user_name, gpointer user_data) |
static void | on_epc_progress_begin (const gchar* title, gpointer user_data) |
static void | on_epc_progress_update (gdouble progress, const gchar* message, gpointer user_data) |
static void | on_epc_progress_end (gpointer user_data) |
static bool | handle_error_cerr_only () |
This is a singleton.
Use get_instance().
typedef sigc::slot<Document*> Glom::ConnectionPool::SlotGetDocument |
Specify a callback that the ConnectionPool can call to get a pointer to the document.
This callback avoids Connection having to link to Application, and avoids us worrying about whether a previously-set document (via a set_document() method) is still valid.
This callback should show UI to indicate that work is still happening.
For instance, a pulsing ProgressBar.
typedef sigc::slot<void> Glom::ConnectionPool::type_void_slot |
bool Glom::ConnectionPool::add_column | ( | const Glib::ustring & | table_name, | |
const sharedptr< const Field >& | field | |||
) |
bool Glom::ConnectionPool::change_column | ( | const Glib::ustring & | table_name, | |
const sharedptr< const Field >& | field_old, | |||
const sharedptr< const Field >& | field | |||
) |
bool Glom::ConnectionPool::change_columns | ( | const Glib::ustring & | table_name, | |
const type_vec_const_fields& | old_fields, | |||
const type_vec_const_fields& | fields | |||
) |
bool Glom::ConnectionPool::cleanup | ( | const SlotProgress& | slot_progress | ) |
Stop the database server instance for the database files.
slot_progress | A callback to call while the work is still happening. | |
parent_window | The parent window (transient for) of any dialogs shown during this operation. |
sharedptr< SharedConnection > Glom::ConnectionPool::connect | ( | ) |
This method will return a SharedConnection, either by opening a new connection or returning an already-open connection.
When that SharedConnection is destroyed, or when SharedConnection::close() is called, then the ConnectionPool will be informed. The connection will only be closed when all SharedConnections have finished with their connections.
an | ExceptionConnection when the connection fails. |
bool Glom::ConnectionPool::convert_backup | ( | const SlotProgress& | slot_progress, | |
const std::string & | path_dir | |||
) |
Use a backup of the database in a tarball to create tables and data in an existing empty database.
The database (server) should already have the necessary groups and users.
path_dir | The top-level directory for the backup file, using the normal directory structure. See save_backup(). |
void Glom::ConnectionPool::create_database | ( | const Glib::ustring & | database_name | ) |
Creates a new database.
void Glom::ConnectionPool::delete_instance | ( | ) | [static] |
Delete the singleton so it doesn't show up as leaked memory in, for instance, valgrind.
bool Glom::ConnectionPool::drop_column | ( | const Glib::ustring & | table_name, | |
const Glib::ustring & | field_name | |||
) |
sharedptr< SharedConnection > Glom::ConnectionPool::get_and_connect | ( | ) | [static] |
const ConnectionPool::Backend* Glom::ConnectionPool::get_backend | ( | ) | const |
ConnectionPool::Backend* Glom::ConnectionPool::get_backend | ( | ) |
Glib::ustring Glom::ConnectionPool::get_database | ( | ) | const |
const FieldTypes* Glom::ConnectionPool::get_field_types | ( | ) | const |
ConnectionPool* Glom::ConnectionPool::get_instance | ( | ) | [static] |
Get the singleton instance.
Use delete_instance() when the program quits.
Glib::ustring Glom::ConnectionPool::get_password | ( | ) | const |
bool Glom::ConnectionPool::get_ready_to_connect | ( | ) | const |
Field::sql_format Glom::ConnectionPool::get_sql_format | ( | ) | const |
Glib::ustring Glom::ConnectionPool::get_string_find_operator | ( | ) | const |
Glib::ustring Glom::ConnectionPool::get_user | ( | ) | const |
bool Glom::ConnectionPool::handle_error_cerr_only | ( | ) | [static] |
ConnectionPool::InitErrors Glom::ConnectionPool::initialize | ( | const SlotProgress& | slot_progress, | |
bool | network_shared = false | |||
) |
Do one-time initialization, such as creating required database files on disk for later use by their own database server instance.
slot_progress | A callback to call while the work is still happening. | |
network_shared | Whether the database (and document) should be available to other users over the network, if possible. | |
parent_window | A parent window to use as the transient window when displaying errors. |
void Glom::ConnectionPool::on_epc_progress_begin | ( | const gchar * | title, | |
gpointer | user_data | |||
) | [static] |
void Glom::ConnectionPool::on_epc_progress_end | ( | gpointer | user_data | ) | [static] |
void Glom::ConnectionPool::on_epc_progress_update | ( | gdouble | progress, | |
const gchar * | message, | |||
gpointer | user_data | |||
) | [static] |
gboolean Glom::ConnectionPool::on_publisher_document_authentication | ( | EpcAuthContext * | context, | |
const gchar * | user_name, | |||
gpointer | user_data | |||
) | [static] |
EpcContents * Glom::ConnectionPool::on_publisher_document_requested | ( | EpcPublisher * | publisher, | |
const gchar * | key, | |||
gpointer | user_data | |||
) | [static] |
bool Glom::ConnectionPool::save_backup | ( | const SlotProgress& | slot_progress, | |
const std::string & | path_dir | |||
) |
Save a backup of the database in a tarball.
This backup can later be used to recreate the database, for instance with a later version of PostgreSQL. See ().
path_dir | The top-level directory for the backup file, using the normal directory structure. |
void Glom::ConnectionPool::set_avahi_publish_callbacks | ( | const type_void_slot& | slot_begin, | |
const type_void_slot& | slot_progress, | |||
const type_void_slot& | slot_done | |||
) |
Set callbacks that will be called to show UI while starting to advertise on the network via Avahi.
slot_begin | Show an explanatory message. | |
slot_progress | Show a pulse progress and/or keep the UI updating. | |
slot_done | Stop showing the message. |
void Glom::ConnectionPool::set_backend | ( | std::auto_ptr< Backend > | backend | ) |
void Glom::ConnectionPool::set_database | ( | const Glib::ustring & | value | ) |
void Glom::ConnectionPool::set_get_document_func | ( | const SlotGetDocument& | slot | ) |
bool Glom::ConnectionPool::set_network_shared | ( | const SlotProgress& | slot_progress, | |
bool | network_shared = true | |||
) | [virtual] |
Change the database server's configration to allow or prevent access from other users on the network.
For current backends, you may use this only before startup(), or after cleanup().
slot_progress | A callback to call while the work is still happening. | |
network_shared | Whether the database (and document) should be available to other users over the network, if possible. |
void Glom::ConnectionPool::set_password | ( | const Glib::ustring & | value | ) |
void Glom::ConnectionPool::set_ready_to_connect | ( | bool | val = true |
) |
void Glom::ConnectionPool::set_user | ( | const Glib::ustring & | value | ) |
void Glom::ConnectionPool::setup_from_document | ( | const Document* | document | ) |
Make the ConnectionPool use the correct backend, with the necessary details, as required by the document.
ConnectionPool::StartupErrors Glom::ConnectionPool::startup | ( | const SlotProgress& | slot_progress, | |
bool | network_shared = false | |||
) |
Start a database server instance for the existing database files.
slot_progress | A callback to call while the work is still happening. | |
network_shared | Whether the database (and document) should be available to other users over the network, if possible. | |
parent_window | The parent window (transient for) of any dialogs shown during this operation. |