H5Ovisit, using a class member function as the iterator function

Hi everyone,

I have the following problem and haven't found any good solution to it yet.

Within a class function, i want to open an HDF5 file, iterate over all elements and process the content of the datasets. The function H5Ovisit is perfect for it, except that
the function, which is called for each object, has to be global. I would like to have that the iterator function is a member function of the class, so that with each call it has access to the class member functions and variables. However all attempts to call H5Ovisit like H5Ovisit(...,...,...,this->iterate,...) or via a global function pointer and the assignment of this function pointer with the member function right before the call of H5Ovisit has failed.

I would love to solution similar to the SAX-parser for XML files, where you can inherit the iterative function into the derived class and then overwrite the definition.

Any help would be highly appreciated,

Sven Reiche
Paul Scherrer Institut,
5232 Villigen PSI
Switzerland

···

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

Hi Sven,

Say the class you want to use is X.
Make a static member function f1 in your class acting as the function pointer to H5ovisit and make a normal member function f2 which does the work.
The op_data argument should be a pointer to your object of class X and implement X:f1 as
    { return static_cast<X*>(op_data)->f2 (o_id, name, object_info); }

Of course, f1 can also be a global function, but making it a static member function puts the function where it belongs.

Cheers,
Ger

Sven Reiche <sven.reiche@psi.ch> 02/04/09 3:34 PM >>>

Hi everyone,

I have the following problem and haven't found any good solution to it
yet.

Within a class function, i want to open an HDF5 file, iterate over all
elements and process the content of the datasets. The function
H5Ovisit is perfect for it, except that
the function, which is called for each object, has to be global. I
would like to have that the iterator function is a member function of
the class, so that with each call it has access to the class member
functions and variables. However all attempts to call H5Ovisit like
H5Ovisit(...,...,...,this->iterate,...) or via a global function
pointer and the assignment of this function pointer with the member
function right before the call of H5Ovisit has failed.

I would love to solution similar to the SAX-parser for XML files,
where you can inherit the iterative function into the derived class
and then overwrite the definition.

Any help would be highly appreciated,

Sven Reiche
Paul Scherrer Institut,
5232 Villigen PSI
Switzerland

···

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.

----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.