[Ns-bugs] [Bug 127] Add trace callback type information for Python bindings
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Sat Jan 10 09:24:17 PST 2009
http://www.nsnam.org/bugzilla/show_bug.cgi?id=127
--- Comment #6 from Tom Henderson <tomh at tomh.org> 2009-01-10 12:24:17 EDT ---
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > This is still an issue AFAIK. Not P1 because Python bindings will be merged
> > > after ns 3.1.
> > >
> >
> > Gustavo, can you clarify the status of this? My understanding is that:
> >
> > 1) if a callback is exported explicitly at the API, it is possible to register
> > a python method with it, thereby enabling people to write python code for ns-3
Is the above true? Are there any examples of it presently?
> >
> > 2) but due to this bug, we just can't hook them through the trace hooks
> > obtained through the trace path
> >
> > If I am correct, are there any examples (even a small sample program for
> > samples/ directory) of how to do this? Someone here at UW would like to try
> > writing some Python ns-3 code.
> >
>
> The problem is that 1) in Python we cannot introspect the signature of a
> "callable" (i.e. function or method, or class instance with a __call__ method),
> and 2) NS-3 also does not provide an API that says what is the expected
> callback type for a certain trace path, but it eventually checks in runtime
> whether supplied callbacks are of the correct type. Although the
> Config::Connect API accepts a generic callback type (CallbackBase) as
> parameter, it later matches it against one of the concrete callback types
> (Callback<R,T1,T2,...>). So the Python bindings have to supply a concrete
> callback wrapper based on a Python callable for which I cannot obtain signature
> information.
>
> I can think of two possible and contrasting ways to move forward:
>
> 1- Add a new NS-3 API to give back callback type(s) regarding trace path. The
> Python bindings could work things out and the Python API would turn out to be
> simple:
>
>
> def my_callback(packet):
> print packet
>
> ns3.Config.Connect("/NodeList/*/....", my_callback)
>
clearly that would be nicer on users but I don't know what is involved in
supporting that.
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list