[Ns-bugs] [Bug 155] "std::ostream & os" parameters not Python friendly
bugzilla-daemon@nsnam-www.ece.gatech.edu
bugzilla-daemon at nsnam-www.ece.gatech.edu
Sun Mar 30 09:29:44 PDT 2008
http://www.nsnam.org/bugzilla/show_bug.cgi?id=155
------- Comment #1 from mathieu.lacage at sophia.inria.fr 2008-03-30 12:29 -------
(In reply to comment #0)
> In the Python bindings I'm working on
> (http://code.nsnam.org/gjc/ns-3-pybindgen-notracing/), I am getting errors
> like:
>
> /home/gjc/projects/ns-3/ns-3-pybindgen-notracing/build/debug/ns3/csma-helper.h:68:
> Warning: Parameter '::std::ostream & os' error (used in static void
> ns3::CsmaHelper::EnableAscii(std::ostream & os, uint32_t nodeid, uint32_t
> deviceid) [member function]): TypeLookupError('std::ostream &',)
>
> So, std::ostream is not being wrapped, but the problem is that I am not
> comfortable wrapping ostream in any form. The main problem is passing as
> reference and lack of reference counting.
>
> Conceptually, I could create my own PyOStream C++ subclass of ostream, which
> would redirect writes to a python file-like object. But passing as reference
> or pointer is dangerous because there is no guarantee that python object will
> be kept alive for long. Python users should not have to worry about life cycle
> issues that much, and they are not used to it.
>
> If these NS-3 APIs operated on a reference counted object instead (e.g.
> Ptr<OStream>) things would be vastly safer to Python bindings... this
> Ptr<OStream> could have "std::ostream& GetStdOStream ()" method. That would be
> fine as long as the std::ostream object life cycle management responsibility
> shifts away from the Python bindings into the NS-3 core itself.
Adding such a Ptr<Ostream> class in the public API looks horribly painful from
c++ and would kill the whole purpose of these helper methods which is to make
life easy to c++ programmers, so, I would be really annoyed to have to do this.
It would be nice to find a good solution for python though: how does python
handle formatted io to stdout and files ? Can you point me to a not-too-painful
introduction ? How does boost::python handle this case ?
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Ns-bugs
mailing list