ATLAS Offline Software
Public Member Functions | Static Private Attributes | List of all members
python.decorators.singleton.Singleton Class Reference

Metaclass for implementing the Singleton pattern. More...

Inheritance diagram for python.decorators.singleton.Singleton:
Collaboration diagram for python.decorators.singleton.Singleton:

Public Member Functions

def __call__ (cls, *args, **kwargs)
 Retrieve the singleton instance, creating if necessary. More...
 

Static Private Attributes

dictionary _instances = {}
 

Detailed Description

Metaclass for implementing the Singleton pattern.

Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 3 of file singleton.py.

Member Function Documentation

◆ __call__()

def python.decorators.singleton.Singleton.__call__ (   cls,
args,
**  kwargs 
)

Retrieve the singleton instance, creating if necessary.

Definition at line 11 of file singleton.py.

11  def __call__(cls, *args, **kwargs):
12  """! Retrieve the singleton instance, creating if necessary."""
13  if cls not in cls._instances:
14  cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
15  return cls._instances[cls]

Member Data Documentation

◆ _instances

dictionary python.decorators.singleton.Singleton._instances = {}
staticprivate

Definition at line 9 of file singleton.py.


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