diff --git a/doc/manual/source/new-models.rst b/doc/manual/source/new-models.rst index db813d2c1..5f88b6c23 100644 --- a/doc/manual/source/new-models.rst +++ b/doc/manual/source/new-models.rst @@ -385,6 +385,29 @@ every class that defines a new GetTypeId method, and it does the actual registration of the class into the system. The :ref:`Object-model` chapter discusses this in more detail. +Note: Template classes should both export the instantiated template and call +``NS_OBJECT_TEMPLATE_CLASS_DEFINE (TemplateClass, TemplateArgument);`` +to prevent the same template from being instantiated more than a single +time in different modules. This prevents errors such as +``Trying to allocate twice the same uid: TemplateClass``. + +An example for the ``CounterCalculator``:: + + //.h file + namespace ns3 + { + extern template class CounterCalculator; + } + //.cc file + #include + namespace ns3 + { + NS_OBJECT_TEMPLATE_CLASS_DEFINE (CounterCalculator, uint32_t); + } + +More details can be found in `issue #761 `_. + + Including External Files ++++++++++++++++++++++++