[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave_value <-> GdBoxed
From: |
David Bateman |
Subject: |
Re: Octave_value <-> GdBoxed |
Date: |
Thu, 9 Dec 2004 13:52:38 +0100 |
User-agent: |
Mutt/1.4.1i |
Welcome to the pleasures of user defined types.....
The way around this is for example if your class is like
class
GdBoxed : public octave_base_value
{
...
private:
DECLARE_OCTAVE_ALLOCATOR
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
};
and you've registered to type like
DEFINE_OCTAVE_ALLOCATOR (GdbBoxed);
DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (GdBoxed, "GdBoxed", "GdBoxed");
is to first extract your class from the octave_value container, like
GdBoxed Gdrep;
if (args(0).type_name == "GdBoxed")
GdRep = ((const GdBoxed&) args(0)).get_rep();
else
error ("incorrect type")
You can then call your methods on the Gdrep variable... Next you'll
want to know how to return Gdrep, which can be done by casting as an
octave_value with
octave_value retval = new GdBoxed (Gdrep);
Note that if you need the narrowing functions, then you'll need to explicitly
call them like
retval.maybe_mutate ();
Cheers
David
According to Muthu <address@hidden> (on 12/09/04):
> Hi there!
> Greetings everyone.
> I am trying to write a new octave object class
> [GdBoxed class].I create an instance of this object,
> derived from octave_base_value, and return it to the
> interpreter.
>
> Now when the user sends it back to me from the
> interpreter,it comes shadowed as a octave_value()
> which I have to typecast to the derived form. This is
> not working, as I cannot call the member functions
> which I have added newly for the derived types,
> but I can access the virtual members correctly [eg:
> print,ulong_value]. I made a kludge to make the
> ulong_value() return the pointer to the object,
> and from there call my newly added members.
>
> I would like to know what is the generic method used
> for doing this upcasting of octave_value to derived
> types used by other programmers.
>
> Also, I want to know why sometimes when I call my
> functions octave complains that "cannot find symbol
> ZNGdBox_23fa" during dynamically loading functions?
>
> Please help.
>
> Yours Truly,
> Muthu.
>
>
>
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - What will yours do?
> http://my.yahoo.com
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
--
David Bateman address@hidden
Motorola CRM +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------