Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Making C++ objects persistent between mex calls, and robust.
Replies: 37   Last Post: Sep 27, 2013 6:54 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Pierre

Posts: 8
Registered: 2/3/11
Re: Making C++ objects persistent between mex calls, and robust.
Posted: Feb 3, 2011 12:49 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Oliver Woodford" wrote in message <iiemhf$pev$1@fred.mathworks.com>...
> "Pierre" wrote:
> > First, except for the initializing method, one does not necessarily have to write the proxy method WrapperClass/<action> in order to invoke the <action>_mex functions: only declare the <action> method in the class definition and place the mex files in the @WrapperClass directory immediately... you have to implement mexFunction() anyhow, which is another proxy function already and which can take over the part of fetching the C++ object pointer from the Matlab object with mxGetProperty(). I admit, this concerns exclusively code aesthetics but it might slightly improve code maintainability and oversight.
>
> Another point, which works in favour of the WrapperClass/<action> approach, is that with that approach you can get away with just one mex function. You can then call it with a parameter, e.g. a string, to denote which class function you want to call. That's the way I'm currently doing things, but it is entirely aesthetic, you're right.
>
> Oliver


You are absolutely right Oliver, I hadn't thought about that approach at all. The single-mex approach is probably the most reasonable one for supposedly 99% of the cases one may want to use the technique proposed herein. Being too much focused on my case, I didn't consider that approach as we've got so much handling of parameter-conversion at transition points, that this single mex would easily bloat up to far over 1500 lines of string comparing if statements, type-casting and array copying (comments excluded) which would be hard to maintain (neither in terms of difficulty nor complexity, but I guess it would become quite error-prone over time).

(Meanwhile I also managed to figure out how to alter properties of handle objects immediately from a mex file: Invoking mxSetProperty() on a const_cast of the concerned prhs[i] seems to work just fine. ;) )


Date Subject Author
4/1/10
Read Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
6/7/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Anthony Halley
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Walter Roberson
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Anthony Halley
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
1/22/11
Read Re: Making C++ objects persistent between mex calls, and robust.
newuser asdf
1/22/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Bruno Luong
1/23/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Rune Allnor
1/23/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Bruno Luong
1/23/11
Read Re: Making C++ objects persistent between mex calls, and robust.
newuser asdf
1/24/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
2/3/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Pierre
2/3/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
2/3/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Pierre
2/3/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
2/15/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Pierre
7/6/11
Read Re: Making C++ objects persistent between mex calls, and robust.
mathias
7/6/11
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
5/24/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Ajay
5/25/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Pierre
10/2/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
11/7/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Francesco Montorsi
11/8/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
11/9/12
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
1/21/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
1/22/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
1/30/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Gabri Gwala
1/30/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Steven Lord
1/31/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
9/22/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Gabri Gwala
9/22/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Gabri Gwala
9/27/13
Read Re: Making C++ objects persistent between mex calls, and robust.
Oliver Woodford
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Anthony Halley
6/8/10
Read Re: Making C++ objects persistent between mex calls, and robust.
Anthony Halley

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.