ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
Handle.m
Go to the documentation of this file.
1%> \brief
2%> This is the base class for generating
3%> subclass of MATLAB ``handle`` superclass whose annoying
4%> methods are forcefully hidden from the user view.<br>
5%>
6%> \interface{Handle}
7%> \code{.m}
8%>
9%> Handle = pm.matlab.Handle()
10%>
11%> \endcode
12%>
13%> \example{Handle}
14%> \include{lineno} example/matlab/Handle/main.m
15%> \output{Handle}
16%> \include{lineno} example/matlab/Handle/main.out.m
17%>
18%> \final{Handle}
19%>
20%> \author
21%> \JoshuaOsborne, May 21 2024, 11:31 PM, University of Texas at Arlington<br>
22%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
23%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
24classdef Handle < dynamicprops%handle
25
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 methods(Access = public)
29 %> \brief
30 %> Open the documentation of the class
31 %> of the parent object on MATLAB display.
32 %>
33 %> \details
34 %> This is a dynamic method of the class [pm.matlab.Handle](@ref Handle).
35 %>
36 %> \interface{doc}
37 %> \code{.m}
38 %>
39 %> h = pm.matlab.Handle();
40 %> h.doc();
41 %>
42 %> \endcode
43 %>
44 %> \final{doc}
45 %>
46 %> \author
47 %> \JoshuaOsborne, May 21 2024, 11:34 PM, University of Texas at Arlington<br>
48 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
49 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
50 function doc(self)
51 doc(class(self));
52 end
53 end
54
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
57 methods(Access = public)
58 %> \brief
59 %> Print help about the class of
60 %> the parent object on MATLAB display.
61 %>
62 %> \details
63 %> This is a dynamic method of the class [pm.matlab.Handle](@ref Handle).
64 %>
65 %> \interface{help}
66 %> \code{.m}
67 %>
68 %> self.help()
69 %>
70 %> \endcode
71 %>
72 %> \final{help}
73 %>
74 %> \author
75 %> \JoshuaOsborne, May 21 2024, 11:36 PM, University of Texas at Arlington<br>
76 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
77 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
78 function help(self)
79 help(class(self));
80 end
81 end
82
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84
85 methods(Access = public, Hidden)
86 function hash2comp(self, hash)
87 hashlen = length(hash);
88 selfProp = string(properties(self));
89 selfPropLen = length(selfProp);
90 insensitive = true;
91 extensible = true;
92 recursive = true;
93 for i = 1 : 2 : hashlen % walk through input key val.
94 propertyDoesNotExist = true;
95 hashItemString = string(hash{i});
96 for ip = 1 : selfPropLen % walk through object prop val.
97 if strcmpi(hashItemString, selfProp(ip))
98 propertyDoesNotExist = false;
99 if i < hashlen % this must be here. checks for the correct pairing of key, val.
100 if isa(hash{i + 1}, "cell") && (isstruct(self.(selfProp(ip))) || isa(self.(selfProp(ip)), "handle") || ~isempty(properties(self.(selfProp(ip)))))
101 self.(selfProp(ip)) = pm.matlab.hashmap.hash2comp(hash{i + 1}, self.(selfProp(ip)), insensitive, extensible, recursive);
102 else
103 self.(selfProp(ip)) = hash{i + 1};
104 end
105 else
106 error("The corresponding value for the property """ + string(selfProp(ip)) + """ is missing as input argument.");
107 end
108 break;
109 end
110 end
111 if propertyDoesNotExist
112 disp("hash{i}");
113 disp( hash{i} );
114 error("The requested object property displayed above does not exist:");
115 end
116 end
117 end
118 end
119
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121
122 methods(Access = public, Hidden)
123 function setKeyVal(self, field, key, val)
124 if nargin < 4
125 if isempty(self.(field))
126 self.(field) = key;
127 end
128 else
129 if ~isfield(self.(field), key) || isempty(self.(field).(key))
130 self.(field).(key) = val;
131 end
132 end
133 end
134 end
135
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137
138 methods(Access = public, Hidden)
139 function newprop(self, prop, val)
140 if ~any(strcmp(properties(self), prop))
141 self.addprop(prop);
142 end
143 if 2 < nargin
144 self.(prop) = val;
145 end
146 end
147 end
148
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150
151 %> \cond excluded
152
153 methods(Access = public, Hidden)
154 function lh = addlistener(varargin)
155 lh = addlistener@handle(varargin{:});
156 end
157 function lh = listener(varargin)
158 lh = listener@handle(varargin{:});
159 end
160 function notify(varargin)
161 notify@handle(varargin{:});
162 end
163 function delete(varargin)
164 delete@handle(varargin{:});
165 end
166 function Hmatch = findobj(varargin)
167 Hmatch = findobj@handle(varargin{:});
168 end
169 function p = findprop(varargin)
170 p = findprop@handle(varargin{:});
171 end
172 function TF = eq(varargin)
173 TF = eq@handle(varargin{:});
174 end
175 function TF = ne(varargin)
176 TF = ne@handle(varargin{:});
177 end
178 function TF = lt(varargin)
179 TF = lt@handle(varargin{:});
180 end
181 function TF = le(varargin)
182 TF = le@handle(varargin{:});
183 end
184 function TF = gt(varargin)
185 TF = gt@handle(varargin{:});
186 end
187 function TF = ge(varargin)
188 TF = ge@handle(varargin{:});
189 end
190 %function TF = isvalid(varargin)
191 % TF = isvalid@handle(varargin{:});
192 %end
193 end
194
195 %> \endcond excluded
196
197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198
199end
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
Definition: Handle.m:24
function newprop(in self, in prop, in val)
function doc(in self)
Open the documentation of the class of the parent object on MATLAB display.
function help(in self)
Print help about the class of the parent object on MATLAB display.
function hash2comp(in self, in hash)
function setKeyVal(in self, in field, in key, in val)
function hash2comp(in hashmap, in object, in insensitive, in extensible, in recursive)
Return a copy of the input object whose property (or field) values are overwritten with the correspon...
excluded
Definition: show.m:173