# HG changeset patch # User Mitch Watrous # Date 1348860138 25200 # Node ID 94215be61edf2f73ef201a998a428aa9e39db970 # Parent 8462a1160246422c4b4aeb07a21ea5833edca6bd Make MobilityHelper use an output stream wrapper diff -r 8462a1160246 -r 94215be61edf examples/routing/manet-routing-compare.cc --- a/examples/routing/manet-routing-compare.cc Thu Sep 27 13:29:03 2012 -0400 +++ b/examples/routing/manet-routing-compare.cc Fri Sep 28 12:22:18 2012 -0700 @@ -378,9 +378,8 @@ //AsciiTraceHelper ascii; //Ptr osw = ascii.CreateFileStream ( (tr_name + ".tr").c_str()); //wifiPhy.EnableAsciiAll (osw); - std::ofstream os; - os.open ((tr_name + ".mob").c_str ()); - MobilityHelper::EnableAsciiAll (os); + AsciiTraceHelper ascii; + MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (tr_name + ".mob")); //Ptr flowmon; //FlowMonitorHelper flowmonHelper; diff -r 8462a1160246 -r 94215be61edf examples/wireless/wifi-wired-bridging.cc --- a/examples/wireless/wifi-wired-bridging.cc Thu Sep 27 13:29:03 2012 -0400 +++ b/examples/wireless/wifi-wired-bridging.cc Fri Sep 28 12:22:18 2012 -0700 @@ -190,9 +190,8 @@ if (writeMobility) { - std::ofstream os; - os.open ("wifi-wired-bridging.mob"); - MobilityHelper::EnableAsciiAll (os); + AsciiTraceHelper ascii; + MobilityHelper::EnableAsciiAll (ascii.CreateFileStream ("wifi-wired-bridging.mob")); } Simulator::Stop (Seconds (5.0)); diff -r 8462a1160246 -r 94215be61edf src/mobility/helper/mobility-helper.cc --- a/src/mobility/helper/mobility-helper.cc Thu Sep 27 13:29:03 2012 -0400 +++ b/src/mobility/helper/mobility-helper.cc Fri Sep 28 12:22:18 2012 -0700 @@ -200,8 +200,9 @@ } } void -MobilityHelper::CourseChanged (std::ostream *os, Ptr mobility) +MobilityHelper::CourseChanged (Ptr stream, Ptr mobility) { + std::ostream* os = stream->GetStream (); Ptr node = mobility->GetObject (); *os << "now=" << Simulator::Now () << " node=" << node->GetId (); @@ -225,25 +226,25 @@ } void -MobilityHelper::EnableAscii (std::ostream &os, uint32_t nodeid) +MobilityHelper::EnableAscii (Ptr stream, uint32_t nodeid) { std::ostringstream oss; oss << "/NodeList/" << nodeid << "/$ns3::MobilityModel/CourseChange"; Config::ConnectWithoutContext (oss.str (), - MakeBoundCallback (&MobilityHelper::CourseChanged, &os)); + MakeBoundCallback (&MobilityHelper::CourseChanged, stream)); } void -MobilityHelper::EnableAscii (std::ostream &os, NodeContainer n) +MobilityHelper::EnableAscii (Ptr stream, NodeContainer n) { for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i) { - EnableAscii (os, (*i)->GetId ()); + EnableAscii (stream, (*i)->GetId ()); } } void -MobilityHelper::EnableAsciiAll (std::ostream &os) +MobilityHelper::EnableAsciiAll (Ptr stream) { - EnableAscii (os, NodeContainer::GetGlobal ()); + EnableAscii (stream, NodeContainer::GetGlobal ()); } int64_t MobilityHelper::AssignStreams (NodeContainer c, int64_t stream) diff -r 8462a1160246 -r 94215be61edf src/mobility/helper/mobility-helper.h --- a/src/mobility/helper/mobility-helper.h Thu Sep 27 13:29:03 2012 -0400 +++ b/src/mobility/helper/mobility-helper.h Fri Sep 28 12:22:18 2012 -0700 @@ -24,6 +24,7 @@ #include #include "ns3/object-factory.h" #include "ns3/attribute.h" +#include "ns3/output-stream-wrapper.h" #include "ns3/position-allocator.h" #include "node-container.h" @@ -221,31 +222,31 @@ void InstallAll (void); /** - * \param os output stream + * \param stream an output stream wrapper * \param nodeid the id of the node to generate ascii output for. * * Enable ascii output on the mobility model associated to the * specified nodeid and dump that to the specified stdc++ output * stream. */ - static void EnableAscii (std::ostream &os, uint32_t nodeid); + static void EnableAscii (Ptr stream, uint32_t nodeid); /** - * \param os output stream + * \param stream an output stream wrapper * \param n node container * * Enable ascii output on the mobility model associated each of * the nodes in the input container and dump that to the * specified stdc++ output stream. */ - static void EnableAscii (std::ostream &os, NodeContainer n); + static void EnableAscii (Ptr stream, NodeContainer n); /** - * \param os output stream + * \param stream an output stream wrapper * * Enable ascii output on the mobility model associated * every node in the system and dump that to the specified * stdc++ output stream. */ - static void EnableAsciiAll (std::ostream &os); + static void EnableAsciiAll (Ptr stream); /** * Assign a fixed random variable stream number to the random variables * used by the mobility models (including any position allocators assigned @@ -264,7 +265,7 @@ /** * \internal */ - static void CourseChanged (std::ostream *os, Ptr mobility); + static void CourseChanged (Ptr stream, Ptr mobility); std::vector > m_mobilityStack; ObjectFactory m_mobility; Ptr m_position;