19 #include "ns3/callback.h"
20 #include "ns3/config.h"
21 #include "ns3/integer.h"
23 #include "ns3/names.h"
24 #include "ns3/object-vector.h"
25 #include "ns3/object.h"
26 #include "ns3/pointer.h"
27 #include "ns3/singleton.h"
29 #include "ns3/trace-source-accessor.h"
30 #include "ns3/traced-value.h"
114 .AddAttribute(
"NodesA",
118 MakeObjectVectorChecker<ConfigTestObject>())
119 .AddAttribute(
"NodesB",
123 MakeObjectVectorChecker<ConfigTestObject>())
124 .AddAttribute(
"NodeA",
128 MakePointerChecker<ConfigTestObject>())
129 .AddAttribute(
"NodeB",
133 MakePointerChecker<ConfigTestObject>())
138 MakeIntegerChecker<int8_t>())
143 MakeIntegerChecker<int8_t>())
144 .AddAttribute(
"Source",
148 MakeIntegerChecker<int16_t>())
149 .AddTraceSource(
"Source",
152 "ns3::TracedValueCallback::Int16");
260 MakeIntegerChecker<int8_t>());
311 void DoRun()
override;
315 :
TestCase(
"Check ability to register a root namespace and use it")
333 root->GetAttribute(
"A", iv);
341 root->GetAttribute(
"A", iv);
347 root->GetAttribute(
"B", iv);
355 root->GetAttribute(
"B", iv);
375 void DoRun()
override;
379 :
TestCase(
"Check ability to register an object under the root namespace and use it")
400 a->GetAttribute(
"A", iv);
408 a->GetAttribute(
"A", iv);
414 a->GetAttribute(
"B", iv);
422 a->GetAttribute(
"B", iv);
429 a->GetAttribute(
"A", iv);
433 a->GetAttribute(
"B", iv);
444 b->GetAttribute(
"A", iv);
446 b->GetAttribute(
"B", iv);
457 b->GetAttribute(
"A", iv);
459 b->GetAttribute(
"B", iv);
466 a->GetAttribute(
"A", iv);
468 b->GetAttribute(
"A", iv);
488 void DoRun()
override;
492 :
TestCase(
"Check ability to configure vectors of Object using regular expressions")
538 obj0->GetAttribute(
"A", iv);
541 obj1->GetAttribute(
"A", iv);
544 obj2->GetAttribute(
"A", iv);
547 obj3->GetAttribute(
"A", iv);
555 obj0->GetAttribute(
"A", iv);
558 obj1->GetAttribute(
"A", iv);
561 obj2->GetAttribute(
"A", iv);
564 obj3->GetAttribute(
"A", iv);
571 obj0->GetAttribute(
"A", iv);
574 obj1->GetAttribute(
"A", iv);
577 obj2->GetAttribute(
"A", iv);
580 obj3->GetAttribute(
"A", iv);
587 obj0->GetAttribute(
"A", iv);
590 obj1->GetAttribute(
"A", iv);
593 obj2->GetAttribute(
"A", iv);
596 obj3->GetAttribute(
"A", iv);
603 obj0->GetAttribute(
"A", iv);
606 obj1->GetAttribute(
"A", iv);
609 obj2->GetAttribute(
"A", iv);
612 obj3->GetAttribute(
"A", iv);
619 obj0->GetAttribute(
"A", iv);
622 obj1->GetAttribute(
"A", iv);
625 obj2->GetAttribute(
"A", iv);
628 obj3->GetAttribute(
"A", iv);
652 void Trace(int16_t oldValue [[maybe_unused]], int16_t newValue)
663 void TraceWithPath(std::string path, int16_t old [[maybe_unused]], int16_t newValue)
670 void DoRun()
override;
677 :
TestCase(
"Check ability to trace connect through vectors of Object using regular expressions")
773 "/NodeA/NodeB/NodesB/0/Source",
774 "Trace 0 did not provide expected context");
785 "/NodeA/NodeB/NodesB/1/Source",
786 "Trace 1 did not provide expected context");
806 "/NodeA/NodeB/NodesB/1/Source",
807 "Trace 1 did not provide expected context");
830 void DoRun()
override;
834 :
TestCase(
"Check that attributes of base class are searchable from paths including objects of "
861 a->AggregateObject(derived);
863 derived->GetAttribute(
"X", iv);
Hold a signed integer type.
A base class which provides memory management and object aggregation.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
~BaseConfigObject() override
Destructor.
int8_t m_x
X attribute target.
static TypeId GetTypeId()
Get the type ID.
BaseConfigObject()
Constructor.
An object with some attributes that we can play with using config.
void AddNodeB(Ptr< ConfigTestObject > b)
Add node B function.
void AddNodeA(Ptr< ConfigTestObject > a)
Add node A function.
Ptr< ConfigTestObject > m_nodeA
NodeA attribute target.
std::vector< Ptr< ConfigTestObject > > m_nodesA
NodesA attribute target.
TracedValue< int16_t > m_trace
Source TraceSource target.
void SetNodeB(Ptr< ConfigTestObject > b)
Set node b function.
int8_t GetB() const
Get node b function.
int8_t m_b
B attribute target.
std::vector< Ptr< ConfigTestObject > > m_nodesB
NodesB attribute target.
int8_t m_a
A attribute target.
int8_t GetA() const
Get node A function.
static TypeId GetTypeId()
Get the type ID.
void SetNodeA(Ptr< ConfigTestObject > a)
Set node A function.
Ptr< ConfigTestObject > m_nodeB
NodeB attribute target.
The Test Suite that glues all of the Test Cases together.
ConfigTestSuite()
Constructor.
static TypeId GetTypeId()
Get the type ID.
~DerivedConfigObject() override
Destructor.
DerivedConfigObject()
Constructor.
~DerivedConfigTestObject() override
Destructor.
static TypeId GetTypeId()
Get the type ID.
DerivedConfigTestObject()
Constructor.
Test for the ability to deal configure with vectors of objects.
void DoRun() override
Implementation to actually run this TestCase.
~ObjectVectorConfigTestCase() override
Destructor.
ObjectVectorConfigTestCase()
Constructor.
Test for the ability to trace configure with vectors of objects.
void Trace(int16_t oldValue[[maybe_unused]], int16_t newValue)
Trace callback without context.
int16_t m_newValue
Flag to detect tracing result.
std::string m_path
The context path.
void TraceWithPath(std::string path, int16_t old[[maybe_unused]], int16_t newValue)
Trace callback with context path.
~ObjectVectorTraceConfigTestCase() override
Destructor.
ObjectVectorTraceConfigTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test for the ability to register and use a root namespace.
RootNamespaceConfigTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~RootNamespaceConfigTestCase() override
Destructor.
Test for the ability to search attributes of parent classes when Resolver searches for attributes in ...
~SearchAttributesOfParentObjectsTestCase() override
Destructor.
SearchAttributesOfParentObjectsTestCase()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test for the ability to add an object under the root namespace.
void DoRun() override
Implementation to actually run this TestCase.
UnderRootNamespaceConfigTestCase()
Constructor.
~UnderRootNamespaceConfigTestCase() override
Destructor.
static ConfigTestSuite g_configTestSuite
ConfigTestSuite instance variable.
void Connect(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void Set(std::string path, const AttributeValue &value)
void RegisterRootNamespaceObject(Ptr< Object > obj)
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.