Participants & Implementation:
Singleton:
– is responsible for creating and storing its own unique instance
– defines an Instance operation that lets clients access its unique instance
The “class level” Instance operation will either return or create and return the sole instance; a “class level” attribute will contain either a default indicating there is no instance yet or the sole instance
Applicability:
– There must be exactly one instance of a class, and it must be accessible to clients from a well-known access point.
– When the sole instance should be extensible by subclassing, and clients should be able to use an extended instance without modifying their code.
Benefits:
– Controlled access to sole instance
– Permits a variable number of instances
Usage in OVM:
· OVM_TOP – instance of ovm_root. Only one instance of ovm_top
· OVM Factory - only one instance of ovm_factory
References:
iii. http://home.gwu.edu/~blankeng/Classes/CSCI253/Class%20page%20(spring%202007).htm
vi. http://www.dofactory.com/Default.aspx
No comments:
Post a Comment