AudibleT 0.0.1
A real-time A/B/X audio testing tool for subjective assessment of various audio parameters, compatible for general purpose computer as well as embedded systems.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DatabaseManager Class Reference

The DatabaseManager class manages the database operations for the audio testing application. More...

#include <DatabaseManager.h>

Inheritance diagram for DatabaseManager:
Inheritance graph
[legend]
Collaboration diagram for DatabaseManager:
Collaboration graph
[legend]

Public Member Functions

 DatabaseManager (QObject *parent=nullptr)
 Constructs a new DatabaseManager object.
 
 ~DatabaseManager ()
 Destroys the DatabaseManager object and cleans up.
 
bool setupDatabase ()
 Sets up the database. Opens the connection and creates necessary tables.
 
void dropAndRecreateTables ()
 Drops all tables and recreates them. All data is lost.
 
bool insertAudioFile (const QString &path, const QString &fileName)
 Inserts an audio file record into the database.
 
QList< AudioSamplegetAudioFiles ()
 Retrieves all audio files from the database.
 
bool clearAudioFiles ()
 Deletes all audio files from the database.
 
int createTestSession (int sampleId, int trialsCount)
 Creates a new test session record in the database.
 
bool updateTestSessionEndTime (int sessionId)
 Updates the end time of a test session record in the database.
 
QVector< TestingSessiongetSessionsWithDuration ()
 Retrieves all test sessions along with their durations from the database.
 
bool insertTrial (int sessionId, const QString &correctResponse, const QString &userResponse, int responseTime)
 Inserts a new trial record into the database.
 
QVector< SessionTrialgetTrialsForSession (int sessionId)
 Retrieves all trials for a specific session from the database.
 
double getAverageTrialsPerSession ()
 Gets the average number of trials per session.
 
double getAverageResponseTimePerTrial ()
 Gets the average response time per trial.
 
double getAverageDurationPerSession ()
 Gets the average duration per session.
 
double getAverageSuccessPerSession ()
 Gets the average success per session.
 
QMap< QString, QMap< QString, int > > getConfusionMatrixCountsForSession (int sessionId)
 Get confusion matrix counts for a specific session.
 
QList< TestSessionDatareturnExportDataForAllSessions ()
 Returns the export data for all test sessions.
 
QList< TestSessionDatareturnExportDataForSession (int sessionId)
 Returns the export data for a specific test session.
 

Detailed Description

The DatabaseManager class manages the database operations for the audio testing application.

This class provides an interface to create, read, update, and delete data from the database. It encapsulates all the database operations and provides methods to interact with the database.

Constructor & Destructor Documentation

◆ DatabaseManager()

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

Constructs a new DatabaseManager object.

Parameters
parentThe parent QObject.

Member Function Documentation

◆ clearAudioFiles()

bool DatabaseManager::clearAudioFiles ( )

Deletes all audio files from the database.

Returns
true if the records were deleted successfully, false otherwise.

◆ createTestSession()

int DatabaseManager::createTestSession ( int  sampleId,
int  trialsCount 
)

Creates a new test session record in the database.

Parameters
sampleIdThe ID of the sample for the test session.
trialsCountThe number of trials in the test session.
Returns
The ID of the created session if the operation was successful, -1 otherwise.

◆ getAudioFiles()

QList< AudioSample > DatabaseManager::getAudioFiles ( )

Retrieves all audio files from the database.

Returns
A list of AudioSample objects representing the audio files.

◆ getAverageDurationPerSession()

double DatabaseManager::getAverageDurationPerSession ( )

Gets the average duration per session.

This method calculates and returns the average duration of sessions from the data in the database.

Returns
The average duration per session as a double.

◆ getAverageResponseTimePerTrial()

double DatabaseManager::getAverageResponseTimePerTrial ( )

Gets the average response time per trial.

This method calculates and returns the average response time per trial from the data in the database.

Returns
The average response time per trial as a double.

◆ getAverageSuccessPerSession()

double DatabaseManager::getAverageSuccessPerSession ( )

Gets the average success per session.

This method calculates and returns the average success rate per session from the data in the database.

Returns
The average success rate per session as a double.

◆ getAverageTrialsPerSession()

double DatabaseManager::getAverageTrialsPerSession ( )

Gets the average number of trials per session.

This method calculates and returns the average number of trials conducted per session in the database.

Returns
The average number of trials per session as a double.

◆ getConfusionMatrixCountsForSession()

QMap< QString, QMap< QString, int > > DatabaseManager::getConfusionMatrixCountsForSession ( int  sessionId)

Get confusion matrix counts for a specific session.

This function retrieves counts for all combinations of actual and predicted values ("A" or "B") for a specified session. The counts represent the number of instances in the session where the actual value and predicted value pair occurred.

The outer QMap has "actual" values ("A" or "B") as keys and the inner QMap as values. The inner QMap has "predicted" values ("A" or "B") as keys and counts as values.

Parameters
sessionIdThe ID of the session for which to retrieve the confusion matrix counts.
Returns
A QMap containing the counts of each possible actual/predicted value combination for the specified session.

◆ getSessionsWithDuration()

QVector< TestingSession > DatabaseManager::getSessionsWithDuration ( )

Retrieves all test sessions along with their durations from the database.

Returns
A vector of TestingSession objects representing the test sessions.

◆ getTrialsForSession()

QVector< SessionTrial > DatabaseManager::getTrialsForSession ( int  sessionId)

Retrieves all trials for a specific session from the database.

Parameters
sessionIdThe ID of the session for which the trials are to be retrieved.
Returns
A vector of SessionTrial objects representing the trials.

◆ insertAudioFile()

bool DatabaseManager::insertAudioFile ( const QString &  path,
const QString &  fileName 
)

Inserts an audio file record into the database.

Parameters
pathThe path of the audio file.
fileNameThe name of the audio file.
Returns
true if the record was inserted successfully, false otherwise.

◆ insertTrial()

bool DatabaseManager::insertTrial ( int  sessionId,
const QString &  correctResponse,
const QString &  userResponse,
int  responseTime 
)

Inserts a new trial record into the database.

Parameters
sessionIdThe ID of the session for the trial.
correctResponseThe correct response for the trial.
userResponseThe user's response for the trial.
responseTimeThe time taken by the user to respond.
Returns
true if the record was inserted successfully, false otherwise.

◆ returnExportDataForAllSessions()

QList< TestSessionData > DatabaseManager::returnExportDataForAllSessions ( )

Returns the export data for all test sessions.

This function retrieves and returns a QList<TestSessionData> containing the export data for all available test sessions.

Returns
A QList<TestSessionData> containing the export data for all test sessions.

◆ returnExportDataForSession()

QList< TestSessionData > DatabaseManager::returnExportDataForSession ( int  sessionId)

Returns the export data for a specific test session.

This function retrieves and returns a QList<TestSessionData> containing the export data for the test session identified by the provided sessionId.

Parameters
sessionIdThe identifier of the test session to retrieve export data for.
Returns
A QList<TestSessionData> containing the export data for the specified test session.

◆ setupDatabase()

bool DatabaseManager::setupDatabase ( )

Sets up the database. Opens the connection and creates necessary tables.

Returns
true if the database was set up successfully, false otherwise.

◆ updateTestSessionEndTime()

bool DatabaseManager::updateTestSessionEndTime ( int  sessionId)

Updates the end time of a test session record in the database.

Parameters
sessionIdThe ID of the session to be updated.
Returns
true if the record was updated successfully, false otherwise.

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