diff -r 2324032b8f90 examples/wifi-ap.cc --- a/examples/wifi-ap.cc Thu Mar 20 10:25:59 2008 -0700 +++ b/examples/wifi-ap.cc Thu Mar 20 18:50:47 2008 +0000 @@ -47,32 +47,32 @@ using namespace ns3; using namespace ns3; void -DevTxTrace (std::string context, Ptr p, Mac48Address address) +DevTxTrace (Config::Path context, Ptr p, Mac48Address address) { std::cout << " TX to=" << address << " p: " << *p << std::endl; } void -DevRxTrace (std::string context, Ptr p, Mac48Address address) +DevRxTrace (Config::Path context, Ptr p, Mac48Address address) { std::cout << " RX from=" << address << " p: " << *p << std::endl; } void -PhyRxOkTrace (std::string context, Ptr packet, double snr, WifiMode mode, enum WifiPreamble preamble) +PhyRxOkTrace (Config::Path context, Ptr packet, double snr, WifiMode mode, enum WifiPreamble preamble) { std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl; } void -PhyRxErrorTrace (std::string context, Ptr packet, double snr) +PhyRxErrorTrace (Config::Path context, Ptr packet, double snr) { std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl; } void -PhyTxTrace (std::string context, Ptr packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower) +PhyTxTrace (Config::Path context, Ptr packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower) { std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl; } void -PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state) +PhyStateTrace (Config::Path context, Time start, Time duration, enum WifiPhy::State state) { std::cout << " state="; switch (state) { diff -r 2324032b8f90 src/core/config.cc --- a/src/core/config.cc Thu Mar 20 10:25:59 2008 -0700 +++ b/src/core/config.cc Thu Mar 20 18:50:47 2008 +0000 @@ -469,6 +469,44 @@ void UnregisterRootNamespaceObject (Ptr< Singleton::Get ()->UnregisterRootNamespaceObject (obj); } +std::string Path::GetComponentString (uint32_t componentIndex) const +{ + NS_ASSERT (m_path [0] == '/'); + std::string::size_type componentStart = 1; + uint32_t currentComponent = 0; + for (std::string::size_type pos = 1;; pos++) + { + char c = m_path [pos]; + if (c == '/') + { + if (currentComponent == componentIndex) + { + return m_path.substr (componentStart, pos - componentStart); + } + pos++; + componentStart = pos; + currentComponent++; + } + else if (c == '\0') + { + if (currentComponent == componentIndex) + { + return m_path.substr (componentStart, pos - componentStart); + } + } + } + return std::string (); +} + +uint32_t Path::GetComponentUint32 (uint32_t componentIndex) const +{ + std::istringstream iss; + iss.str (GetComponentString (componentIndex)); + uint32_t result; + iss >> result; + return result; +} + } // namespace Config } // namespace ns3 diff -r 2324032b8f90 src/core/config.h --- a/src/core/config.h Thu Mar 20 10:25:59 2008 -0700 +++ b/src/core/config.h Thu Mar 20 18:50:47 2008 +0000 @@ -118,6 +118,31 @@ void RegisterRootNamespaceObject (Ptr obj); + +class Path +{ +public: + Path (std::string path) : m_path (path) {} + std::string GetComponentString (uint32_t componentIndex) const; + uint32_t GetComponentUint32 (uint32_t componentIndex) const; + + friend inline bool operator != (const Path &pathA, const Path &pathB); + friend inline bool operator < (const Path &pathA, const Path &pathB); + +private: + std::string m_path; +}; + +inline bool operator != (const Path &pathA, const Path &pathB) +{ + return pathA.m_path != pathB.m_path; +} + +inline bool operator < (const Path &pathA, const Path &pathB) +{ + return pathA.m_path < pathB.m_path; +} + } // namespace Config } // namespace ns3 diff -r 2324032b8f90 src/core/traced-callback.h --- a/src/core/traced-callback.h Thu Mar 20 10:25:59 2008 -0700 +++ b/src/core/traced-callback.h Thu Mar 20 18:50:47 2008 +0000 @@ -24,6 +24,7 @@ #include #include "callback.h" +#include "config.h" namespace ns3 { @@ -80,9 +81,9 @@ void void TracedCallback::Connect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; cb.Assign (callback); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (Config::Path (path)); m_callbackList.push_back (realCb); } template::Disconnect (const CallbackBase & callback, std::string path) { - Callback cb; + Callback cb; cb.Assign (callback); - Callback realCb = cb.Bind (path); + Callback realCb = cb.Bind (Config::Path (path)); DisconnectWithoutContext (realCb); } template