radioviz.services.singleton

Singleton pattern implementation for RadioViz application.

This module provides a decorator for implementing the singleton pattern, ensuring that only one instance of a class is ever created.

Functions

singleton(cls)

Decorator to make a class a singleton.

class radioviz.services.singleton._SingletonWrapper(cls: Type[T])[source]

Bases: Generic[T]

Wrapper class that implements the singleton pattern logic.

This internal class handles the creation and management of singleton instances for decorated classes. It ensures that only one instance is created and returned on subsequent calls.

Initialize the singleton wrapper.

Parameters:

cls (type) – The class to be wrapped as a singleton

radioviz.services.singleton.singleton(cls: Type[T]) _SingletonWrapper[T][source]

Decorator to make a class a singleton.

This function takes a class and returns a singleton wrapper that ensures only one instance of the class will ever be created.

Parameters:

cls (type) – The class to be converted into a singleton

Returns:

A singleton wrapper for the given class

Return type:

_SingletonWrapper