|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
Singleton registry managing active and pending wavelength connections and their associated information. More...
#include <wavelength_registry.h>
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 WavelengthRegistry * | GetInstance () |
| Gets the singleton instance of the WavelengthRegistry. | |
Private Member Functions | |
| WavelengthRegistry & | operator= (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, WavelengthInfo > | wavelengths_ |
| Map storing WavelengthInfo for each registered frequency. Key is the frequency string. | |
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.
|
inlineexplicitprivate |
Private constructor to enforce the singleton pattern. Initializes active_wavelength_ to "-1".
| parent | Optional parent QObject. |
|
overrideprivatedefault |
Private destructor.
|
privatedelete |
Deleted copy constructor to prevent copying.
|
signal |
Emitted when the active wavelength changes via SetActiveWavelength().
| previous_frequency | The identifier of the previously active wavelength ("-1" if none). |
| new_frequency | The identifier of the newly active wavelength ("-1" if none). |
| 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.
| frequency | The frequency identifier. |
| 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.
| frequency | The unique identifier for the new wavelength. |
| info | The WavelengthInfo struct containing details about the wavelength. |
| void WavelengthRegistry::ClearAllWavelengths | ( | ) |
Removes all wavelengths and pending registrations from the registry. Sets the active wavelength to "-1".
|
inline |
Gets the identifier of the currently active wavelength.
|
inline |
Gets a list of all frequency identifiers currently in the registry.
|
inlinestatic |
Gets the singleton instance of the WavelengthRegistry.
| WavelengthInfo WavelengthRegistry::GetWavelengthInfo | ( | const QString & | frequency | ) | const |
Retrieves the WavelengthInfo for a specific frequency.
| frequency | The frequency identifier. |
| QPointer< QWebSocket > WavelengthRegistry::GetWavelengthSocket | ( | const QString & | frequency | ) | const |
Retrieves the WebSocket connection associated with a specific frequency.
| frequency | The frequency identifier. |
|
inline |
Checks if a wavelength with the given frequency exists in the registry.
| frequency | The frequency identifier to check. |
|
inline |
Checks if a frequency is currently marked as having a pending registration.
| frequency | The frequency identifier. |
|
inline |
Checks if the specified frequency is the currently active one.
| frequency | The frequency identifier to check. |
| bool WavelengthRegistry::IsWavelengthClosing | ( | const QString & | frequency | ) | const |
Checks if a wavelength is currently marked as closing.
| frequency | The frequency identifier. |
| bool WavelengthRegistry::MarkWavelengthClosing | ( | const QString & | frequency, |
| bool | closing = true ) |
Marks or unmarks a wavelength as being in the process of closing.
| frequency | The frequency identifier. |
| closing | True to mark as closing, false otherwise. |
|
privatedelete |
Deleted assignment operator to prevent assignment.
| bool WavelengthRegistry::RemovePendingRegistration | ( | const QString & | frequency | ) |
Removes a frequency from the pending registration list.
| frequency | The frequency identifier. |
| 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.
| frequency | The identifier of the wavelength to remove. |
| 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.
| frequency | The frequency identifier to set as active, or "-1" for none. |
| void WavelengthRegistry::SetWavelengthSocket | ( | const QString & | frequency, |
| const QPointer< QWebSocket > & | socket ) |
Sets or updates the WebSocket connection associated with a specific frequency.
| frequency | The frequency identifier. |
| socket | A QPointer<QWebSocket> to the socket. |
| bool WavelengthRegistry::UpdateWavelength | ( | const QString & | frequency, |
| const WavelengthInfo & | info ) |
Updates the information for an existing wavelength. Emits wavelengthUpdated signal.
| frequency | The identifier of the wavelength to update. |
| info | The new WavelengthInfo struct. |
|
signal |
Emitted when a new wavelength is successfully added to the registry.
| frequency | The identifier of the added wavelength. |
|
signal |
Emitted when a wavelength is successfully removed from the registry.
| frequency | The identifier of the removed wavelength. |
|
signal |
Emitted when the information for an existing wavelength is updated.
| frequency | The identifier of the updated wavelength. |
|
private |
The identifier of the currently active wavelength, or "-1" if none is active.
|
private |
Set storing frequencies for which a registration attempt is currently in progress.
|
private |
Map storing WavelengthInfo for each registered frequency. Key is the frequency string.