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(
"TestUnorderedMap",
244 MakeObjectMapChecker<Derived>())
245 .AddAttribute(
"IntegerTraceSource1",
249 MakeIntegerChecker<int8_t>())
250 .AddAttribute(
"IntegerTraceSource2",
255 MakeIntegerChecker<int8_t>())
256 .AddAttribute(
"UIntegerTraceSource",
260 MakeIntegerChecker<uint8_t>())
261 .AddAttribute(
"DoubleTraceSource",
265 MakeDoubleChecker<double>())
266 .AddAttribute(
"BoolTraceSource",
271 .AddAttribute(
"EnumTraceSource",
276 .AddAttribute(
"ValueClassSource",
280 MakeValueClassTestChecker())
281 .AddTraceSource(
"Source1",
284 "ns3::TracedValueCallback::Int8")
285 .AddTraceSource(
"Source2",
288 "ns3::AttributeObjectTest::NumericTracedCallback")
289 .AddTraceSource(
"ValueSource",
292 "ns3::ValueClassTest::TracedValueCallback")
293 .AddAttribute(
"Pointer",
297 MakePointerChecker<Derived>())
298 .AddAttribute(
"PointerInitialized",
302 MakePointerChecker<Derived>())
303 .AddAttribute(
"PointerInitialized2",
307 MakePointerChecker<Derived>())
308 .AddAttribute(
"Callback",
313 .AddAttribute(
"TestTimeWithBounds",
318 .AddAttribute(
"TestDeprecated",
324 "DEPRECATED test working.");
340 m_vector1.push_back(CreateObject<Derived>());
346 m_vector2.push_back(CreateObject<Derived>());
509 std::unordered_map<uint64_t, Ptr<Derived>>
559 std::string attributeName,
560 std::string expectedString,
578 std::string attributeName,
579 std::string expectedString,
588 bool ok1 = p->GetAttributeFailSafe(attributeName, stringValue);
589 bool ok2 = stringValue.
Get() == expectedString;
594 bool ok3 = p->GetAttributeFailSafe(attributeName, actualValue);
595 bool ok4 = expectedValue.Get() == actualValue.Get();
597 return ok1 && ok2 && ok3 && ok4;
610 p = CreateObject<AttributeObjectTest>();
618 p = CreateObject<AttributeObjectTest>();
621 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
624 std::string expected(
"Attribute 'TestDeprecated' is deprecated: DEPRECATED test working.\n");
626 std::stringstream buffer;
627 std::streambuf* oldBuffer = std::cerr.rdbuf(buffer.rdbuf());
634 std::cerr.rdbuf(oldBuffer);
642 p = CreateObject<AttributeObjectTest>();
645 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
651 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"true"));
654 ok = CheckGetCodePaths(p,
"TestBoolName",
"true",
BooleanValue(
true));
657 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
662 ok = p->SetAttributeFailSafe(
"TestBoolName",
StringValue(
"false"));
665 ok = CheckGetCodePaths(p,
"TestBoolName",
"false",
BooleanValue(
false));
668 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
673 p = CreateObject<AttributeObjectTest>();
682 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"true"));
685 ok = CheckGetCodePaths(p,
"TestBoolA",
"true",
BooleanValue(
true));
689 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
694 ok = p->SetAttributeFailSafe(
"TestBoolA",
StringValue(
"false"));
697 ok = CheckGetCodePaths(p,
"TestBoolA",
"false",
BooleanValue(
false));
701 "Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
711 p = CreateObject<AttributeObjectTest>();
718 ok = CheckGetCodePaths(p,
"TestInt16",
"-2",
IntegerValue(-2));
724 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-5"));
727 ok = CheckGetCodePaths(p,
"TestInt16",
"-5",
IntegerValue(-5));
730 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
735 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"+2"));
738 ok = CheckGetCodePaths(p,
"TestInt16",
"2",
IntegerValue(2));
741 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
746 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32768"));
749 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
753 "Attribute not set properly by SetAttributeFailSafe() (most negative) via StringValue");
759 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"-32769"));
762 "Unexpectedly could SetAttributeFailSafe() via StringValue to -32769");
764 ok = CheckGetCodePaths(p,
"TestInt16",
"-32768",
IntegerValue(-32768));
770 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32767"));
773 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
777 "Attribute not set properly by SetAttributeFailSafe() (most positive) via StringValue");
783 ok = p->SetAttributeFailSafe(
"TestInt16",
StringValue(
"32768"));
786 "Unexpectedly could SetAttributeFailSafe() via StringValue to 32768");
788 ok = CheckGetCodePaths(p,
"TestInt16",
"32767",
IntegerValue(32767));
795 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(10));
798 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
802 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via StringValue");
807 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(11));
810 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11");
812 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"10",
IntegerValue(10));
818 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-5));
821 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
825 "Attribute not set properly by SetAttributeFailSafe() (negative limit) via StringValue");
830 ok = p->SetAttributeFailSafe(
"TestInt16WithBounds",
IntegerValue(-6));
833 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6");
835 ok = CheckGetCodePaths(p,
"TestInt16WithBounds",
"-5",
IntegerValue(-5));
846 p = CreateObject<AttributeObjectTest>();
853 ok = CheckGetCodePaths(p,
"TestUint8",
"1",
UintegerValue(1));
862 ok = CheckGetCodePaths(p,
"TestUint8",
"0",
UintegerValue(0));
865 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
870 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(255));
873 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
877 "Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
883 ok = p->SetAttributeFailSafe(
"TestUint8",
UintegerValue(256));
886 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
893 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"255"));
896 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
899 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
905 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"256"));
908 "Unexpectedly could SetAttributeFailSafe() via StringValue to 256");
910 ok = CheckGetCodePaths(p,
"TestUint8",
"255",
UintegerValue(255));
916 ok = p->SetAttributeFailSafe(
"TestUint8",
StringValue(
"-1"));
919 "Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
929 p = CreateObject<AttributeObjectTest>();
936 ok = CheckGetCodePaths(p,
"TestFloat",
"-1.1",
DoubleValue(-1.1F));
942 ok = p->SetAttributeFailSafe(
"TestFloat",
DoubleValue(2.3F));
945 ok = CheckGetCodePaths(p,
"TestFloat",
"2.3",
DoubleValue(2.3F));
948 "Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
958 p = CreateObject<AttributeObjectTest>();
977 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
995 "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
1000 ok = p->SetAttributeFailSafe(
"TestEnum",
StringValue(
"TestB"));
1006 "Attribute not set properly by SetAttributeFailSafe() via StringValue");
1022 ok = p->SetAttributeFailSafe(
"TestEnum",
EnumValue(5));
1036 p = CreateObject<AttributeObjectTest>();
1048 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+5e+09ns",
TimeValue(
Seconds(5)));
1051 "Attribute not set properly by SetAttributeFailSafe(5s) via TimeValue");
1053 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
StringValue(
"3s"));
1056 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+3e+09ns",
TimeValue(
Seconds(3)));
1059 "Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
1069 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(10)));
1072 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1076 "Attribute not set properly by SetAttributeFailSafe(10s [positive limit]) via StringValue");
1081 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(11)));
1084 "Unexpectedly could SetAttributeFailSafe() via TimeValue to 11s [greater "
1085 "than positive limit]");
1087 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue(
Seconds(10)));
1093 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-5)));
1096 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1100 "Attribute not set properly by SetAttributeFailSafe(-5s [negative limit]) via StringValue");
1105 ok = p->SetAttributeFailSafe(
"TestTimeWithBounds",
TimeValue(
Seconds(-6)));
1108 "Unexpectedly could SetAttributeFailSafe() via TimeValue to -6s");
1110 ok = CheckGetCodePaths(p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue(
Seconds(-5)));
1145 void DoRun()
override;
1163 std::string description)
1174 p = CreateObject<AttributeObjectTest>();
1180 ok = p->SetAttributeFailSafe(
"TestRandom",
1181 StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
1187 ok = p->SetAttributeFailSafe(
"TestRandom",
1188 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
1213 void DoRun()
override;
1227 p = CreateObject<AttributeObjectTest>();
1234 p->GetAttribute(
"TestVector1", vector);
1237 "Initial count of ObjectVectorValue \"TestVector1\" should be zero");
1246 "Initial count of ObjectVectorValue \"TestVector1\" should still be zero");
1251 p->GetAttribute(
"TestVector1", vector);
1254 "ObjectVectorValue \"TestVector1\" should be incremented");
1268 "Count of ObjectVectorValue \"TestVector1\" should still be one");
1273 p->GetAttribute(
"TestVector1", vector);
1276 "ObjectVectorValue \"TestVector1\" should be incremented");
1298 void DoRun()
override;
1312 p = CreateObject<AttributeObjectTest>();
1319 p->GetAttribute(
"TestMap1", map);
1322 "Initial count of ObjectVectorValue \"TestMap1\" should be zero");
1330 "Initial count of ObjectVectorValue \"TestMap1\" should still be zero");
1335 p->GetAttribute(
"TestMap1", map);
1350 "Count of ObjectVectorValue \"TestMap1\" should still be one");
1355 p->GetAttribute(
"TestMap1", map);
1363 p->AddToUnorderedMap(4);
1364 p->AddToUnorderedMap(2);
1365 p->AddToUnorderedMap(1);
1366 p->AddToUnorderedMap(3);
1368 p->RemoveFromUnorderedMap(2);
1369 p->GetAttribute(
"TestUnorderedMap", unorderedMap);
1372 "ObjectMapValue \"TestUnorderedMap\" should have three values");
1376 "ObjectMapValue \"TestUnorderedMap\" should have value with key 1");
1380 "ObjectMapValue \"TestUnorderedMap\" should not have value with key 2");
1381 auto it = unorderedMap.
Begin();
1384 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 1");
1388 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 3");
1392 "ObjectMapValue \"TestUnorderedMap\" should have a value with key 4");
1415 void DoRun()
override;
1430 p = CreateObject<AttributeObjectTest>();
1437 p->GetAttribute(
"IntegerTraceSource1", iv);
1443 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(5));
1446 p->GetAttribute(
"IntegerTraceSource1", iv);
1449 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1454 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(127));
1457 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(128));
1460 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1462 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-128));
1465 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-129));
1468 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1474 p->GetAttribute(
"IntegerTraceSource2", iv);
1480 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(5));
1483 p->GetAttribute(
"IntegerTraceSource2", iv);
1486 "Attribute not set properly by SetAttributeFailSafe() via IntegerValue");
1491 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(127));
1494 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(128));
1497 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1499 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-128));
1502 ok = p->SetAttributeFailSafe(
"IntegerTraceSource2",
IntegerValue(-129));
1505 "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1528 void DoRun()
override;
1554 p = CreateObject<AttributeObjectTest>();
1563 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(-1));
1572 ok = p->TraceConnectWithoutContext(
1577 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1584 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(0));
1589 "Hitting a TracedValue does not cause trace callback to be called");
1595 ok = p->TraceDisconnectWithoutContext(
1600 "Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1602 ok = p->SetAttributeFailSafe(
"IntegerTraceSource1",
IntegerValue(1));
1607 "Hitting a TracedValue after disconnect still causes callback");
1630 void DoRun()
override;
1657 p = CreateObject<AttributeObjectTest>();
1673 p->InvokeCb(1.0, -5, 0.0);
1677 "Invoking a newly created TracedCallback results in an unexpected callback");
1683 ok = p->TraceConnectWithoutContext(
"Source2",
1691 p->InvokeCb(1.0, -5, 0.0);
1699 ok = p->TraceDisconnectWithoutContext(
1704 p->InvokeCb(-1.0, -5, 0.0);
1708 "Invoking disconnected TracedCallback unexpectedly results in trace callback");
1731 void DoRun()
override;
1758 p = CreateObject<AttributeObjectTest>();
1767 p->GetAttribute(
"Pointer", ptr);
1772 "Unexpectedly found non-null pointer in newly initialized PointerValue Attribute");
1778 derived = Create<Derived>();
1779 ok = p->SetAttributeFailSafe(
"Pointer",
PointerValue(derived));
1782 "Could not SetAttributeFailSafe() a PointerValue of the correct type");
1788 p->GetAttribute(
"Pointer", ptr);
1792 "Retrieved Attribute does not match stored PointerValue");
1800 p->GetAttribute(
"Pointer", ptr);
1804 "Retrieved Ptr<Object> does not match stored Ptr<Derived>");
1810 p->GetAttribute(
"Pointer", ptr);
1814 "Unexpectedly retrieved unrelated Ptr<type> from stored Ptr<Derived>");
1820 p->GetAttribute(
"PointerInitialized", ptr);
1824 p2->GetAttribute(
"PointerInitialized", ptr2);
1828 "ptr and ptr2 both have PointerInitialized pointing to the same object");
1830 p2->GetAttribute(
"PointerInitialized", ptr3);
1834 "ptr and ptr3 both have PointerInitialized pointing to the same object");
1840 factory.
SetTypeId(
"ns3::AttributeObjectTest");
1848 aotPtr->GetAttribute(
"PointerInitialized", ptr4);
1851 aotPtr2->GetAttribute(
"PointerInitialized", ptr5);
1855 "aotPtr and aotPtr2 are unique, but their Derived member is not");
1889 void DoRun()
override;
1916 p = CreateObject<AttributeObjectTest>();
1936 p->InvokeCbValue(2);
1941 ok = p->SetAttributeFailSafe(
"Callback", cbValue);
1947 p->InvokeCbValue(2);
1950 ok = p->SetAttributeFailSafe(
"Callback",
CallbackValue(MakeNullCallback<void, int8_t>()));
1956 p->InvokeCbValue(3);
1959 "Callback Attribute set to null callback unexpectedly fired");
2000 "Ensure TracedValue<uint8_t> can be set like IntegerValue"),
2006 "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.
Ptr< Derived > DoGetVector(std::size_t i) const
Get the i-th item 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.
void InvokeCb(double a, int b, float c)
Invoke the m_cb callback.
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.
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.
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(* NumericTracedCallback)(double, int, float)
Traced callbacks for (double, int, float) values.
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.
IntegerTraceSourceTestCase(std::string description)
Constructor.
~IntegerTraceSourceTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void NotifySource1(int8_t old, int8_t n)
Notify the call of source 1.
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.
double m_got2
Value used to verify that source 2 was called.
~PointerAttributeTestCase() override
PointerAttributeTestCase(std::string description)
Constructor.
void NotifySource2(double a, int b, float c)
Notify the call of source 2.
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...
~TracedCallbackTestCase() override
TracedCallbackTestCase(std::string description)
Constructor.
void NotifySource2(double a, int b, float c)
Notify the call of source 2.
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.
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>.
Smart pointer class similar to boost::intrusive_ptr.
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.
static void SetResolution(Unit resolution)
AttributeValue implementation for Time.
Forward calls to a chain of Callback.
Trace classes with value semantics.
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)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeCallbackAccessor(T1 a1)
Ptr< const AttributeChecker > MakeCallbackChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
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)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
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...
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.