ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
DataRef.m
Go to the documentation of this file.
1%> \brief
2%> This is the abstract class for generating instances of objects
3%> that can contain basic attributes required for storing reference
4%> to a given data.<br>
5%>
6%> \details
7%> This class is merely a convenience read-only
8%> wrapper to reference external data.<br>
9%>
10%> \remark
11%> See the constructor documentation for example usage.<br>
12%>
13%> \note
14%> This class primarily exist to facilitate bypassing
15%> the lack of references and pointers in MATLAB.<br>
16%>
17%> \see
18%> [DataFrame](@ref DataFrame)<br>
19%>
20%> \final
21%>
22%> \author
23%> \JoshuaOsborne, May 21 2024, 4:45 PM, University of Texas at Arlington<br>
24%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
25%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
26classdef DataRef < pm.matlab.Handle
27
28 properties(Access = protected, Hidden)
29 %>
30 %> ``dfref``
31 %>
32 %> A ``protected`` and ``Hidden`` copy of the user-specified
33 %> input data (or its handle) ``dfref`` to the class constructor.<br>
34 %> This is an exact copy of the user-specified function handle or data.<br>
35 %> Users are supposed to access this component only via the class
36 %> method [pm.container.DataRef.copy()](@ref DataRef::copy).<br>
37 %>
38 dfref;
39 end
40
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43 methods(Access = public)
44
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46
47 %> \brief
48 %> Generate an return an object of class [DataRef](pm.container.DataRef)
49 %> from the input dataframe or its specified input reference.<br>
50 %>
51 %> \param[in] dfref : The input object containing the target dataset
52 %> or function handle that takes no arguments and returns the dataset.<br>
53 %> Specifying a function handle is superior to specifying the dataset
54 %> directly, because the function handle will always allow the use of
55 %> the most updated version of the user table or matrix.<br>
56 %> (**optional**. default = ``[]``)
57 %>
58 %> \return
59 %> ``self`` : The output scalar object of class [pm.container.DataRef](@ref DataRef).
60 %>
61 %> \interface{DataRef}
62 %> \code{.m}
63 %>
64 %> df = pm.container.DataRef(dfref);
65 %>
66 %> \endcode
67 %>
68 %> \example{DataRef}
69 %> \include{lineno} example/container/DataRef/main.m
70 %> \output{DataRef}
71 %> \include{lineno} example/container/DataRef/main.out.m
72 %>
73 %> \final{DataRef}
74 %>
75 %> \author
76 %> \AmirShahmoradi, Tuesday March 7, 2017, 7:03 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin<br>
77 function self = DataRef(dfref)
78 if nargin < 1
79 dfref = [];
80 end
81 self.dfref = dfref;
82 end
83
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85
86 %>
87 %> \brief
88 %> Generate and return a copy of the data (or what is returned by the function handle)
89 %> given the constructor of the parent object or the data return by the input.<br>
90 %>
91 %> \details
92 %> This class method offer the only way to access the user-specified data (reference).<br>
93 %> The underlying logic behind the use of function to access the data (reference)
94 %> originates from the lack of the concept of references (pointers)
95 %> in the MATLAB computing language.<br>
96 %>
97 %> \param[inout] self : The **implicitly-passed** input argument representing the parent object of the method.<br>
98 %>
99 %> \return
100 %> ``df`` : The output scalar MATLAB ``table`` a full copy of the data (reference)
101 %> contained in the user-specified input ``dfref`` passed
102 %> to the constructor of the parent object.<br>
103 %>
104 %> \interface{copy}
105 %> \code{.m}
106 %>
107 %> df = pm.container.DataRef(dfref);
108 %> dfcopy = df.copy();
109 %>
110 %> \endcode
111 %>
112 %> \remark
113 %> See the constructor documentation for example usage.<br>
114 %>
115 %> \final{copy}
116 %>
117 %> \author
118 %> \JoshuaOsborne, Friday May 17, 2014, 6:40 PM, The University of Texas at Arlington, Dallas, TX<br>
119 %> \AmirShahmoradi, Tuesday March 7, 2017, 7:03 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin<br>
120 function df = copy(self)
121 if isa(self.dfref, 'function_handle')
122 df = self.dfref();
123 else
124 df = self.dfref;
125 end
126 end
127
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129
130 end
131
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133
134end
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
This is the abstract class for generating instances of objects that can contain basic attributes requ...
Definition: DataFrame.m:25
This is the abstract class for generating instances of objects that can contain basic attributes requ...
Definition: DataRef.m:27
Property dfref
Definition: DataRef.m:41
function copy(in self)
Generate and return a copy of the data (or what is returned by the function handle) given the constru...
function DataRef(in dfref)
Generate an return an object of class DataRef from the input dataframe or its specified input referen...
This is the base class for generating subclass of MATLAB handle superclass whose annoying methods are...
Definition: Handle.m:24
function copy(in from, in to, in field, in exclude)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...