Skip to content
Snippets Groups Projects
Commit 7cf4ab44 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

Added Singleton pattern

parent a5d0eb19
No related branches found
No related tags found
No related merge requests found
...@@ -237,6 +237,13 @@ class SpatialExtent(QgsRectangle): ...@@ -237,6 +237,13 @@ class SpatialExtent(QgsRectangle):
return '{} {} {}'.format(self.upperLeft(), self.lowerRight(), self.crs().authid()) return '{} {} {}'.format(self.upperLeft(), self.lowerRight(), self.crs().authid())
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwds):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args,**kwds)
return cls._instances[cls]
class KeepRefs(object): class KeepRefs(object):
__refs__ = defaultdict(list) __refs__ = defaultdict(list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment