View | Details | Raw Unified | Return to bug 148
Collapse All | Expand All

(-)a/examples/wifi-ap.cc (-6 / +6 lines)
 Lines 47-78   using namespace ns3; Link Here 
47
using namespace ns3;
47
using namespace ns3;
48
48
49
void
49
void
50
DevTxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
50
DevTxTrace (Config::Path context, Ptr<const Packet> p, Mac48Address address)
51
{
51
{
52
  std::cout << " TX to=" << address << " p: " << *p << std::endl;
52
  std::cout << " TX to=" << address << " p: " << *p << std::endl;
53
}
53
}
54
void
54
void
55
DevRxTrace (std::string context, Ptr<const Packet> p, Mac48Address address)
55
DevRxTrace (Config::Path context, Ptr<const Packet> p, Mac48Address address)
56
{
56
{
57
  std::cout << " RX from=" << address << " p: " << *p << std::endl;
57
  std::cout << " RX from=" << address << " p: " << *p << std::endl;
58
}
58
}
59
void
59
void
60
PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
60
PhyRxOkTrace (Config::Path context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
61
{
61
{
62
  std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl;
62
  std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl;
63
}
63
}
64
void
64
void
65
PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr)
65
PhyRxErrorTrace (Config::Path context, Ptr<const Packet> packet, double snr)
66
{
66
{
67
  std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl;
67
  std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl;
68
}
68
}
69
void
69
void
70
PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
70
PhyTxTrace (Config::Path context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
71
{
71
{
72
  std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
72
  std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl;
73
}
73
}
74
void
74
void
75
PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state)
75
PhyStateTrace (Config::Path context, Time start, Time duration, enum WifiPhy::State state)
76
{
76
{
77
  std::cout << " state=";
77
  std::cout << " state=";
78
  switch (state) {
78
  switch (state) {
(-)a/src/core/config.cc (+38 lines)
 Lines 469-474   void UnregisterRootNamespaceObject (Ptr< Link Here 
469
  Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
469
  Singleton<ConfigImpl>::Get ()->UnregisterRootNamespaceObject (obj);
470
}
470
}
471
471
472
std::string Path::GetComponentString (uint32_t componentIndex) const
473
{
474
  NS_ASSERT (m_path [0] == '/');
475
  std::string::size_type componentStart = 1;
476
  uint32_t currentComponent = 0;
477
  for (std::string::size_type pos = 1;; pos++)
478
    {
479
      char c = m_path [pos];
480
      if (c == '/')
481
        {
482
          if (currentComponent == componentIndex)
483
            {
484
              return m_path.substr (componentStart, pos - componentStart);
485
            }
486
          pos++;
487
          componentStart = pos;
488
          currentComponent++;
489
        }
490
      else if (c == '\0')
491
        {
492
          if (currentComponent == componentIndex)
493
            {
494
              return m_path.substr (componentStart, pos - componentStart);
495
            }
496
        }
497
    }
498
  return std::string ();
499
}
500
501
uint32_t Path::GetComponentUint32 (uint32_t componentIndex) const
502
{
503
  std::istringstream iss;
504
  iss.str (GetComponentString (componentIndex));
505
  uint32_t result;
506
  iss >> result;
507
  return result;
508
}
509
472
} // namespace Config
510
} // namespace Config
473
511
474
} // namespace ns3
512
} // namespace ns3
(-)a/src/core/config.h (+25 lines)
 Lines 118-123   void RegisterRootNamespaceObject (Ptr<Ob Link Here 
118
 */
118
 */
119
void UnregisterRootNamespaceObject (Ptr<Object> obj);
119
void UnregisterRootNamespaceObject (Ptr<Object> obj);
120
120
121
122
class Path
123
{
124
public:
125
  Path (std::string path) : m_path (path) {}
126
  std::string GetComponentString (uint32_t componentIndex) const;
127
  uint32_t GetComponentUint32 (uint32_t componentIndex) const;
128
129
  friend inline bool operator != (const Path &pathA, const Path &pathB);
130
  friend inline bool operator < (const Path &pathA, const Path &pathB);
131
132
private:
133
  std::string m_path;
134
};
135
136
inline bool operator != (const Path &pathA, const Path &pathB)
137
{
138
  return pathA.m_path != pathB.m_path;
139
}
140
141
inline bool operator < (const Path &pathA, const Path &pathB)
142
{
143
  return pathA.m_path < pathB.m_path;
144
}
145
121
} // namespace Config
146
} // namespace Config
122
147
123
} // namespace ns3
148
} // namespace ns3
(-)a/src/core/traced-callback.h (-4 / +5 lines)
 Lines 24-29    Link Here 
24
24
25
#include <list>
25
#include <list>
26
#include "callback.h"
26
#include "callback.h"
27
#include "config.h"
27
28
28
namespace ns3 {
29
namespace ns3 {
29
30
 Lines 80-88   void Link Here 
80
void 
81
void 
81
TracedCallback<T1,T2,T3,T4>::Connect (const CallbackBase & callback, std::string path)
82
TracedCallback<T1,T2,T3,T4>::Connect (const CallbackBase & callback, std::string path)
82
{
83
{
83
  Callback<void,std::string,T1,T2,T3,T4> cb;
84
  Callback<void,Config::Path,T1,T2,T3,T4> cb;
84
  cb.Assign (callback);
85
  cb.Assign (callback);
85
  Callback<void,T1,T2,T3,T4> realCb = cb.Bind (path);
86
  Callback<void,T1,T2,T3,T4> realCb = cb.Bind (Config::Path (path));
86
  m_callbackList.push_back (realCb);
87
  m_callbackList.push_back (realCb);
87
}
88
}
88
template<typename T1, typename T2, 
89
template<typename T1, typename T2, 
 Lines 108-116   void Link Here 
108
void 
109
void 
109
TracedCallback<T1,T2,T3,T4>::Disconnect (const CallbackBase & callback, std::string path)
110
TracedCallback<T1,T2,T3,T4>::Disconnect (const CallbackBase & callback, std::string path)
110
{
111
{
111
  Callback<void,std::string,T1,T2,T3,T4> cb;
112
  Callback<void,Config::Path,T1,T2,T3,T4> cb;
112
  cb.Assign (callback);
113
  cb.Assign (callback);
113
  Callback<void,T1,T2,T3,T4> realCb = cb.Bind (path);
114
  Callback<void,T1,T2,T3,T4> realCb = cb.Bind (Config::Path (path));
114
  DisconnectWithoutContext (realCb);
115
  DisconnectWithoutContext (realCb);
115
}
116
}
116
template<typename T1, typename T2, 
117
template<typename T1, typename T2, 

Return to bug 148