diff --git a/src/common/tags.h b/src/common/tags.h index eee5807fd..6f9db0b8b 100644 --- a/src/common/tags.h +++ b/src/common/tags.h @@ -80,6 +80,8 @@ private: }; /** + * \brief pretty print packet tags + * * This class is used to register a pretty-printer * callback function to print in a nice user-friendly * way the content of the target type. To register @@ -92,7 +94,11 @@ private: template class TagPrettyPrinter { public: - TagPrettyPrinter (void(*) (T *, std::ostream &)); + /** + * \param fn a function which can pretty-print an instance + * of type T in the output stream. + */ + TagPrettyPrinter (void(*fn) (T *, std::ostream &)); private: TagPrettyPrinter (); static void prettyPrintCb (uint8_t *buf, std::ostream &os); @@ -113,6 +119,10 @@ private: }; // namespace ns3 + +/************************************************************** + An implementation of the templates defined above + *************************************************************/ #include #include @@ -161,13 +171,14 @@ const uint32_t TypeUid::getUid (void) template TagPrettyPrinter::TagPrettyPrinter (void(*prettyPrinter) (T *, std::ostream &)) { + assert (sizeof (T) <= Tags::SIZE); gPrettyPrinter = prettyPrinter; TagsPrettyPrinterRegistry::record (TypeUid::getUid (), &TagPrettyPrinter::prettyPrintCb); } template void -TagPrettyPrinter::prettyPrintCb (uint8_t buf[Tags::SIZE], std::ostream &os) +TagPrettyPrinter::prettyPrintCb (uint8_t *buf, std::ostream &os) { assert (sizeof (T) <= Tags::SIZE); T *tag = reinterpret_cast (buf);