MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MathLink with C++

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40718] Re: MathLink with C++
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 15 Apr 2003 03:56:44 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <b7dq44$67s$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

just make the templates to access the methods of a certain object
an you are done.

you CreateObject[] function return a unique integer ID to Mathematica
and you SetObjectValue[] function scan the (C++) list of objects to 
locate the object with that ID number and call the method of this object
to set the value?

MathLink itself does *not* connect to a class and Mathematica
does not help you to call class methods from Mathematica.
Mathematica connect to a process and the process is repsonsible
to redirect the function calls of ExternalCall[]s to the correct
function/method 

BTW you need a class in the addtwo example ? Whow !


Regards
  Jens



Steve Luttrell wrote:
> 
> I use Mathematica 4.2.1 for MS Windows. I need a simple example (like the
> "addtwo" MathLink example) to demonstrate precisely how one connects
> MathLink to classes in C++ (to drive C++ from Mathematica), but I can't find
> any information on this in the usual places. I use MS Visual C++ 6 and can
> get the "addtwo" example working, but I have not been successful in
> extending this example to use classes.
> 
> At the Mathematica end of the link I would expect to do the following sort
> of thing (trivial example, but enough to get me started):
> 
> obj = CreateObject[];
> val = <number>;
> SetObjectValue[obj, val];
> val2 = GetObjectValue[obj];
> Print[val2];
> DestroyObject[obj];
> 
> What would I have to put at the C++ end of the link (e.g. code to add to the
> "addtwo" example, say) to make the above "Object" class work for me?
> 
> --
> Steve Luttrell
> West Malvern, UK


  • Prev by Date: Re: Simplification of definite integral?
  • Next by Date: Re: Re: Simplification of definite integral?
  • Previous by thread: FW: A better Units package
  • Next by thread: One-liners' performance