-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchar_factory.py
More file actions
30 lines (21 loc) · 794 Bytes
/
char_factory.py
File metadata and controls
30 lines (21 loc) · 794 Bytes
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
from char import CharFlyweight
from character import Character
#Singleton implementation of a Character factory for Flyweight pattern implementation
class CharFactory:
__instance = None
'''
desc: Function for creating single point of access.
'''
def __new__(cls):
if cls.__instance is None:
cls.__instance = super().__new__(cls)
return cls.__instance
'''
desc: Function for returning the character flyweight class object for the character fetched based on the unicode
input: Character Unicode
output: Character Flyweight object
'''
def getFlyweight(self,unicode):
unicodeChar = Character.getCharacter(unicode)
flyweightObj = CharFlyweight(unicodeChar)
return flyweightObj