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

Singleton registry managing active and pending wavelength connections and their associated information. More...

#include <wavelength_registry.h>

Inheritance diagram for WavelengthRegistry:
Collaboration diagram for WavelengthRegistry:

Signals

void activeWavelengthChanged (QString previous_frequency, QString new_frequency)
 Emitted when the active wavelength changes via SetActiveWavelength().
 
void wavelengthAdded (QString frequency)
 Emitted when a new wavelength is successfully added to the registry.
 
void wavelengthRemoved (QString frequency)
 Emitted when a wavelength is successfully removed from the registry.
 
void wavelengthUpdated (QString frequency)
 Emitted when the information for an existing wavelength is updated.
 

Public Member Functions

bool AddPendingRegistration (const QString &frequency)
 Marks a frequency as having a pending registration attempt. Used to prevent duplicate registration attempts while one is in progress.
 
bool AddWavelength (const QString &frequency, const WavelengthInfo &info)
 Adds a new wavelength and its information to the registry. Removes any pending registration for the same frequency. Emits wavelengthAdded signal.
 
void ClearAllWavelengths ()
 Removes all wavelengths and pending registrations from the registry. Sets the active wavelength to "-1".
 
QString GetActiveWavelength () const
 Gets the identifier of the currently active wavelength.
 
QList< QString > GetAllWavelengths () const
 Gets a list of all frequency identifiers currently in the registry.
 
WavelengthInfo GetWavelengthInfo (const QString &frequency) const
 Retrieves the WavelengthInfo for a specific frequency.
 
QPointer< QWebSocket > GetWavelengthSocket (const QString &frequency) const
 Retrieves the WebSocket connection associated with a specific frequency.
 
bool HasWavelength (const QString &frequency) const
 Checks if a wavelength with the given frequency exists in the registry.
 
bool IsPendingRegistration (const QString &frequency) const
 Checks if a frequency is currently marked as having a pending registration.
 
bool IsWavelengthActive (const QString &frequency) const
 Checks if the specified frequency is the currently active one.
 
bool IsWavelengthClosing (const QString &frequency) const
 Checks if a wavelength is currently marked as closing.
 
bool MarkWavelengthClosing (const QString &frequency, bool closing=true)
 Marks or unmarks a wavelength as being in the process of closing.
 
bool RemovePendingRegistration (const QString &frequency)
 Removes a frequency from the pending registration list.
 
bool RemoveWavelength (const QString &frequency)
 Removes a wavelength from the registry. If the removed wavelength was the active one, sets the active wavelength to "-1". Emits wavelengthRemoved signal.
 
void SetActiveWavelength (const QString &frequency)
 Sets the specified frequency as the currently active wavelength. If the frequency does not exist in the registry (and is not "-1"), the operation is ignored. Emits activeWavelengthChanged signal.
 
void SetWavelengthSocket (const QString &frequency, const QPointer< QWebSocket > &socket)
 Sets or updates the WebSocket connection associated with a specific frequency.
 
bool UpdateWavelength (const QString &frequency, const WavelengthInfo &info)
 Updates the information for an existing wavelength. Emits wavelengthUpdated signal.
 

Static Public Member Functions

static WavelengthRegistryGetInstance ()
 Gets the singleton instance of the WavelengthRegistry.
 

Private Member Functions

WavelengthRegistryoperator= (const WavelengthRegistry &)=delete
 Deleted assignment operator to prevent assignment.
 
 WavelengthRegistry (const WavelengthRegistry &)=delete
 Deleted copy constructor to prevent copying.
 
 WavelengthRegistry (QObject *parent=nullptr)
 Private constructor to enforce the singleton pattern. Initializes active_wavelength_ to "-1".
 
 ~WavelengthRegistry () override=default
 Private destructor.
 

Private Attributes

QString active_wavelength_
 The identifier of the currently active wavelength, or "-1" if none is active.
 
QSet< QString > pending_registrations_
 Set storing frequencies for which a registration attempt is currently in progress.
 
QMap< QString, WavelengthInfowavelengths_
 Map storing WavelengthInfo for each registered frequency. Key is the frequency string.
 

Detailed Description

Singleton registry managing active and pending wavelength connections and their associated information.

This class acts as a central repository for all known wavelengths (frequencies) that the application is aware of, either joined, hosted, or pending registration. It stores WavelengthInfo for each frequency and manages the concept of an "active" wavelength. It provides methods for adding, removing, updating, and querying wavelength information and their associated WebSocket connections. It emits signals when the registry state changes.

Constructor & Destructor Documentation

◆ WavelengthRegistry() [1/2]

WavelengthRegistry::WavelengthRegistry ( QObject * parent = nullptr)
inlineexplicitprivate

Private constructor to enforce the singleton pattern. Initializes active_wavelength_ to "-1".

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

◆ ~WavelengthRegistry()

WavelengthRegistry::~WavelengthRegistry ( )
overrideprivatedefault

Private destructor.

◆ WavelengthRegistry() [2/2]

WavelengthRegistry::WavelengthRegistry ( const WavelengthRegistry & )
privatedelete

Deleted copy constructor to prevent copying.

Here is the call graph for this function:

Member Function Documentation

◆ activeWavelengthChanged

void WavelengthRegistry::activeWavelengthChanged ( QString previous_frequency,
QString new_frequency )
signal

Emitted when the active wavelength changes via SetActiveWavelength().

Parameters
previous_frequencyThe identifier of the previously active wavelength ("-1" if none).
new_frequencyThe identifier of the newly active wavelength ("-1" if none).
Here is the caller graph for this function:

◆ AddPendingRegistration()

bool WavelengthRegistry::AddPendingRegistration ( const QString & frequency)

Marks a frequency as having a pending registration attempt. Used to prevent duplicate registration attempts while one is in progress.

Parameters
frequencyThe frequency identifier.
Returns
True if marked successfully, false if the frequency already exists or is already pending.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddWavelength()

bool WavelengthRegistry::AddWavelength ( const QString & frequency,
const WavelengthInfo & info )

Adds a new wavelength and its information to the registry. Removes any pending registration for the same frequency. Emits wavelengthAdded signal.

Parameters
frequencyThe unique identifier for the new wavelength.
infoThe WavelengthInfo struct containing details about the wavelength.
Returns
True if added successfully, false if the frequency already exists.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAllWavelengths()

void WavelengthRegistry::ClearAllWavelengths ( )

Removes all wavelengths and pending registrations from the registry. Sets the active wavelength to "-1".

Here is the call graph for this function:

◆ GetActiveWavelength()

QString WavelengthRegistry::GetActiveWavelength ( ) const
inline

Gets the identifier of the currently active wavelength.

Returns
The frequency string, or "-1" if no wavelength is active.
Here is the caller graph for this function:

◆ GetAllWavelengths()

QList< QString > WavelengthRegistry::GetAllWavelengths ( ) const
inline

Gets a list of all frequency identifiers currently in the registry.

Returns
A QList<QString> containing all known frequencies.

◆ GetInstance()

static WavelengthRegistry * WavelengthRegistry::GetInstance ( )
inlinestatic

Gets the singleton instance of the WavelengthRegistry.

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

◆ GetWavelengthInfo()

WavelengthInfo WavelengthRegistry::GetWavelengthInfo ( const QString & frequency) const

Retrieves the WavelengthInfo for a specific frequency.

Parameters
frequencyThe frequency identifier.
Returns
The WavelengthInfo struct. Returns a default-constructed WavelengthInfo if the frequency is not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWavelengthSocket()

QPointer< QWebSocket > WavelengthRegistry::GetWavelengthSocket ( const QString & frequency) const

Retrieves the WebSocket connection associated with a specific frequency.

Parameters
frequencyThe frequency identifier.
Returns
A QPointer<QWebSocket> to the socket, or nullptr if the frequency doesn't exist or has no socket.
Here is the call graph for this function:

◆ HasWavelength()

bool WavelengthRegistry::HasWavelength ( const QString & frequency) const
inline

Checks if a wavelength with the given frequency exists in the registry.

Parameters
frequencyThe frequency identifier to check.
Returns
True if the wavelength exists, false otherwise.
Here is the caller graph for this function:

◆ IsPendingRegistration()

bool WavelengthRegistry::IsPendingRegistration ( const QString & frequency) const
inline

Checks if a frequency is currently marked as having a pending registration.

Parameters
frequencyThe frequency identifier.
Returns
True if registration is pending, false otherwise.
Here is the caller graph for this function:

◆ IsWavelengthActive()

bool WavelengthRegistry::IsWavelengthActive ( const QString & frequency) const
inline

Checks if the specified frequency is the currently active one.

Parameters
frequencyThe frequency identifier to check.
Returns
True if the given frequency is the active one, false otherwise.

◆ IsWavelengthClosing()

bool WavelengthRegistry::IsWavelengthClosing ( const QString & frequency) const

Checks if a wavelength is currently marked as closing.

Parameters
frequencyThe frequency identifier.
Returns
True if marked as closing, false otherwise or if the frequency doesn't exist.
Here is the call graph for this function:

◆ MarkWavelengthClosing()

bool WavelengthRegistry::MarkWavelengthClosing ( const QString & frequency,
bool closing = true )

Marks or unmarks a wavelength as being in the process of closing.

Parameters
frequencyThe frequency identifier.
closingTrue to mark as closing, false otherwise.
Returns
True if the status was updated, false if the frequency does not exist.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

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

Deleted assignment operator to prevent assignment.

Here is the call graph for this function:

◆ RemovePendingRegistration()

bool WavelengthRegistry::RemovePendingRegistration ( const QString & frequency)

Removes a frequency from the pending registration list.

Parameters
frequencyThe frequency identifier.
Returns
True if removed successfully, false if it was not pending.
Here is the caller graph for this function:

◆ RemoveWavelength()

bool WavelengthRegistry::RemoveWavelength ( const QString & frequency)

Removes a wavelength from the registry. If the removed wavelength was the active one, sets the active wavelength to "-1". Emits wavelengthRemoved signal.

Parameters
frequencyThe identifier of the wavelength to remove.
Returns
True if removed successfully, false if the frequency does not exist.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetActiveWavelength()

void WavelengthRegistry::SetActiveWavelength ( const QString & frequency)

Sets the specified frequency as the currently active wavelength. If the frequency does not exist in the registry (and is not "-1"), the operation is ignored. Emits activeWavelengthChanged signal.

Parameters
frequencyThe frequency identifier to set as active, or "-1" for none.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetWavelengthSocket()

void WavelengthRegistry::SetWavelengthSocket ( const QString & frequency,
const QPointer< QWebSocket > & socket )

Sets or updates the WebSocket connection associated with a specific frequency.

Parameters
frequencyThe frequency identifier.
socketA QPointer<QWebSocket> to the socket.
Here is the call graph for this function:

◆ UpdateWavelength()

bool WavelengthRegistry::UpdateWavelength ( const QString & frequency,
const WavelengthInfo & info )

Updates the information for an existing wavelength. Emits wavelengthUpdated signal.

Parameters
frequencyThe identifier of the wavelength to update.
infoThe new WavelengthInfo struct.
Returns
True if updated successfully, false if the frequency does not exist.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wavelengthAdded

void WavelengthRegistry::wavelengthAdded ( QString frequency)
signal

Emitted when a new wavelength is successfully added to the registry.

Parameters
frequencyThe identifier of the added wavelength.
Here is the caller graph for this function:

◆ wavelengthRemoved

void WavelengthRegistry::wavelengthRemoved ( QString frequency)
signal

Emitted when a wavelength is successfully removed from the registry.

Parameters
frequencyThe identifier of the removed wavelength.
Here is the caller graph for this function:

◆ wavelengthUpdated

void WavelengthRegistry::wavelengthUpdated ( QString frequency)
signal

Emitted when the information for an existing wavelength is updated.

Parameters
frequencyThe identifier of the updated wavelength.
Here is the caller graph for this function:

Member Data Documentation

◆ active_wavelength_

QString WavelengthRegistry::active_wavelength_
private

The identifier of the currently active wavelength, or "-1" if none is active.

◆ pending_registrations_

QSet<QString> WavelengthRegistry::pending_registrations_
private

Set storing frequencies for which a registration attempt is currently in progress.

◆ wavelengths_

QMap<QString, WavelengthInfo> WavelengthRegistry::wavelengths_
private

Map storing WavelengthInfo for each registered frequency. Key is the frequency string.


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