doc: Clarify specialization of GetInstanceTypeId()

This commit is contained in:
Tom Henderson
2025-01-07 10:38:53 -08:00
parent af9b91a791
commit b506ec1bc2
3 changed files with 12 additions and 8 deletions

View File

@@ -801,10 +801,13 @@ follows::
// continue on with constructor.
}
Beware that the object and all its derived classes must also implement
a :cpp:func:`GetInstanceTypeId()` method. Otherwise
the :cpp:func:`ObjectBase::ConstructSelf()` will not be able to read
the attributes.
Classes that derive from :cpp:class:`Object` can not implement (i.e., specialize)
a :cpp:func:`GetInstanceTypeId()` method; this method is marked `final`
in :cpp:class:`Object`. However, classes that instead derive from
:cpp:class:`ObjectBase` directly (in ns-3, this is usually packet headers and tags),
must implement :cpp:func:`GetInstanceTypeId()`. It is recommended that this
method simply return the value provided by :cpp:func:`GetTypeId()`; see the class
:cpp:class:`EthernetHeader` in `src/network/utils` directory as an example.
Adding Attributes
+++++++++++++++++