[Ns-bugs] [Bug 50] The example code on the page Low-level tracing page does not compile

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Sat Jul 14 02:51:15 PDT 2007


http://www.nsnam.org/bugzilla/show_bug.cgi?id=50


mathieu.lacage at sophia.inria.fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




------- Comment #1 from mathieu.lacage at sophia.inria.fr  2007-07-14 05:51 -------
(In reply to comment #0)
> I am trying to create a trace sink to do some tracing. I tried to follow the
> example on the Low-level tracing page in the Doxygen documentation.
> 
> There are two problems:
> 1) The code:
>  void MyTraceSink (TraceContext const &context, Packet &packet)
>  {
>    NodeList::Index index;
>    context.Get (index);
>    std::cout << "node id=" << NodeList::GetNode (index)->GetId () << std::endl;
>  }
> 
> Should be changed to:
> 
> 
>  void MyTraceSink (TraceContext const &context, Packet &packet)
>  {
>    NodeList::NodeIndex index;
>    context.Get (index);
>    std::cout << "node id=" << NodeList::GetNode (index)->GetId () << std::endl;
>  }

can you push a patch which fixes this ?

> 
> 2) The command:
>    TraceRoot::Connect ("/nodes/ * / Ipv4 / *", MakeCallback
> (&TraceSink::MyTraceSink));
> Which I assume can be put in the main file gives the following compile error:
> examples/simple-multipoint.cc:154: error: no matching function for call to
> 'MakeCallback(void (ns3::TraceSink::*)(const ns3::TraceContext&,
> ns3::Packet&))'
> 
> Now, if I have that command in another class, I can use:
> TraceRoot::Connect ("/nodes/ * / Ipv4 / *", MakeCallback
> (&TraceSink::MyTraceSink, this));
> 
> What does the "this" do?

I suspect that you have defined MyTraceSink as a member method rather than as a
standalone function (which the same code you reference did). If this is the
case, the member method needs to be invoked on an object instance and the
"this" argument here is just a pointer to that object instance which is
required to make a callback which references that specific method on that
specific object instance.


-- 
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