Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!v25g2000yqk.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: C++ and Matlab
Date: Thu, 5 Nov 2009 06:18:03 -0800 (PST)
Organization: http://groups.google.com
Lines: 46
Message-ID: <b252c0c8-21f7-458d-a4df-611879516bba@v25g2000yqk.googlegroups.com>
References: <79efd49c-346d-40b2-a663-67f754b7b8da@g23g2000yqh.googlegroups.com> 
	<hcs27a$qga$1@fred.mathworks.com> <ab897769-b6b9-49a5-8926-79681bcec4c1@g23g2000yqh.googlegroups.com>
NNTP-Posting-Host: 77.17.43.82
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257430684 6157 127.0.0.1 (5 Nov 2009 14:18:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 5 Nov 2009 14:18:04 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: v25g2000yqk.googlegroups.com; posting-host=77.17.43.82; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .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; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:582722


On 5 Nov, 13:55, Izzy <iskandarpr...@gmail.com> wrote:
> 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 this c++/matlab
> thing. Basically I have a singleton class in c++ 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.

How are you proposing to do this?

You can make C++ and matlab interact in two ways:

1) Call C++ from matlab in the form of MEXfiles
2) Call the matlab engine from a C++ executable

In case 1 your C++ singleton will have to be declared and
initialized somewhere near the entry point of your C++
MEX routine, and be available to your C++ code. However,
its scope - and thus lifetime - will end near the return
point of your MEX routine. So there is no reason to expect
the singleton to be available from matlab scope, or to
stay available between multiple calls to the MEX routine.

In case 2 you would ideally want to pass the singleton
from C++ into matlab scope, to become accessible to matlab.
That can not be done. The best you can do is to pass variables
from the singleton through the engine gateway, and read
modified data back.

Rune