Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-11-28 08:54:44


----- Original Message -----
From: "Anton Gluck" <gluc_at_[hidden]>
>
> I've looked through the code and tried a few things, and came up with this
> solution: I changed the return type from ClusterVar to ClusterVar* so that
> Python will not receive a ClusterVar object without info on whether this
> was a CatVar or ContVar.

I think you're on the right track now. It isn't so much a matter of losing
info about what it was, but of losing its CatVar-ness or ContVar-ness
altogether.

> Since now I am returning a pointer I wrote a
> to_python for this that examines the ClusterVar, casts it as CatVar or
> ContVar accordingly, and then returns the object. Now Python will receive
> actual CatVar and ContVar objects. In case somebody is interested, here is
> the code for to_python:
>
> PyObject* to_python(ClusterVar* cv)
> {
> if (typeid(*cv) == typeid(CatVar)) {
> return to_python(dynamic_cast<CatVar&>(*cv));
> }
> else if (typeid(*cv) == typeid(ContVar)) {
> return to_python(dynamic_cast<ContVar&>(*cv));
> }
> else return to_python(*cv);
> // in case we have a genuine ClusterVar object
> }

I don't really understand what you're up to with this, but it strikes me (in
my gut - oof!) as highly likely to be unneccessary, and more suitably
replaced by Ullrich's declare_base() mechanism. He's a better candidate to
help you out with this, though.

Regards,
Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk