1#ifndef WAVELENGTH_REGISTRY_H
2#define WAVELENGTH_REGISTRY_H
27 QPointer<QWebSocket>
socket =
nullptr;
WavelengthInfo GetWavelengthInfo(const QString &frequency) const
Retrieves the WavelengthInfo for a specific frequency.
Definition wavelength_registry.cpp:37
void wavelengthAdded(QString frequency)
Emitted when a new wavelength is successfully added to the registry.
bool RemoveWavelength(const QString &frequency)
Removes a wavelength from the registry. If the removed wavelength was the active one,...
Definition wavelength_registry.cpp:21
void wavelengthRemoved(QString frequency)
Emitted when a wavelength is successfully removed from the registry.
QString active_wavelength_
The identifier of the currently active wavelength, or "-1" if none is active.
Definition wavelength_registry.h:241
~WavelengthRegistry() override=default
Private destructor.
bool UpdateWavelength(const QString &frequency, const WavelengthInfo &info)
Updates the information for an existing wavelength. Emits wavelengthUpdated signal.
Definition wavelength_registry.cpp:44
void SetActiveWavelength(const QString &frequency)
Sets the specified frequency as the currently active wavelength. If the frequency does not exist in t...
Definition wavelength_registry.cpp:57
void wavelengthUpdated(QString frequency)
Emitted when the information for an existing wavelength is updated.
bool RemovePendingRegistration(const QString &frequency)
Removes a frequency from the pending registration list.
Definition wavelength_registry.cpp:80
WavelengthRegistry(QObject *parent=nullptr)
Private constructor to enforce the singleton pattern. Initializes active_wavelength_ to "-1".
Definition wavelength_registry.h:222
WavelengthRegistry & operator=(const WavelengthRegistry &)=delete
Deleted assignment operator to prevent assignment.
QSet< QString > pending_registrations_
Set storing frequencies for which a registration attempt is currently in progress.
Definition wavelength_registry.h:239
QString GetActiveWavelength() const
Gets the identifier of the currently active wavelength.
Definition wavelength_registry.h:119
QList< QString > GetAllWavelengths() const
Gets a list of all frequency identifiers currently in the registry.
Definition wavelength_registry.h:94
bool IsWavelengthActive(const QString &frequency) const
Checks if the specified frequency is the currently active one.
Definition wavelength_registry.h:128
static WavelengthRegistry * GetInstance()
Gets the singleton instance of the WavelengthRegistry.
Definition wavelength_registry.h:51
QMap< QString, WavelengthInfo > wavelengths_
Map storing WavelengthInfo for each registered frequency. Key is the frequency string.
Definition wavelength_registry.h:237
bool IsWavelengthClosing(const QString &frequency) const
Checks if a wavelength is currently marked as closing.
Definition wavelength_registry.cpp:110
bool HasWavelength(const QString &frequency) const
Checks if a wavelength with the given frequency exists in the registry.
Definition wavelength_registry.h:79
void SetWavelengthSocket(const QString &frequency, const QPointer< QWebSocket > &socket)
Sets or updates the WebSocket connection associated with a specific frequency.
Definition wavelength_registry.cpp:95
void ClearAllWavelengths()
Removes all wavelengths and pending registrations from the registry. Sets the active wavelength to "-...
Definition wavelength_registry.cpp:117
bool AddPendingRegistration(const QString &frequency)
Marks a frequency as having a pending registration attempt. Used to prevent duplicate registration at...
Definition wavelength_registry.cpp:69
void activeWavelengthChanged(QString previous_frequency, QString new_frequency)
Emitted when the active wavelength changes via SetActiveWavelength().
WavelengthRegistry(const WavelengthRegistry &)=delete
Deleted copy constructor to prevent copying.
bool IsPendingRegistration(const QString &frequency) const
Checks if a frequency is currently marked as having a pending registration.
Definition wavelength_registry.h:152
bool MarkWavelengthClosing(const QString &frequency, bool closing=true)
Marks or unmarks a wavelength as being in the process of closing.
Definition wavelength_registry.cpp:101
QPointer< QWebSocket > GetWavelengthSocket(const QString &frequency) const
Retrieves the WebSocket connection associated with a specific frequency.
Definition wavelength_registry.cpp:88
bool AddWavelength(const QString &frequency, const WavelengthInfo &info)
Adds a new wavelength and its information to the registry. Removes any pending registration for the s...
Definition wavelength_registry.cpp:5
Structure holding information about a specific wavelength (frequency).
Definition wavelength_registry.h:13
bool is_host
True if the current user is the host of this wavelength.
Definition wavelength_registry.h:23
QString frequency
The unique identifier (name) of the wavelength.
Definition wavelength_registry.h:15
int host_port
The port number the host is listening on.
Definition wavelength_registry.h:25
QString host_id
The unique client ID of the user hosting the wavelength.
Definition wavelength_registry.h:21
bool is_password_protected
True if the wavelength requires a password to join.
Definition wavelength_registry.h:17
QPointer< QWebSocket > socket
QPointer to the WebSocket connection associated with this wavelength. Automatically nullifies if the ...
Definition wavelength_registry.h:27
QString password
The password for the wavelength (if protected).
Definition wavelength_registry.h:19
bool is_closing
Flag indicating if the wavelength is currently in the process of being closed.
Definition wavelength_registry.h:29
QDateTime created_at
Timestamp when this wavelength information was created or added to the registry locally.
Definition wavelength_registry.h:31