[Ns-developers] NS-3 PyBindGen again
mathieu.lacage at sophia.inria.fr
Mon Jan 7 03:58:32 PST 2008
On Mon, 2008-01-07 at 11:29 +0000, Gustavo Carneiro wrote:
> I won't comment on you specific implementation, but I have to question
> whether this is really useful or not. How often do you connect
> callbacks from Python to C++ functions?
Quite often if you want to connect a C++ statistics class to a trace
> Do you have an idea on how this could be implemented ? If so,
> could you
> outline briefly how you think it could be done ?
> This is where we have to provide a MakeCallback API to Python, the
> types mangled into the name. Example:
> In C++:
> static void
> CourseChange (const TraceContext &context, Ptr<const MobilityModel>
> notifier->TraceConnect ("/course-change", MakeCallback
> In Python would be:
> def CourseChange (context, position):
> Yes, it's very ugly. But I don't see any way around it with the
> current API.
> It would be nice, though, if the API could be enhanced to provide
> introspection of the required tracing callbacks. An API like this
> would be enough:
> const std::type_info GetTraceCallbackType(const std::string path)
> Should I open a bug report?
This API is, however, impossible to implement in C++ as far as I know :/
What we could potentially do is add some API which reports the set of
TraceDoc objects which match a specific trace path so, from python, you
could get these before calling Connect and attempt to create the right
kind of callback by using a callback name mangled by the signature
If the above could be made to work, the final problem you would need to
be able to solve would be how to bind the TraceContext class. i.e.,
could you make it possible for the python trace hook to read the context
of the TraceContext ?
More information about the Ns-developers