• File: patterns.py
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/tuned/patterns.py
  • Date Modified: 03/21/2019 10:10 PM
  • File size: 335 bytes
  • MIME-type: text/x-script.python
  • Charset: utf-8
class Singleton(object):
	"""
	Singleton design pattern.
	"""

	_instance = None

	def __init__(self):
		if self.__class__ is Singleton:
			raise TypeError("Cannot instantiate directly.")

	@classmethod
	def get_instance(cls):
		"""Get the class instance."""
		if cls._instance is None:
			cls._instance = cls()
		return cls._instance