Singleton class responsible for managing the connection to the PostgreSQL database.
More...
#include <database_manager.h>
|
| bool | IsConnected () const |
| | Checks if the connection to the database was successfully established.
|
| |
|
| | 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.
|
| |
| DatabaseManager & | operator= (const DatabaseManager &)=delete |
| | Deleted assignment operator to prevent assignment.
|
| |
| | ~DatabaseManager () override=default |
| | Private destructor. The unique_ptr automatically manages the pqxx::connection lifetime.
|
| |
|
| 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.
|
| |
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.
◆ 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
-
| parent | Optional parent QObject. |
◆ ~DatabaseManager()
| DatabaseManager::~DatabaseManager |
( |
| ) |
|
|
overrideprivatedefault |
Private destructor. The unique_ptr automatically manages the pqxx::connection lifetime.
◆ DatabaseManager() [2/2]
Deleted copy constructor to prevent copying.
◆ GetInstance()
◆ IsConnected()
| bool DatabaseManager::IsConnected |
( |
| ) |
const |
|
inline |
Checks if the connection to the database was successfully established.
- Returns
- True if connected, false otherwise.
◆ operator=()
Deleted assignment operator to prevent assignment.
◆ 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: