10#include "ns3/core-module.h"
23class AlphaProt :
public std::enable_if_t<std::is_same_v<Object, T>, T>
46class BetaProt :
public std::enable_if_t<std::is_same_v<Object, T>, T>
71main(
int argc,
char* argv[])
75 std::string alphaName(
"ns3::alphaTest::AlphaProt<Object>");
76 std::string alphaClassName(alpha->GetInstanceTypeId().GetName());
79 if (alphaClassName != alphaName)
81 std::cerr <<
"Unexpected templated class name (\"" << alphaClassName <<
"\" instead of \""
82 << alphaName <<
"\")";
85 if (alphaClassNameDirect != alphaName)
87 std::cerr <<
"Unexpected templated class name (\"" << alphaClassNameDirect
88 <<
"\" instead of \"" << alphaName <<
"\")";
94 std::string betaName(
"ns3::BetaProt<Object>");
95 std::string betaClassName(beta->GetInstanceTypeId().GetName());
98 if (betaClassName != betaName)
100 std::cerr <<
"Unexpected templated class name (\"" << betaClassName <<
"\" instead of \""
101 << betaName <<
"\")";
104 if (betaClassNameDirect != betaName)
106 std::cerr <<
"Unexpected templated class name (\"" << betaClassNameDirect
107 <<
"\" instead of \"" << betaName <<
"\")";
Test class, inside the namespace ns3.
static TypeId GetTypeId()
Get the TypeId.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Test class, inside the namespace ns3::alphaTest.
static TypeId GetTypeId()
Get the TypeId.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_TEMPLATE_CLASS_WITH_NS_DEFINE(nst, type, nsp, param)
Explicitly instantiate a template class with one template parameter and register the resulting instan...
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class with one template parameter and register the resulting instan...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetTemplateClassName()
Helper function to get the name (as a string) of the type of a template class.