Bug 1037

Summary: no way to associate std::cout with OutputStreamWrapper
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED INVALID    
Severity: normal CC: mathieu.lacage, ns-bugs, rohrej
Priority: P5    
Version: pre-release   
Hardware: All   
OS: All   

Description Tom Henderson 2010-12-08 17:44:02 UTC
This used to be possible until the patches to bugs 931 and 933 were merged that removed the SetStream() method:

   Ptr<OutputStreamWrapper>  cout_wrap = new OutputStreamWrapper;
   cout_wrap->SetStream(&std::cout);
   p2p.EnableAsciiAll (cout_wrap); 

Currently, there does not appear to be an easy way to redirect tracing to standard output streams.  It seems that restoring SetStream() as before leads to memory management ambiguity of the pointer.  Can this functionality be re-enabled somehow?  (to allow easier post-processing of the trace file in parallel with running simulation)
Comment 1 Justin P. Rohrer 2010-12-08 18:05:45 UTC
One alternative to the SetStream function might be add a function to AsciiTraceHelper which returns Ptr<OutputStreamWrapper> directed to standard output.  This would be sufficient for our (KUs) needs, without allowing the passing of arbitrary streams by the user.
Comment 2 Tom Henderson 2010-12-29 12:55:22 UTC
Does this work (without any changes to ns-3-dev)?

   PointToPointHelper p2p;
   Ptr<OutputStreamWrapper> osw = Create<OutputStreamWrapper> (&std::cout);
   p2p.EnableAsciiAll (osw);
Comment 3 Mathieu Lacage 2011-07-06 18:22:28 UTC
(In reply to comment #2)
> Does this work (without any changes to ns-3-dev)?
> 
>    PointToPointHelper p2p;
>    Ptr<OutputStreamWrapper> osw = Create<OutputStreamWrapper> (&std::cout);
>    p2p.EnableAsciiAll (osw);

it should work. INVALID.