|
|
| 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 |
} |
|
|
| 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); |