|
"Sprinceana " <mihaispr@yahoo.com> wrote in message <h1q5eq$564$1@fred.mathworks.com>...
> "meng long" <menglong6518@yeah.net> wrote in message <h1pvot$o7o$1@fred.mathworks.com>...
> > In Matlab, can I clone a object?
>
> What object do you want to clone? Can you give details?
Dear Sprinceana:
I want to clone any instance of a handle classes.
Now I use a pseudo_clone defined by a method in the class 'Handle < handle'
function Clone(oObj,oCln)
oMeta = PMeta.HProp(oObj,{'Name','SetAccess','IsHandle'});
clProp = oMeta.clName;
clSetAccess = oMeta.clSetAccess;
loIsHandle = oMeta.loIsHandle;
dNoRows = oMeta.dNoRows;
for dNoR = 1:dNoRows
if(~strcmp(clSetAccess{dNoR},'public')), continue; end
tTmp = oObj.(clProp{dNoR});
if(loIsHandle(dNoR))
oCln.(clProp{dNoR}) = feval(class(tTmp));
Clone(tTmp,oCln.(clProp{dNoR}));
else
oCln.(clProp{dNoR}) = tTmp;
end
end
The function Clone can not works in your computer since many other relative methods are needed. I knows that the 'Clone' is not completed, but I can do nothing except
waiting matlab to surport clone as in C++,C#.
Look forward
meng long
|