Boost logo

Boost Users :

From: Nat Goodspeed (nat_at_[hidden])
Date: 2008-05-14 12:35:48


Ananth Durbha wrote:

> I am trying to modify a set of file parser callback functions (for a
> custom file format) to populate a Boost graph. The callbacks provide a
> (void*) pointer style parameter passing. But Boost graph method
> add_vertex(graph) will return a vertex descriptor. How do I obtain the
> pointer information for this newly added vertex so that the pointer can
> be cast as (void*) and passed to the appropriate call back?

If you're writing the code that calls the callback, what about something
like this (untested):

struct CallbackData
{
     /* vertex descriptor type */ vertex_desc;
};

...

     CallbackData cdata;
     cdata.vertex_desc = add_vertex(...);
     (*callback)(reinterpret_cast<void*>(&cdata));

Then, inside your callback:

void my_callback(void* data)
{
     CallbackData* pdata = reinterpret_cast<CallbackData*>(data);
     /* ... use pdata->vertex_desc ... */
}

? If that's not the scenario you have in mind, then please explain more
clearly.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net