--- a/src/common/tags.cc Thu Feb 01 18:50:19 2007 +0100
+++ b/src/common/tags.cc Thu Feb 01 18:50:58 2007 +0100
@@ -42,7 +42,7 @@
m_sorted = true;
}
assert (m_sorted);
- uint32_t uid = 0;
+ uint32_t uid = 1;
for (TagsDataCI i = m_registry.begin (); i != m_registry.end (); i++)
{
if (i->first == uuid)
@@ -52,8 +52,7 @@
uid++;
}
// someone asked for a uid for an unregistered uuid.
- assert ("You tried to use unregistered tag: make sure you create an "
- "instance of type TagRegistration<YouTagType>.");
+ assert (!"You tried to use unregistered tag: make sure you create an instance of type TagRegistration<YouTagType>.");
// quiet compiler
return 0;
}
@@ -101,6 +100,7 @@
}
gN_free++;
data->m_next = gFree;
+ data->m_id = 0;
gFree = data;
}
#else
@@ -203,17 +203,17 @@
};
static void
-myTagAPrettyPrinterCb (struct myTagA *a, std::ostream &os)
+myTagAPrettyPrinterCb (struct myTagA const*a, std::ostream &os)
{
os << "struct myTagA, a="<<(uint32_t)a->a<<std::endl;
}
static void
-myTagBPrettyPrinterCb (struct myTagB *b, std::ostream &os)
+myTagBPrettyPrinterCb (struct myTagB const*b, std::ostream &os)
{
os << "struct myTagB, b="<<b->b<<std::endl;
}
static void
-myTagCPrettyPrinterCb (struct myTagC *c, std::ostream &os)
+myTagCPrettyPrinterCb (struct myTagC const*c, std::ostream &os)
{
os << "struct myTagC, c="<<(uint32_t)c->c[0]<<std::endl;
}
--- a/src/common/tags.h Thu Feb 01 18:50:19 2007 +0100
+++ b/src/common/tags.h Thu Feb 01 18:50:58 2007 +0100
@@ -96,10 +96,10 @@
* \param fn a function which can pretty-print an instance
* of type T in the output stream.
*/
- TagRegistration<T> (std::string uuid, void(*fn) (T *, std::ostream &));
+ TagRegistration<T> (std::string uuid, void(*fn) (T const*, std::ostream &));
private:
static void PrettyPrinterCb (uint8_t *buf, std::ostream &os);
- static void(*m_prettyPrinter) (T *, std::ostream &);
+ static void(*m_prettyPrinter) (T const*, std::ostream &);
};
}; // namespace ns3
@@ -118,6 +118,10 @@
public:
typedef void (*PrettyPrinter) (uint8_t [Tags::SIZE], std::ostream &);
static void Record (std::string uuid, PrettyPrinter prettyPrinter);
+ /**
+ * returns a numeric integer which uniquely identifies the input string.
+ * that integer cannot be zero which is a reserved value.
+ */
static uint32_t LookupUid (std::string uuid);
static void PrettyPrint (uint32_t uid, uint8_t buf[Tags::SIZE], std::ostream &os);
private:
@@ -173,7 +177,7 @@
* the call to the user-provided function.
*/
template <typename T>
-TagRegistration<T>::TagRegistration (std::string uuid, void (*prettyPrinter) (T *, std::ostream &))
+TagRegistration<T>::TagRegistration (std::string uuid, void (*prettyPrinter) (T const*, std::ostream &))
{
assert (sizeof (T) <= Tags::SIZE);
m_prettyPrinter = prettyPrinter;
@@ -190,7 +194,7 @@
}
template <typename T>
-void (*TagRegistration<T>::m_prettyPrinter) (T *, std::ostream &) = 0;
+void (*TagRegistration<T>::m_prettyPrinter) (T const*, std::ostream &) = 0;