blob: d1631370d814c6a000e08ef8c945828796dd1883 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# Guid class
class Guid:
"Class used to generate unique identifier"
class __impl:
"Singleton class"
def __init__(self):
"Constructor, init reference count"
self.count=0
def newid(self):
"Generate a new id"
self.count = self.count+1
return self.count
__instance=None
def __init__(self):
"Constructor, create Singleton if don't exist"
if Guid.__instance is None:
Guid.__instance = Guid.__impl()
self.__dict__['_Guid__instance'] = Guid.__instance
def __getattr__(self, attr):
"Pass attr retrieving to Singleton"
return getattr(self.__instance, attr)
|