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

Manages temporary storage of attachment data using a singleton pattern. More...

#include <attachment_data_store.h>

Collaboration diagram for AttachmentDataStore:

Public Member Functions

QString GetAttachmentData (const QString &attachment_id)
 Retrieves the base64-encoded attachment data associated with a given ID. This operation is thread-safe.
 
void RemoveAttachmentData (const QString &attachment_id)
 Removes the attachment data associated with the given ID from the store. Used to free up memory once the attachment data is no longer needed. This operation is thread-safe.
 
QString StoreAttachmentData (const QString &base64_data)
 Stores base64-encoded attachment data and returns a unique ID. Generates a UUID for the attachment and stores the data in the internal map. This operation is thread-safe.
 

Static Public Member Functions

static AttachmentDataStoreGetInstance ()
 Gets the singleton instance of the AttachmentDataStore.
 

Private Member Functions

 AttachmentDataStore ()=default
 Private default constructor to enforce the singleton pattern.
 
 AttachmentDataStore (const AttachmentDataStore &)=delete
 Deleted copy constructor to prevent copying.
 
AttachmentDataStoreoperator= (const AttachmentDataStore &)=delete
 Deleted assignment operator to prevent assignment.
 

Private Attributes

QMap< QString, QString > attachment_data_ {}
 Map storing the attachment data. Key: Attachment ID (QString UUID). Value: Base64-encoded attachment data (QString).
 
QMutex mutex_ {}
 Mutex ensuring thread-safe access to the attachment_data_ map.
 

Detailed Description

Manages temporary storage of attachment data using a singleton pattern.

This class provides a thread-safe, in-memory store for holding base64-encoded attachment data associated with unique IDs. It's used to temporarily hold attachment content before it's fully processed or sent.

Constructor & Destructor Documentation

◆ AttachmentDataStore() [1/2]

AttachmentDataStore::AttachmentDataStore ( )
privatedefault

Private default constructor to enforce the singleton pattern.

Here is the caller graph for this function:

◆ AttachmentDataStore() [2/2]

AttachmentDataStore::AttachmentDataStore ( const AttachmentDataStore & )
privatedelete

Deleted copy constructor to prevent copying.

Here is the call graph for this function:

Member Function Documentation

◆ GetAttachmentData()

QString AttachmentDataStore::GetAttachmentData ( const QString & attachment_id)

Retrieves the base64-encoded attachment data associated with a given ID. This operation is thread-safe.

Parameters
attachment_idThe unique identifier of the attachment data to retrieve.
Returns
The base64-encoded QString data if the ID exists, otherwise an empty QString.
Here is the caller graph for this function:

◆ GetInstance()

static AttachmentDataStore * AttachmentDataStore::GetInstance ( )
inlinestatic

Gets the singleton instance of the AttachmentDataStore.

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

◆ operator=()

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

Deleted assignment operator to prevent assignment.

Here is the call graph for this function:

◆ RemoveAttachmentData()

void AttachmentDataStore::RemoveAttachmentData ( const QString & attachment_id)

Removes the attachment data associated with the given ID from the store. Used to free up memory once the attachment data is no longer needed. This operation is thread-safe.

Parameters
attachment_idThe unique identifier of the attachment data to remove.

◆ StoreAttachmentData()

QString AttachmentDataStore::StoreAttachmentData ( const QString & base64_data)

Stores base64-encoded attachment data and returns a unique ID. Generates a UUID for the attachment and stores the data in the internal map. This operation is thread-safe.

Parameters
base64_dataThe attachment data encoded as a base64 QString.
Returns
A unique QString identifier (UUID without braces) for the stored data.
Here is the caller graph for this function:

Member Data Documentation

◆ attachment_data_

QMap<QString, QString> AttachmentDataStore::attachment_data_ {}
private

Map storing the attachment data. Key: Attachment ID (QString UUID). Value: Base64-encoded attachment data (QString).

◆ mutex_

QMutex AttachmentDataStore::mutex_ {}
private

Mutex ensuring thread-safe access to the attachment_data_ map.


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