18 #include "ns3/boolean.h"
19 #include "ns3/callback.h"
20 #include "ns3/config.h"
21 #include "ns3/double.h"
23 #include "ns3/integer.h"
24 #include "ns3/nstime.h"
25 #include "ns3/object-factory.h"
26 #include "ns3/object-map.h"
27 #include "ns3/object-vector.h"
28 #include "ns3/object.h"
29 #include "ns3/pointer.h"
30 #include "ns3/random-variable-stream.h"
31 #include "ns3/string.h"
33 #include "ns3/trace-source-accessor.h"
34 #include "ns3/traced-value.h"
35 #include "ns3/uinteger.h"
167 TypeId(
"ns3::AttributeObjectTest")
170 .HideFromDocumentation()
171 .AddAttribute(
"TestBoolName",
176 .AddAttribute(
"TestBoolA",
182 .AddAttribute(
"TestInt16",
186 MakeIntegerChecker<int16_t>())
187 .AddAttribute(
"TestInt16WithBounds",
191 MakeIntegerChecker<int16_t>(-5, 10))
192 .AddAttribute(
"TestInt16SetGet",
197 MakeIntegerChecker<int16_t>())
198 .AddAttribute(
"TestUint8",
202 MakeUintegerChecker<uint8_t>())
203 .AddAttribute(
"TestEnum",
208 .AddAttribute(
"TestEnumSetGet",
214 .AddAttribute(
"TestRandom",
216 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"),
218 MakePointerChecker<RandomVariableStream>())
219 .AddAttribute(
"TestFloat",
223 MakeDoubleChecker<float>())
224 .AddAttribute(
"TestVector1",
228 MakeObjectVectorChecker<Derived>())
229 .AddAttribute(
"TestVector2",
234 MakeObjectVectorChecker<Derived>())
235 .AddAttribute(
"TestMap1",
239 MakeObjectMapChecker<Derived>())
240 .AddAttribute(
"IntegerTraceSource1",
244 MakeIntegerChecker<int8_t>())
245 .AddAttribute(
"IntegerTraceSource2",
250 MakeIntegerChecker<int8_t>())
251 .AddAttribute(
"UIntegerTraceSource",
255 MakeIntegerChecker<uint8_t>())
256 .AddAttribute(
"DoubleTraceSource",
260 MakeDoubleChecker<double>())
261 .AddAttribute(
"BoolTraceSource",
266 .AddAttribute(
"EnumTraceSource",
271 .AddAttribute(
"ValueClassSource",
275 MakeValueClassTestChecker())
276 .AddTraceSource(
"Source1",
279 "ns3::TracedValueCallback::Int8")
280 .AddTraceSource(
"Source2",
283 "ns3::AttributeObjectTest::NumericTracedCallback")
284 .AddTraceSource(
"ValueSource",
287 "ns3::ValueClassTest::TracedValueCallback")
288 .AddAttribute(
"Pointer",
292 MakePointerChecker<Derived>())
293 .AddAttribute(
"PointerInitialized",
297 MakePointerChecker<Derived>())
298 .AddAttribute(
"PointerInitialized2",
302 MakePointerChecker<Derived>())
303 .AddAttribute(
"Callback",
308 .AddAttribute(
"TestTimeWithBounds",
313 .AddAttribute(
"TestDeprecated",
319 "DEPRECATED test working.");
335 m_vector1.push_back(CreateObject<Derived>());
341 m_vector2.push_back(CreateObject<Derived>());
350 m_map1.insert(std::pair<uint32_t,
Ptr<Derived>>(i, CreateObject<Derived>()));
370 if (!m_cbValue.IsNull())
401 return m_int16SetGet;
419 return m_vector2.size();
491 typedef void (*NumericTracedCallback)(double,
int, float);
512 template <
typename T>
534 std::string attributeName,
535 std::string expectedString,
539 template <
typename T>
545 template <
typename T>
550 template <
typename T>
553 std::string attributeName,
554 std::string expectedString,
564 bool ok2 = stringValue.
Get() == expectedString;
570 bool ok4 = expectedValue.Get() == actualValue.Get();
572 return ok1 && ok2 && ok3 && ok4;
585 p = CreateObject<AttributeObjectTest>();
593 p = CreateObject<AttributeObjectTest>();
596 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
599 std::string expected(
"Attribute 'TestDeprecated' is deprecated: DEPRECATED test working.\n");
601 std::stringstream buffer;
602 std::streambuf* oldBuffer = std::cerr.rdbuf(buffer.rdbuf());
609 std::cerr.rdbuf(oldBuffer);
617 p = CreateObject<AttributeObjectTest>();
620 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
626 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"true"));
629 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
632 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
637 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"false"));
640 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
643 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
648 p = CreateObject<AttributeObjectTest>();
657 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"true"));
660 ok = CheckGetCodePaths(p,
"TestBoolA",
"true",
BooleanValue(
true));
664 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
669 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"false"));
672 ok = CheckGetCodePaths(p,
"TestBoolA",
"false",
BooleanValue(
false));
676 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
686 p = CreateObject<AttributeObjectTest>();
693 ok = CheckGetCodePaths(p,
"TestInt16",
"-2",
IntegerValue(-2));
699 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-5"));
702 ok = CheckGetCodePaths(p,
"TestInt16",
"-5",
IntegerValue(-5));
705 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
710 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"+2"));
713 ok = CheckGetCodePaths(p,
"TestInt16",
"2",
IntegerValue(2));
716 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
721 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32768"));
724 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
728 "Attribute not set properly by SetAttributeFailSafe() (most negative) via StringValue");
734 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32769"));
737 "Unexpectedly could SetAttributeFailSafe() via StringValue to -32769");
739 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
745 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32767"));
748 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
752 "Attribute not set properly by SetAttributeFailSafe() (most positive) via StringValue");
758 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32768"));
761 "Unexpectedly could SetAttributeFailSafe() via StringValue to 32768");
763 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
770 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(10));
773 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
777 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via StringValue");
782 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(11));
785 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11");
787 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
793 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-5));
796 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
800 "Attribute not set properly by SetAttributeFailSafe() (negative limit) via StringValue");
805 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-6));
808 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6");
810 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
821 p = CreateObject<AttributeObjectTest>();
828 ok = CheckGetCodePaths(p,
"TestUint8",
"1",
UintegerValue(1));
837 ok = CheckGetCodePaths(p,
"TestUint8",
"0",
UintegerValue(0));
840 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
845 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(255));
848 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
852 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
858 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(256));
861 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
868 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"255"));
871 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
874 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
880 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"256"));
883 "Unexpectedly could SetAttributeFailSafe() via StringValue to 256");
885 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
891 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"-1"));
894 "Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
904 p = CreateObject<AttributeObjectTest>();
911 ok = CheckGetCodePaths(p,
"TestFloat",
"-1.1",
DoubleValue(-1.1F));
917 ok = p->SetAttributeFailSafe(
"TestFloat",
DoubleValue(2.3F));
920 ok = CheckGetCodePaths(p,
"TestFloat",
"2.3",
DoubleValue(2.3F));
923 "Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
933 p = CreateObject<AttributeObjectTest>();
952 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
970 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
975 ok = p->SetAttributeFailSafe(
"TestEnum",
StringValue(
"TestB"));
981 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
997 ok = p->SetAttributeFailSafe(
"TestEnum",
EnumValue(5));
1011 p = CreateObject<AttributeObjectTest>();
1015 Time::SetResolution(Time::NS);
1023 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+5e+09ns",
TimeValue(
Seconds(5)));
1026 "Attribute not set properly by SetAttributeFailSafe(5s) via TimeValue");
1028 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
StringValue(
"3s"));
1031 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+3e+09ns",
TimeValue(
Seconds(3)));
1034 "Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
1044 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(10)));
1047 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1051 "Attribute not set properly by SetAttributeFailSafe(10s [positive limit]) via StringValue");
1056 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(11)));
1059 "Unexpectedly could SetAttributeFailSafe() via TimeValue to 11s [greater "
1060 "than positive limit]");
1062 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1068 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-5)));
1071 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1075 "Attribute not set properly by SetAttributeFailSafe(-5s [negative limit]) via StringValue");
1080 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-6)));
1083 "Unexpectedly could SetAttributeFailSafe() via TimeValue to -6s");
1085 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1120 void DoRun()
override;
1138 std::string description)
1149 p = CreateObject<AttributeObjectTest>();
1155 ok = p->SetAttributeFailSafe(
"TestRandom",
1156 StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
1162 ok = p->SetAttributeFailSafe(
"TestRandom",
1163 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
1188 void DoRun()
override;
1202 p = CreateObject<AttributeObjectTest>();
1209 p->GetAttribute(
"TestVector1", vector);
1212 "Initial count of ObjectVectorValue \"TestVector1\" should be zero");
1221 "Initial count of ObjectVectorValue \"TestVector1\" should still be zero");
1226 p->GetAttribute(
"TestVector1", vector);
1229 "ObjectVectorValue \"TestVector1\" should be incremented");
1243 "Count of ObjectVectorValue \"TestVector1\" should still be one");
1248 p->GetAttribute(
"TestVector1", vector);
1251 "ObjectVectorValue \"TestVector1\" should be incremented");
1273 void DoRun()
override;
1287 p = CreateObject<AttributeObjectTest>();
1294 p->GetAttribute(
"TestMap1", map);
1297 "Initial count of ObjectVectorValue \"TestMap1\" should be zero");
1305 "Initial count of ObjectVectorValue \"TestMap1\" should still be zero");
1310 p->GetAttribute(
"TestMap1", map);
1325 "Count of ObjectVectorValue \"TestMap1\" should still be one");
1330 p->GetAttribute(
"TestMap1", map);
1354 void DoRun()
override;
1369 p = CreateObject<AttributeObjectTest>();
1376 p->GetAttribute(
"IntegerTraceSource1", iv);
1382 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(5));
1385 p->GetAttribute(
"IntegerTraceSource1", iv);
1388 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1393 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(127));
1396 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(128));
1399 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1401 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-128));
1404 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-129));
1407 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1413 p->GetAttribute(
"IntegerTraceSource2", iv);
1419 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(5));
1422 p->GetAttribute(
"IntegerTraceSource2", iv);
1425 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1430 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(127));
1433 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(128));
1436 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1438 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-128));
1441 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-129));
1444 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1467 void DoRun()
override;
1493 p = CreateObject<AttributeObjectTest>();
1502 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-1));
1511 ok = p->TraceConnectWithoutContext(
1516 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1523 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(0));
1528 "Hitting a TracedValue does not cause trace callback to be called");
1534 ok = p->TraceDisconnectWithoutContext(
1539 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1541 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(1));
1546 "Hitting a TracedValue after disconnect still causes callback");
1569 void DoRun()
override;
1596 p = CreateObject<AttributeObjectTest>();
1612 p->InvokeCb(1.0, -5, 0.0);
1616 "Invoking a newly created TracedCallback results in an unexpected callback");
1622 ok = p->TraceConnectWithoutContext(
"Source2",
1630 p->InvokeCb(1.0, -5, 0.0);
1638 ok = p->TraceDisconnectWithoutContext(
1643 p->InvokeCb(-1.0, -5, 0.0);
1647 "Invoking disconnected TracedCallback unexpectedly results in trace callback");
1670 void DoRun()
override;
1697 p = CreateObject<AttributeObjectTest>();
1706 p->GetAttribute(
"Pointer", ptr);
1711 "Unexpectedly found non-null pointer in newly initialized PointerValue Attribute");
1717 derived = Create<Derived>();
1718 ok = p->SetAttributeFailSafe(
"Pointer",
PointerValue(derived));
1721 "Could not SetAttributeFailSafe() a PointerValue of the correct type");
1727 p->GetAttribute(
"Pointer", ptr);
1731 "Retrieved Attribute does not match stored PointerValue");
1739 p->GetAttribute(
"Pointer", ptr);
1743 "Retrieved Ptr<Object> does not match stored Ptr<Derived>");
1749 p->GetAttribute(
"Pointer", ptr);
1753 "Unexpectedly retrieved unrelated Ptr<type> from stored Ptr<Derived>");
1759 p->GetAttribute(
"PointerInitialized", ptr);
1763 p2->GetAttribute(
"PointerInitialized", ptr2);
1767 "ptr and ptr2 both have PointerInitialized pointing to the same object");
1769 p2->GetAttribute(
"PointerInitialized", ptr3);
1773 "ptr and ptr3 both have PointerInitialized pointing to the same object");
1779 factory.
SetTypeId(
"ns3::AttributeObjectTest");
1787 aotPtr->GetAttribute(
"PointerInitialized", ptr4);
1790 aotPtr2->GetAttribute(
"PointerInitialized", ptr5);
1794 "aotPtr and aotPtr2 are unique, but their Derived member is not");
1828 void DoRun()
override;
1855 p = CreateObject<AttributeObjectTest>();
1875 p->InvokeCbValue(2);
1880 ok = p->SetAttributeFailSafe(
"Callback", cbValue);
1886 p->InvokeCbValue(2);
1889 ok = p->SetAttributeFailSafe(
"Callback",
CallbackValue(MakeNullCallback<void, int8_t>()));
1895 p->InvokeCbValue(3);
1898 "Callback Attribute set to null callback unexpectedly fired");
1939 "Ensure TracedValue<uint8_t> can be set like IntegerValue"),
1945 "Ensure TracedCallback<double, int, float> works as trace source"),
static AttributesTestSuite g_attributesTestSuite
Static variable for test initialization.
Class used to check attributes.
std::size_t DoGetVectorN() const
Get the length of m_vector2.
bool DoSetIntSrc(int8_t v)
Set the m_intSrc2 value.
bool m_boolTest
Boolean test.
void AddToVector2()
Add an object to the second vector.
std::map< uint32_t, Ptr< Derived > > m_map1
Map of uint32_t, derived objects.
int16_t m_int16SetGet
16-bit integer set-get.
Test_e DoGetEnum() const
Get the m_enumSetGet value.
bool DoGetTestA() const
Get the m_boolTestA value.
void InvokeCb(double a, int b, float c)
Invoke the m_cb callback.
Ptr< Derived > DoGetVector(std::size_t i) const
Get the i-th item of m_vector2.
Ptr< RandomVariableStream > m_random
Random number generator.
bool m_boolTestA
Boolean test A.
int16_t m_int16
16-bit integer.
static TypeId GetTypeId()
Get the type ID.
~AttributeObjectTest() override
std::vector< Ptr< Derived > > m_vector1
First vector of derived objects.
Callback< void, int8_t > m_cbValue
Callback accepting an integer.
void InvokeCbValue(int8_t a)
Invoke the m_cbValue callback.
TracedValue< double > m_doubleSrc
double Traced value.
bool m_boolTestDeprecated
Boolean test deprecated.
void AddToMap1(uint32_t i)
Adds an object to the first map.
TracedCallback< double, int, float > m_cb
TracedCallback (double, int, float).
Ptr< Derived > m_ptr
Pointer to Derived class.
int16_t m_int16WithBounds
16-bit integer with bounds.
TracedValue< int8_t > m_intSrc1
First int8_t Traced value.
TracedValue< Test_e > m_enumSrc
enum Traced value.
Ptr< Derived > m_ptrInitialized
Pointer to Derived class.
void AddToVector1()
Add an object to the first vector.
Ptr< Derived > m_ptrInitialized2
Pointer to Derived class.
int16_t DoGetInt16() const
Get the m_int16SetGet value.
TracedValue< ValueClassTest > m_valueSrc
ValueClassTest Traced value.
void DoSetTestA(bool v)
Set the m_boolTestA value.
TracedValue< uint8_t > m_uintSrc
uint8_t Traced value.
TracedValue< bool > m_boolSrc
bool Traced value.
TracedValue< int8_t > m_intSrc2
Second int8_t Traced value.
Time m_timeWithBounds
Time with bounds.
int8_t DoGetIntSrc() const
Get the m_intSrc2 value.
uint8_t m_uint8
8-bit integer.
std::vector< Ptr< Derived > > m_vector2
Second vector of derived objects.
bool DoSetEnum(Test_e v)
Set the m_enumSetGet value.
void DoSetInt16(int16_t v)
Set the m_int16SetGet value.
Test case template used for generic Attribute Value types – used to make sure that Attributes work as...
~AttributeTestCase() override
bool CheckGetCodePaths(Ptr< Object > p, std::string attributeName, std::string expectedString, T expectedValue)
Check the attribute path and value.
AttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
The attributes Test Suite.
Test the Attributes of type CallbackValue.
CallbackValueTestCase(std::string description)
Constructor.
void NotifyCallbackValue(int8_t a)
Function invoked when the callback is fired.
void DoRun() override
Implementation to actually run this TestCase.
void InvokeCbValue(int8_t a)
Function to invoke the callback.
Callback< void, int8_t > m_cbValue
The callback.
~CallbackValueTestCase() override
int16_t m_gotCbValue
Value used to verify that source 2 was called.
Simple class derived from ns3::Object, used to check attribute constructors.
static TypeId GetTypeId()
Get the type ID.
Trace sources with value semantics can be used like Attributes, make sure we can use them that way.
IntegerTraceSourceAttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
~IntegerTraceSourceAttributeTestCase() override
Trace sources used like Attributes must also work as trace sources, make sure we can use them that wa...
int64_t m_got1
Value used to verify that source 1 was called.
void NotifySource1(int8_t old[[maybe_unused]], int8_t n)
Notify the call of source 1.
IntegerTraceSourceTestCase(std::string description)
Constructor.
~IntegerTraceSourceTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Test case for Object Map Attributes.
~ObjectMapAttributeTestCase() override
ObjectMapAttributeTestCase(std::string description)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Test case for Object Vector Attributes.
ObjectVectorAttributeTestCase(std::string description)
Constructor.
~ObjectVectorAttributeTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Smart pointers (Ptr) are central to our architecture, so they must work as attributes.
void DoRun() override
Implementation to actually run this TestCase.
void NotifySource2(double a, int b[[maybe_unused]], float c[[maybe_unused]])
Notify the call of source 2.
double m_got2
Value used to verify that source 2 was called.
~PointerAttributeTestCase() override
PointerAttributeTestCase(std::string description)
Constructor.
Test the Attributes of type RandomVariableStream.
void InvokeCbValue(int8_t a)
Invoke the m_cbValue.
Callback< void, int8_t > m_cbValue
Callback used in the test.
~RandomVariableStreamAttributeTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void NotifyCallbackValue(int8_t a)
Function called when the callback is used.
RandomVariableStreamAttributeTestCase(std::string description)
Constructor.
int16_t m_gotCbValue
Value used to verify that the callback has been invoked.
Trace sources used like Attributes must also work as trace sources, make sure we can use them that wa...
void NotifySource2(double a, int b[[maybe_unused]], float c[[maybe_unused]])
Notify the call of source 2.
~TracedCallbackTestCase() override
TracedCallbackTestCase(std::string description)
Constructor.
double m_got2
Value used to verify that source 2 was called.
void DoRun() override
Implementation to actually run this TestCase.
AttributeValue implementation for Boolean.
bool IsNull() const
Check for null implementation.
AttributeValue implementation for Callback.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Hold a signed integer type.
bool GetAttributeFailSafe(std::string name, AttributeValue &value) const
Get the value of an attribute without raising errors.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Container for a set of ns3::Object pointers.
std::size_t GetN() const
Get the number of Objects.
Ptr< Object > Get(std::size_t i) const
Get a specific Object.
Hold objects of type Ptr<T>.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId AddConstructor()
Record in this TypeId the fact that the default constructor is accessible.
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
Hold an unsigned integer type.
Test class for TracedValue callbacks attributes.
void(* TracedValueCallback)(const ValueClassTest oldValue, const ValueClassTest newValue)
TracedValue callback signature for ValueClassTest.
AttributeValue implementation for ValueClassTest.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeCallbackChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetDefault(std::string name, const AttributeValue &value)
bool SetDefaultFailSafe(std::string fullName, const AttributeValue &value)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#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.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
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.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
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...
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
ATTRIBUTE_HELPER_CPP(Length)
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)