libmexclass represents proxy IDs as uint64 values. It would be better if we created a class to represent proxy IDs. Doing so would facilitate creating MATLAB objects from existing proxies.
For example, suppose you have a proxy UInt64Array class that accepts a uint64 vector on construction:
classdef UInt64Array
properties(Access = private)
Proxy
end
methods
function obj = UInt64Array(data)
arguments
data(1, :) uint64
end
obj.Proxy = libmexclass.proxy.Proxy(Name="UInt64ArrayProxy", ConstructorArguments={data});
end
end
end
Right now, what data represents is ambigous. It could be a proxy ID, or it could be a uint64 array from which the user wants to create a proxy. If we represent proxy IDs with a class, this ambiguity goes away:
classdef UInt64Array
properties(Access = private)
Proxy
end
methods
function obj = UInt64Array(data)
arguments
data
end
if isa(data, "ProxyID")
obj.Proxy = libmexclass.proxy.Proxy(Name="UInt64ArrayProxy", ID=data);
else
obj.Proxy = libmexclass.proxy.Proxy(Name="UInt64ArrayProxy", ConstructorArguments={data});
end
end
end
end
libmexclass
represents proxy IDs asuint64
values. It would be better if we created a class to represent proxy IDs. Doing so would facilitate creating MATLAB objects from existing proxies.For example, suppose you have a proxy
UInt64Array
class that accepts auint64
vector on construction:Right now, what data represents is ambigous. It could be a proxy ID, or it could be a uint64 array from which the user wants to create a proxy. If we represent proxy IDs with a class, this ambiguity goes away: