Public Member Functions | |
obj | instance () |
v | get_Data (type obj) |
Public Access. | |
void | set_Data (type obj, type singletonData) |
v get | Data (type obj) |
end1 | |
void set | Data (type obj, type singletonData) |
v | showsTripleDot (type obj, type x_) |
end1 | |
obj | instance () |
v | get_Data (type obj) |
Public Access. | |
void | set_Data (type obj, type singletonData) |
v get | Data (type obj) |
end1 | |
void set | Data (type obj, type singletonData) |
v | showsTripleDot (type obj, type x_) |
end1 | |
v | showsTripleDot1 (type obj, type x_) |
void | update (type obj, type returner) |
Public Attributes | |
type | Data = [] |
Unique properties of singleton. This can be only accessed with the getter/setter methods via any subclass of singleton.
Definition at line 4 of file t.cpp.
void set singleton::Data | ( | type | obj, | |
type | singletonData | |||
) | [inline] |
Definition at line 73 of file tsingleton.m.
v get singleton::Data | ( | type | obj | ) | [inline] |
end1
Definition at line 69 of file tsingleton.m.
void set singleton::Data | ( | type | obj, | |
type | singletonData | |||
) | [inline] |
v get singleton::Data | ( | type | obj | ) | [inline] |
v singleton::get_Data | ( | type | obj | ) | [inline] |
Public Access.
Definition at line 61 of file tsingleton.m.
obj singleton::instance | ( | ) |
This method serves as the global point of access in creating a single instance *or* acquiring a reference to the singleton. If the object doesn't exist, create it otherwise return the existing one in persistent memory. Input: <none> Output: obj = reference to a persistent instance of the classix
obj singleton::instance | ( | ) |
This method serves as the global point of access in creating a single instance *or* acquiring a reference to the singleton. If the object doesn't exist, create it otherwise return the existing one in persistent memory. Input: <none> Output: obj = reference to a persistent instance of the classix
void singleton::set_Data | ( | type | obj, | |
type | singletonData | |||
) | [inline] |
Definition at line 65 of file tsingleton.m.
void singleton::set_Data | ( | type | obj, | |
type | singletonData | |||
) | [inline] |
v singleton::showsTripleDot | ( | type | obj, | |
type | x_ | |||
) | [inline] |
end1
And the if .. end issue.
s
', ...
f > calibrated f
', ...
Definition at line 78 of file tsingleton.m.
v singleton::showsTripleDot | ( | type | obj, | |
type | x_ | |||
) | [inline] |
v singleton::showsTripleDot1 | ( | type | obj, | |
type | x_ | |||
) | [inline] |
Definition at line 100 of file tsingleton.m.
void singleton::update | ( | type | obj, | |
type | returner | |||
) |
type singleton::Data = [] |
SINGLETON Abstract Class for singleton OOP Design Pattern Intent: Ensures a class only has one instance and provide a global point of access to it [1]. Motivation: It's important for some classes to have exactly one instance. For example, it can be desirable to have only a single instance of a GUI. With a MATLAB GUIDE built GUI, the driver or main function provides a global point of access which is executed to, 1. initially instantiate the GUI; and 2. subsequently bring the existing GUI into focus *not* creating a new one. Implementation: MATLAB OOP doesn't have the notion of static properties. Properties become available once the constructor of the class is invoked. In the case of the singleton Pattern, it is then undesirable to use the constructor as a global point of access since it creates a new instance before you can check if an instance already exists. The solution is to use a persistent variable within a unique static method instance() which calls the constructor to create a unique 'singleton' instance. The persistent variable can be interrogated prior to object creation and after object creation to check if the singleton object exists. There are two conditions that all subclasses must satisfy: 1. Constructor must be hidden from the user (Access=private). 2. The concrete implementation of instance() must use a persistent variable to store the unique instance of the subclass.
Refer to pp.127-134 Gamma et al.[1] for more information on the singleton Design Pattern.
Written by Bobby Nedelkovski The MathWorks Australia Pty Ltd Copyright 2009, The MathWorks, Inc.
Reference: [1] Gamma, E., Helm, R., Johnson, R. and Vlissides, J. Design Patterns : Elements of Reusable Object-Oriented Software. Boston: Addison-Wesley, 1995.