diff --git a/src/common/header.h b/src/common/header.h index e82ae1c16..39ff037c6 100644 --- a/src/common/header.h +++ b/src/common/header.h @@ -63,20 +63,24 @@ namespace ns3 { * * Each header must also make sure that: * - it defines a public default constructor - * - it defines a public static method named GetUid which returns a string. + * - it defines a public static method named GetUid which returns a 32 bit integer * - * The latter should look like the following to ensure that - * every header returns a unique string. + * The latter should look like the following: * \code + * // in the header, * class MyHeader : public Header * { * public: - * static const char *GetUid (void); + * static uint32_t GetUid (void); * }; * - * const char *MyHeader::GetUid (void) + * // in the source file: + * NS_HEADER_ENSURE_REGISTERED (MyHeader); + * + * uint32_t MyHeader::GetUid (void) * { - * return "MyHeader.unique.prefix"; + * static uint32_t uid = Header::Register ("MyHeader.unique.prefix"); + * return uid; * } * \endcode * diff --git a/src/common/packet.h b/src/common/packet.h index f4b0af11d..ce614d2c6 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -327,6 +327,7 @@ private: * * So, a tag class should look like this: * \code + * // in header file * // note how a tag class does not derive from any other class. * class MyTag * { @@ -334,9 +335,9 @@ private: * // we need a public default constructor * MyTag (); * // we need a public static GetUid - * // GetUid must return a string which uniquely + * // GetUid must return a 32 bit integer which uniquely * // identifies this tag type - * static std::string GetUid (void); + * static uint32_t GetUid (void); * // Print should record in the output stream * // the content of the tag instance. * void Print (std::ostream &os) const; @@ -352,11 +353,16 @@ private: * uint32_t Deserialize (Buffer::Iterator i); * }; * + * // in source file + * + * NS_TAG_ENSURE_REGISTERED (MyTag); + * * std::string MyTag::GetUid (void) * { * // we really want to make sure that this * // string is unique in the universe. - * return "MyTag.unique.prefix"; + * static uint32_t uid = TagRegistry ("MyTag.unique.prefix"); + * return uid; * } * \endcode */ diff --git a/src/common/trailer.h b/src/common/trailer.h index 6184f8a5f..b7a306a17 100644 --- a/src/common/trailer.h +++ b/src/common/trailer.h @@ -63,20 +63,24 @@ namespace ns3 { * * Each trailer must also make sure that: * - it defines a public default constructor - * - it defines a public static method named GetUid which returns a string. + * - it defines a public static method named GetUid which returns a 32 bit integer. * - * The latter should look like the following to ensure that - * every trailer returns a unique string. + * The latter should look like the following: * \code + * // in the header * class MyTrailer : public Header * { * public: - * static const char *GetUid (void); + * static uint32_t GetUid (void); * }; * - * const char *MyTrailer::GetUid (void) + * // in the source file + * NS_TRAILER_ENSURE_REGISTERED (MyTrailer); + * + * uint32_t MyTrailer::GetUid (void) * { - * return "MyTrailer.unique.prefix"; + * static uint32_t uid = Trailer::Register ("MyTrailer.unique.prefix"); + * return uid; * } * \endcode *