Boost logo

Boost :

From: Phil Austin (paustin_at_[hidden])
Date: 2001-10-30 15:28:14


David Abrahams writes:
> Phil,
>
> The instance's __dict__ can be accessed by writing instance.__dict__. I am
> guessing that your "attribute_set" is a data member of HDFFile. If you store
> attribute values in there, they won't show up in the __dict__. Your data
> members don't show up in the __dict__ either (they're C++ objects, not
> Python objects of course). Maybe the best way to illustrate is with some
> Python code analogous to what you've done:
>

[snip]

>
> Why are you storing attributes in your own attribute_set? The instance
> already has a __dict__ !

A little background might help here. We'd like to produce a boost
interface to a file format called HDF (NCSA hierarchical data format)
that has the same api as Konrad Hinsen's NetCDF (NCAR common data
format) module
(http://dirac.cnrs-orleans.fr/programs/scientific.html). Both these
file formats store data (binary arrays) and metadata (strings and
arrays that describe the data). Hinsen's module generates file
objects and variable objects that map file and variable metadata onto
file and variable instance attributes. The variable instances support
slicing, so you can store and retrieve partial N-dimensional
arrays. In essence we're pickling/unpickling the instance, with HDF
and netCDF being the pickle data formats.

So in Python I can see it's no problem to do something like:

class HDFFile:
  ...
  def close(self):
        writeMetaData(self.__dict__,self.filename)
  ...

what I haven't been able to come up with is the Boost equivalent
for the above.

(Our initial attempt was a straight-forward steal of Hinsen's
code from Scientific_netcdf.c:

    if (strcmp(name, "__dict__") == 0) {
      Py_INCREF(self->attributes);
      return self->attributes;
    }

)

Regards, Phil


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