*Code cleanup in livestatus servicesbygroup
[shinken.git] / shinken / singleton.py
blobbaf54ab36325cb2cb642e21afa34398a9e7fc7b7
1 #!/usr/bin/env python
2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
22 #The classic Singleton class. So all instance of this class will be the same
23 #instance in fact.
25 class Singleton(type):
26 def __init__(cls, name, bases, dict):
27 print "Init de singleton"
28 super(Singleton, cls).__init__(name, bases, dict)
29 cls.instance = None
31 def __call__(cls, *args, **kw):
32 if cls.instance is None:
33 cls.instance = super(Singleton, cls).__call__(*args, **kw)
34 return cls.instance