ATLAS Offline Software
singleton.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 class Singleton(type):
4  """! Metaclass for implementing the Singleton pattern.
5 
6  @author James Robinson <james.robinson@cern.ch>
7  """
8 
9  _instances = {}
10 
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]
python.decorators.singleton.Singleton._instances
dictionary _instances
Definition: singleton.py:9
python.decorators.singleton.Singleton.__call__
def __call__(cls, *args, **kwargs)
Retrieve the singleton instance, creating if necessary.
Definition: singleton.py:11
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.decorators.singleton.Singleton
Metaclass for implementing the Singleton pattern.
Definition: singleton.py:3