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"
175 TypeId(
"ns3::AttributeObjectTest")
178 .HideFromDocumentation()
179 .AddAttribute(
"TestBoolName",
184 .AddAttribute(
"TestBoolA",
190 .AddAttribute(
"TestInt16",
194 MakeIntegerChecker<int16_t>())
195 .AddAttribute(
"TestInt16WithBounds",
199 MakeIntegerChecker<int16_t>(-5, 10))
200 .AddAttribute(
"TestInt16SetGet",
205 MakeIntegerChecker<int16_t>())
206 .AddAttribute(
"TestUint8",
210 MakeUintegerChecker<uint8_t>())
211 .AddAttribute(
"TestEnum",
216 .AddAttribute(
"TestEnumSetGet",
222 .AddAttribute(
"TestEnumClass",
232 .AddAttribute(
"TestEnumClassSetGet",
243 .AddAttribute(
"TestRandom",
245 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"),
247 MakePointerChecker<RandomVariableStream>())
248 .AddAttribute(
"TestFloat",
252 MakeDoubleChecker<float>())
253 .AddAttribute(
"TestVector1",
257 MakeObjectVectorChecker<Derived>())
258 .AddAttribute(
"TestVector2",
263 MakeObjectVectorChecker<Derived>())
264 .AddAttribute(
"TestMap1",
268 MakeObjectMapChecker<Derived>())
269 .AddAttribute(
"TestUnorderedMap",
273 MakeObjectMapChecker<Derived>())
274 .AddAttribute(
"IntegerTraceSource1",
278 MakeIntegerChecker<int8_t>())
279 .AddAttribute(
"IntegerTraceSource2",
284 MakeIntegerChecker<int8_t>())
285 .AddAttribute(
"UIntegerTraceSource",
289 MakeIntegerChecker<uint8_t>())
290 .AddAttribute(
"DoubleTraceSource",
294 MakeDoubleChecker<double>())
295 .AddAttribute(
"BoolTraceSource",
306 .AddAttribute(
"ValueClassSource",
310 MakeValueClassTestChecker())
311 .AddTraceSource(
"Source1",
314 "ns3::TracedValueCallback::Int8")
315 .AddTraceSource(
"Source2",
318 "ns3::AttributeObjectTest::NumericTracedCallback")
319 .AddTraceSource(
"ValueSource",
322 "ns3::ValueClassTest::TracedValueCallback")
323 .AddAttribute(
"Pointer",
327 MakePointerChecker<Derived>())
328 .AddAttribute(
"PointerInitialized",
332 MakePointerChecker<Derived>())
333 .AddAttribute(
"PointerInitialized2",
337 MakePointerChecker<Derived>())
338 .AddAttribute(
"Callback",
343 .AddAttribute(
"TestTimeWithBounds",
348 .AddAttribute(
"TestDeprecated",
354 "DEPRECATED test working.");
370 m_vector1.push_back(CreateObject<Derived>());
376 m_vector2.push_back(CreateObject<Derived>());
385 m_map1.insert(std::pair<uint32_t,
Ptr<Derived>>(i, CreateObject<Derived>()));
394 m_unorderedMap.insert({i, CreateObject<Derived>()});
403 m_unorderedMap.erase(i);
423 if (!m_cbValue.IsNull())
454 return m_int16SetGet;
472 return m_vector2.size();
532 m_enumClassSetGet = v;
542 return m_enumClassSetGet;
561 std::unordered_map<uint64_t, Ptr<Derived>>
568 typedef void (*NumericTracedCallback)(double, int, float);
589 template <
typename T>
611 std::string attributeName,
612 std::string expectedString,
616 template <
typename T>
622 template <
typename T>
627 template <
typename T>
630 std::string attributeName,
631 std::string expectedString,
641 bool ok2 = stringValue.
Get() == expectedString;
647 bool ok4 = expectedValue.Get() == actualValue.Get();
649 return ok1 && ok2 && ok3 && ok4;
659 auto p = CreateObject<AttributeObjectTest>();
667 p = CreateObject<AttributeObjectTest>();
670 bool ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
673 std::string expected(
"Attribute 'TestDeprecated' is deprecated: DEPRECATED test working.\n");
675 std::stringstream buffer;
676 std::streambuf* oldBuffer = std::cerr.rdbuf(buffer.rdbuf());
683 std::cerr.rdbuf(oldBuffer);
691 p = CreateObject<AttributeObjectTest>();
694 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
700 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"true"));
703 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
706 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
711 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"false"));
714 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
717 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
722 p = CreateObject<AttributeObjectTest>();
731 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"true"));
734 ok = CheckGetCodePaths(p,
"TestBoolA",
"true",
BooleanValue(
true));
738 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
743 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"false"));
746 ok = CheckGetCodePaths(p,
"TestBoolA",
"false",
BooleanValue(
false));
750 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
757 auto p = CreateObject<AttributeObjectTest>();
764 bool ok = CheckGetCodePaths(p,
"TestInt16",
"-2",
IntegerValue(-2));
770 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-5"));
773 ok = CheckGetCodePaths(p,
"TestInt16",
"-5",
IntegerValue(-5));
776 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
781 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"+2"));
784 ok = CheckGetCodePaths(p,
"TestInt16",
"2",
IntegerValue(2));
787 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
792 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32768"));
795 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
799 "Attribute not set properly by SetAttributeFailSafe() (most negative) via StringValue");
805 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32769"));
808 "Unexpectedly could SetAttributeFailSafe() via StringValue to -32769");
810 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
816 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32767"));
819 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
823 "Attribute not set properly by SetAttributeFailSafe() (most positive) via StringValue");
829 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32768"));
832 "Unexpectedly could SetAttributeFailSafe() via StringValue to 32768");
834 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
841 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(10));
844 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
848 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via StringValue");
853 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(11));
856 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11");
858 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
864 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-5));
867 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
871 "Attribute not set properly by SetAttributeFailSafe() (negative limit) via StringValue");
876 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-6));
879 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6");
881 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
889 auto p = CreateObject<AttributeObjectTest>();
896 bool ok = CheckGetCodePaths(p,
"TestUint8",
"1",
UintegerValue(1));
905 ok = CheckGetCodePaths(p,
"TestUint8",
"0",
UintegerValue(0));
908 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
913 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(255));
916 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
920 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
926 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(256));
929 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
936 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"255"));
939 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
942 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
948 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"256"));
951 "Unexpectedly could SetAttributeFailSafe() via StringValue to 256");
953 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
959 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"-1"));
962 "Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
969 auto p = CreateObject<AttributeObjectTest>();
976 bool ok = CheckGetCodePaths(p,
"TestFloat",
"-1.1",
DoubleValue(-1.1F));
982 ok = p->SetAttributeFailSafe(
"TestFloat",
DoubleValue(2.3F));
985 ok = CheckGetCodePaths(p,
"TestFloat",
"2.3",
DoubleValue(2.3F));
988 "Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
995 auto p = CreateObject<AttributeObjectTest>();
1014 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1032 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1037 ok = p->SetAttributeFailSafe(
"TestEnum",
StringValue(
"TestB"));
1043 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
1059 ok = p->SetAttributeFailSafe(
"TestEnum",
EnumValue(5));
1070 auto p = CreateObject<AttributeObjectTest>();
1077 bool ok = CheckGetCodePaths(p,
1089 ok = CheckGetCodePaths(p,
1095 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1101 ok = CheckGetCodePaths(p,
1102 "TestEnumClassSetGet",
1110 ok = p->SetAttributeFailSafe(
"TestEnumClassSetGet",
1114 ok = CheckGetCodePaths(p,
1115 "TestEnumClassSetGet",
1120 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1125 ok = p->SetAttributeFailSafe(
"TestEnumClass",
StringValue(
"TestE"));
1128 ok = CheckGetCodePaths(p,
1134 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
1143 ok = CheckGetCodePaths(p,
1153 ok = p->SetAttributeFailSafe(
"TestEnumClass",
EnumValue(5));
1156 ok = CheckGetCodePaths(p,
1167 auto p = CreateObject<AttributeObjectTest>();
1171 Time::SetResolution(Time::NS);
1176 bool ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(5)));
1179 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+5e+09ns",
TimeValue(
Seconds(5)));
1182 "Attribute not set properly by SetAttributeFailSafe(5s) via TimeValue");
1184 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
StringValue(
"3s"));
1187 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+3e+09ns",
TimeValue(
Seconds(3)));
1190 "Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
1200 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(10)));
1203 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1207 "Attribute not set properly by SetAttributeFailSafe(10s [positive limit]) via StringValue");
1212 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(11)));
1215 "Unexpectedly could SetAttributeFailSafe() via TimeValue to 11s [greater "
1216 "than positive limit]");
1218 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1224 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-5)));
1227 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1231 "Attribute not set properly by SetAttributeFailSafe(-5s [negative limit]) via StringValue");
1236 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-6)));
1239 "Unexpectedly could SetAttributeFailSafe() via TimeValue to -6s");
1241 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1276 void DoRun()
override;
1294 std::string description)
1302 auto p = CreateObject<AttributeObjectTest>();
1308 bool ok = p->SetAttributeFailSafe(
"TestRandom",
1309 StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
1315 ok = p->SetAttributeFailSafe(
"TestRandom",
1316 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
1341 void DoRun()
override;
1354 auto p = CreateObject<AttributeObjectTest>();
1361 p->GetAttribute(
"TestVector1", vector);
1364 "Initial count of ObjectVectorValue \"TestVector1\" should be zero");
1373 "Initial count of ObjectVectorValue \"TestVector1\" should still be zero");
1378 p->GetAttribute(
"TestVector1", vector);
1381 "ObjectVectorValue \"TestVector1\" should be incremented");
1395 "Count of ObjectVectorValue \"TestVector1\" should still be one");
1400 p->GetAttribute(
"TestVector1", vector);
1403 "ObjectVectorValue \"TestVector1\" should be incremented");
1425 void DoRun()
override;
1438 auto p = CreateObject<AttributeObjectTest>();
1445 p->GetAttribute(
"TestMap1", map);
1448 "Initial count of ObjectVectorValue \"TestMap1\" should be zero");
1456 "Initial count of ObjectVectorValue \"TestMap1\" should still be zero");
1461 p->GetAttribute(
"TestMap1", map);
1476 "Count of ObjectVectorValue \"TestMap1\" should still be one");
1481 p->GetAttribute(
"TestMap1", map);
1489 p->AddToUnorderedMap(4);
1490 p->AddToUnorderedMap(2);
1491 p->AddToUnorderedMap(1);
1492 p->AddToUnorderedMap(3);
1494 p->RemoveFromUnorderedMap(2);
1495 p->GetAttribute(
"TestUnorderedMap", unorderedMap);
1498 "ObjectMapValue \"TestUnorderedMap\" should have three values");
1502 "ObjectMapValue \"TestUnorderedMap\" should have value with key 1");
1506 "ObjectMapValue \"TestUnorderedMap\" should not have value with key 2");
1507 auto it = unorderedMap.
Begin();
1510 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 1");
1514 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 3");
1518 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 4");
1541 void DoRun()
override;
1554 auto p = CreateObject<AttributeObjectTest>();
1561 p->GetAttribute(
"IntegerTraceSource1", iv);
1567 bool ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(5));
1570 p->GetAttribute(
"IntegerTraceSource1", iv);
1573 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1578 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(127));
1581 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(128));
1584 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1586 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-128));
1589 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-129));
1592 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1598 p->GetAttribute(
"IntegerTraceSource2", iv);
1604 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(5));
1607 p->GetAttribute(
"IntegerTraceSource2", iv);
1610 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1615 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(127));
1618 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(128));
1621 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1623 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-128));
1626 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-129));
1629 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1652 void DoRun()
override;
1675 auto p = CreateObject<AttributeObjectTest>();
1684 bool ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-1));
1693 ok = p->TraceConnectWithoutContext(
1698 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1705 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(0));
1710 "Hitting a TracedValue does not cause trace callback to be called");
1716 ok = p->TraceDisconnectWithoutContext(
1721 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1723 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(1));
1728 "Hitting a TracedValue after disconnect still causes callback");
1751 void DoRun()
override;
1775 auto p = CreateObject<AttributeObjectTest>();
1791 p->InvokeCb(1.0, -5, 0.0);
1795 "Invoking a newly created TracedCallback results in an unexpected callback");
1802 p->TraceConnectWithoutContext(
"Source2",
1810 p->InvokeCb(1.0, -5, 0.0);
1818 ok = p->TraceDisconnectWithoutContext(
1823 p->InvokeCb(-1.0, -5, 0.0);
1827 "Invoking disconnected TracedCallback unexpectedly results in trace callback");
1850 void DoRun()
override;
1874 auto p = CreateObject<AttributeObjectTest>();
1883 p->GetAttribute(
"Pointer", ptr);
1888 "Unexpectedly found non-null pointer in newly initialized PointerValue Attribute");
1894 derived = Create<Derived>();
1895 bool ok = p->SetAttributeFailSafe(
"Pointer",
PointerValue(derived));
1898 "Could not SetAttributeFailSafe() a PointerValue of the correct type");
1904 p->GetAttribute(
"Pointer", ptr);
1908 "Retrieved Attribute does not match stored PointerValue");
1916 p->GetAttribute(
"Pointer", ptr);
1920 "Retrieved Ptr<Object> does not match stored Ptr<Derived>");
1926 p->GetAttribute(
"Pointer", ptr);
1930 "Unexpectedly retrieved unrelated Ptr<type> from stored Ptr<Derived>");
1936 p->GetAttribute(
"PointerInitialized", ptr);
1940 p2->GetAttribute(
"PointerInitialized", ptr2);
1944 "ptr and ptr2 both have PointerInitialized pointing to the same object");
1946 p2->GetAttribute(
"PointerInitialized", ptr3);
1950 "ptr and ptr3 both have PointerInitialized pointing to the same object");
1956 factory.
SetTypeId(
"ns3::AttributeObjectTest");
1964 aotPtr->GetAttribute(
"PointerInitialized", ptr4);
1967 aotPtr2->GetAttribute(
"PointerInitialized", ptr5);
1971 "aotPtr and aotPtr2 are unique, but their Derived member is not");
2005 void DoRun()
override;
2029 auto p = CreateObject<AttributeObjectTest>();
2049 p->InvokeCbValue(2);
2054 bool ok = p->SetAttributeFailSafe(
"Callback", cbValue);
2060 p->InvokeCbValue(2);
2063 ok = p->SetAttributeFailSafe(
"Callback",
CallbackValue(MakeNullCallback<void, int8_t>()));
2069 p->InvokeCbValue(3);
2072 "Callback Attribute set to null callback unexpectedly fired");
2098 "Check Attributes of type EnumValue"),
2101 "Check Attributes of type EnumValue (wrapping an enum class)"),
2117 "Ensure TracedValue<uint8_t> can be set like IntegerValue"),
2123 "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.
std::unordered_map< uint64_t, Ptr< Derived > > m_unorderedMap
Unordered map of uint64_t, derived objects.
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.
Test_ec m_enumClassSetGet
Enum class set-get.
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.
Test_ec m_enumclass
Enum class.
Ptr< RandomVariableStream > m_random
Random number generator.
bool m_boolTestA
Boolean test A.
int16_t m_int16
16-bit integer.
void AddToUnorderedMap(uint64_t i)
Adds an object to the unordered map.
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.
Test_ec DoGetEnumClass() const
Get the m_enumClassSetGet value.
TracedCallback< double, int, float > m_cb
TracedCallback (double, int, float).
bool DoSetEnumClass(Test_ec v)
Set the m_enumClassSetGet value.
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.
Test_e m_enumSetGet
Enum set-get.
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 RemoveFromUnorderedMap(uint64_t i)
Remove an object from the first map.
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.
bool IsNull() const
Check for null implementation.
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.
Iterator Begin() const
Get an iterator to the first Object.
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.
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.
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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeChecker > MakeEnumChecker(T 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.
ATTRIBUTE_HELPER_CPP(ValueClassTest)
Ptr< const AttributeChecker > MakeCallbackChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.