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

(-)a/src/common/tags.cc (-9 / +11 lines)
 Lines 23-51    Link Here 
23
23
24
namespace ns3 {
24
namespace ns3 {
25
25
26
bool TagRegistry::m_sorted;
26
TagRegistry::TagsData *TagRegistry::m_registry = 0;
27
TagRegistry::TagsData TagRegistry::m_registry;
27
bool TagRegistry::m_sorted = false;
28
28
29
29
30
void 
30
void 
31
TagRegistry::Record (std::string uuid, PrettyPrinter prettyPrinter)
31
TagRegistry::Record (std::string uuid, PrettyPrinter prettyPrinter)
32
{
32
{
33
  if (m_registry == 0)
34
    m_registry = new TagRegistry::TagsData;
33
  NS_ASSERT (!m_sorted);
35
  NS_ASSERT (!m_sorted);
34
  m_registry.push_back (make_pair (uuid, prettyPrinter));
36
  m_registry->push_back (make_pair (uuid, prettyPrinter));
35
}
37
}
36
uint32_t 
38
uint32_t 
37
TagRegistry::LookupUid (std::string uuid)
39
TagRegistry::LookupUid (std::string uuid)
38
{
40
{
39
  if (!m_sorted) 
41
  if (!m_sorted) 
40
    {
42
    {
41
  	std::sort (m_registry.begin (), m_registry.end ());
43
  	std::sort (m_registry->begin (), m_registry->end ());
42
  	m_sorted = true;
44
  	m_sorted = true;
43
    }
45
    }
44
  NS_ASSERT (m_sorted);
46
  NS_ASSERT (m_sorted);
45
  uint32_t uid = 1;
47
  uint32_t uid = 1;
46
  for (TagsDataCI i = m_registry.begin (); i != m_registry.end (); i++) 
48
  for (TagsDataCI i = m_registry->begin (); i != m_registry->end (); i++) 
47
    {
49
    {
48
  	if (i->first == uuid) 
50
 	if (i->first == uuid) 
49
        {
51
        {
50
  		return uid;
52
  		return uid;
51
        }
53
        }
 Lines 59-66   void Link Here 
59
void 
61
void 
60
TagRegistry::PrettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os)
62
TagRegistry::PrettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os)
61
{
63
{
62
  NS_ASSERT (m_registry.size () > uid);
64
  NS_ASSERT (m_registry->size () > uid);
63
  PrettyPrinter prettyPrinter = m_registry[uid].second;
65
  PrettyPrinter prettyPrinter = (*m_registry)[uid].second;
64
  if (prettyPrinter != 0) 
66
  if (prettyPrinter != 0) 
65
    {
67
    {
66
  	prettyPrinter (buf, os);
68
  	prettyPrinter (buf, os);
(-)a/src/common/tags.h (-1 / +1 lines)
 Lines 128-134   private: Link Here 
128
  typedef std::vector<std::pair<std::string,PrettyPrinter> > TagsData;
128
  typedef std::vector<std::pair<std::string,PrettyPrinter> > TagsData;
129
  typedef std::vector<std::pair<std::string,PrettyPrinter> >::const_iterator TagsDataCI;
129
  typedef std::vector<std::pair<std::string,PrettyPrinter> >::const_iterator TagsDataCI;
130
  static bool m_sorted;
130
  static bool m_sorted;
131
  static TagsData m_registry;
131
  static TagsData *m_registry;
132
};
132
};
133
/**
133
/**
134
 * The TypeUid class is used to create a mapping Type --> uid
134
 * The TypeUid class is used to create a mapping Type --> uid

Return to bug 17