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 %> \param[inout] self : The **implicitly-passed** input argument representing the parent object of the method.<br>
37 %>
38 %> \interface{doc}
39 %> \code{.m}
40 %>
41 %> h = pm.matlab.Handle();
42 %> h.doc();
43 %>
44 %> \endcode
45 %>
46 %> \final{doc}
47 %>
48 %> \author
49 %> \JoshuaOsborne, May 21 2024, 11:34 PM, University of Texas at Arlington<br>
50 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
51 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
52 function doc(self)
53 doc(class(self));
54 end
55 end
56
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58
59 methods(Access = public)
60 %> \brief
61 %> Print help about the class of
62 %> the parent object on MATLAB display.
63 %>
64 %> \details
65 %> This is a dynamic method of the class [pm.matlab.Handle](@ref Handle).
66 %>
67 %> \interface{help}
68 %> \code{.m}
69 %>
70 %> self.help()
71 %>
72 %> \endcode
73 %>
74 %> \final{help}
75 %>
76 %> \author
77 %> \JoshuaOsborne, May 21 2024, 11:36 PM, University of Texas at Arlington<br>
78 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
79 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
80 function help(self)
81 help(class(self));
82 end
83 end
84
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87 methods(Access = public, Hidden)
88 function hash2comp(self, hash)
89 hashlen = length(hash);
90 selfProp = string(properties(self));
91 selfPropLen = length(selfProp);
92 insensitive = true;
93 extensible = true;
94 recursive = true;
95 for i = 1 : 2 : hashlen % walk through input key val.
96 propertyDoesNotExist = true;
97 hashItemString = string(hash{i});
98 for ip = 1 : selfPropLen % walk through object prop val.
99 if strcmpi(hashItemString, selfProp(ip))
100 propertyDoesNotExist = false;
101 if i < hashlen % this must be here. checks for the correct pairing of key, val.
102 if isa(hash{i + 1}, "cell") && (isstruct(self.(selfProp(ip))) || isa(self.(selfProp(ip)), "handle") || ~isempty(properties(self.(selfProp(ip)))))
103 self.(selfProp(ip)) = pm.matlab.hashmap.hash2comp(hash{i + 1}, self.(selfProp(ip)), insensitive, extensible, recursive);
104 else
105 self.(selfProp(ip)) = hash{i + 1};
106 end
107 else
108 error("The corresponding value for the property """ + string(selfProp(ip)) + """ is missing as input argument.");
109 end
110 break;
111 end
112 end
113 if propertyDoesNotExist
114 disp("hash{i}");
115 disp( hash{i} );
116 error("The requested object property displayed above does not exist:");
117 end
118 end
119 end
120 end
121
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123
124 methods(Access = public, Hidden)
125 function setKeyVal(self, field, subfield, key, val)
126 if nargin < 4
127 if ~(isfield(self, field) || isprop(self, field)) || isempty(self.(field))
128 self.(field) = subfield;
129 end
130 elseif nargin < 5
131 if ~(isfield(self.(field), subfield) || isprop(self.(field), subfield)) || isempty(self.(field).(subfield))
132 self.(field).(subfield) = key;
133 end
134 else
135 if ~(isfield(self.(field).(subfield), key) || isprop(self.(field).(subfield), key)) || isempty(self.(field).(subfield).(key))
136 self.(field).(subfield).(key) = val;
137 end
138 end
139 end
140 end
141
142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143
144 methods(Access = public, Hidden)
145 function newprop(self, prop, val)
146 if ~any(strcmp(properties(self), prop))
147 self.addprop(prop);
148 end
149 if 2 < nargin
150 self.(prop) = val;
151 end
152 end
153 end
154
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156
157 %> \cond excluded
158
159 methods(Access = public, Hidden)
160 function lh = addlistener(varargin)
161 lh = addlistener@handle(varargin{:});
162 end
163 function lh = listener(varargin)
164 lh = listener@handle(varargin{:});
165 end
166 function notify(varargin)
167 notify@handle(varargin{:});
168 end
169 function delete(varargin)
170 delete@handle(varargin{:});
171 end
172 function Hmatch = findobj(varargin)
173 Hmatch = findobj@handle(varargin{:});
174 end
175 function p = findprop(varargin)
176 p = findprop@handle(varargin{:});
177 end
178 function TF = eq(varargin)
179 TF = eq@handle(varargin{:});
180 end
181 function TF = ne(varargin)
182 TF = ne@handle(varargin{:});
183 end
184 function TF = lt(varargin)
185 TF = lt@handle(varargin{:});
186 end
187 function TF = le(varargin)
188 TF = le@handle(varargin{:});
189 end
190 function TF = gt(varargin)
191 TF = gt@handle(varargin{:});
192 end
193 function TF = ge(varargin)
194 TF = ge@handle(varargin{:});
195 end
196 %function TF = isvalid(varargin)
197 % TF = isvalid@handle(varargin{:});
198 %end
199 end
200
201 %> \endcond excluded
202
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204
205end
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 subfield, 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