blob: 30905f95241529af561fff020e6dfc934a827452 (
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
28
29
30
31
32
|
# 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, start=None):
"Generate a new id"
if start is None:
self.count = self.count+1
else:
if self.count < start:
self.count = start
return start
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)
|