Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
DatabaseManager Class Referencefinal

Singleton class responsible for managing the connection to the PostgreSQL database. More...

#include <database_manager.h>

Inheritance diagram for DatabaseManager:
Collaboration diagram for DatabaseManager:

Public Member Functions

bool IsConnected () const
 Checks if the connection to the database was successfully established.
 

Static Public Member Functions

static DatabaseManagerGetInstance ()
 Gets the singleton instance of the DatabaseManager.
 

Private Member Functions

 DatabaseManager (const DatabaseManager &)=delete
 Deleted copy constructor to prevent copying.
 
 DatabaseManager (QObject *parent=nullptr)
 Private constructor to enforce the singleton pattern. Attempts to establish the connection to the PostgreSQL database using hardcoded credentials. Sets the is_connected_ flag based on the outcome. Checks for the existence of the 'active_wavelengths' table upon successful connection.
 
DatabaseManageroperator= (const DatabaseManager &)=delete
 Deleted assignment operator to prevent assignment.
 
 ~DatabaseManager () override=default
 Private destructor. The unique_ptr automatically manages the pqxx::connection lifetime.
 

Private Attributes

std::unique_ptr< pqxx::connection > connection_
 Unique pointer managing the pqxx database connection object.
 
bool is_connected_
 Flag indicating whether the database connection is currently established.
 

Detailed Description

Singleton class responsible for managing the connection to the PostgreSQL database.

This class establishes and holds the connection to the external PostgreSQL database using the pqxx library. It provides a method to check the connection status. The connection parameters are hardcoded within the constructor.

Constructor & Destructor Documentation

◆ DatabaseManager() [1/2]

DatabaseManager::DatabaseManager ( QObject * parent = nullptr)
explicitprivate

Private constructor to enforce the singleton pattern. Attempts to establish the connection to the PostgreSQL database using hardcoded credentials. Sets the is_connected_ flag based on the outcome. Checks for the existence of the 'active_wavelengths' table upon successful connection.

Parameters
parentOptional parent QObject.
Here is the caller graph for this function:

◆ ~DatabaseManager()

DatabaseManager::~DatabaseManager ( )
overrideprivatedefault

Private destructor. The unique_ptr automatically manages the pqxx::connection lifetime.

◆ DatabaseManager() [2/2]

DatabaseManager::DatabaseManager ( const DatabaseManager & )
privatedelete

Deleted copy constructor to prevent copying.

Here is the call graph for this function:

Member Function Documentation

◆ GetInstance()

static DatabaseManager * DatabaseManager::GetInstance ( )
inlinestatic

Gets the singleton instance of the DatabaseManager.

Returns
Pointer to the singleton DatabaseManager instance.
Here is the call graph for this function:

◆ IsConnected()

bool DatabaseManager::IsConnected ( ) const
inline

Checks if the connection to the database was successfully established.

Returns
True if connected, false otherwise.

◆ operator=()

DatabaseManager & DatabaseManager::operator= ( const DatabaseManager & )
privatedelete

Deleted assignment operator to prevent assignment.

Here is the call graph for this function:

Member Data Documentation

◆ connection_

std::unique_ptr<pqxx::connection> DatabaseManager::connection_
private

Unique pointer managing the pqxx database connection object.

◆ is_connected_

bool DatabaseManager::is_connected_
private

Flag indicating whether the database connection is currently established.


The documentation for this class was generated from the following files: