Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!g23g2000yqh.googlegroups.com!not-for-mail
From: Izzy <iskandarprins@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: C++ and Matlab
Date: Fri, 6 Nov 2009 00:22:46 -0800 (PST)
Organization: http://groups.google.com
Lines: 42
Message-ID: <7fa345d3-dbfa-4afd-b79d-4ffe72c6192c@g23g2000yqh.googlegroups.com>
References: <79efd49c-346d-40b2-a663-67f754b7b8da@g23g2000yqh.googlegroups.com> 
	<ab897769-b6b9-49a5-8926-79681bcec4c1@g23g2000yqh.googlegroups.com> 
	<hcuofb$pd7$1@fred.mathworks.com>
NNTP-Posting-Host: 91.212.0.61
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257495766 28016 127.0.0.1 (6 Nov 2009 08:22:46 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 6 Nov 2009 08:22:46 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: g23g2000yqh.googlegroups.com; posting-host=91.212.0.61; 
	posting-account=6K5KdwoAAACF8TN4oxGQ4_TLCe8E-x2S
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
	2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 
	3.0.4506.2152; .NET CLR 3.5.30729; MEGAUPLOAD 3.0; OfficeLiveConnector.1.3; 
	OfficeLivePatch.0.0; InfoPath.2),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:582949


On Nov 5, 3:46 pm, "James Tursa"
<aclassyguy_with_a_k_not_...@hotmail.com> wrote:
> Izzy <iskandarpr...@gmail.com> wrote in message <ab897769-b6b9-49a5-8926-79681bcec...@g23g2000yqh.googlegroups.com>...
> > On Nov 4, 3:14?pm, "James Tursa"
> > <aclassyguy_with_a_k_not_...@hotmail.com> wrote:
> > > Izzy <iskandarpr...@gmail.com> wrote in message <79efd49c-346d-40b2-a663-67f754b7b...@g23g2000yqh.googlegroups.com>...
> > > > Hi,
>
> > > > If i create a singleton object inc++code and send it into matlab and
> > > > use it there, does the singleton share the same memory or are there 2
> > > > singelton around, one inc++memory space and one in matlab memory
> > > > space?
>
> > > Show us your code. How are you sending it to MATLAB?
>
> > > James Tursa
>
> > No code avalaible yet, since i'm just starting with thisc++/matlab
> > thing. Basically I have a singleton class inc++land, which also
> > needs to be used in matlab land. I was wondering if both lands share
> > the same memory if i would pass the singleton into matlab and do some
> > modification on the singleton, if this singleton would still be the
> > same object.
>
> In general, then, the answer is no. Your singleton could live inside the mex routine, and if you put it at the top level (outside the mexFunction) it will maintain its state across multiple mex calls. But to pass it back into the MATLAB workspace you will have to somehow turn it into an equivalent mxArray. This *copy* would be passed back into the MATLAB workspace. Changing the state of this *copy* in the MATLAB workspace will not affect the original singleton in your mexC++routine.
>
> James Tursa- Hide quoted text -
>
> - Show quoted text -

Aha, thanks. So basically whenever I send in data to and from matlab a
copy is made thus is invalidates the usage of a singleton.