20 #include "ns3/object.h"
21 #include "ns3/boolean.h"
22 #include "ns3/integer.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/config.h"
26 #include "ns3/string.h"
27 #include "ns3/random-variable-stream.h"
28 #include "ns3/double.h"
29 #include "ns3/object-vector.h"
30 #include "ns3/object-map.h"
31 #include "ns3/traced-value.h"
32 #include "ns3/callback.h"
33 #include "ns3/trace-source-accessor.h"
34 #include "ns3/pointer.h"
35 #include "ns3/object-factory.h"
36 #include "ns3/nstime.h"
129 .SetParent<Object> ()
162 .SetParent<Object> ()
163 .HideFromDocumentation ()
164 .AddAttribute (
"TestBoolName",
"help text",
168 .AddAttribute (
"TestBoolA",
"help text",
173 .AddAttribute (
"TestInt16",
"help text",
176 MakeIntegerChecker<int16_t> ())
177 .AddAttribute (
"TestInt16WithBounds",
"help text",
180 MakeIntegerChecker<int16_t> (-5, 10))
181 .AddAttribute (
"TestInt16SetGet",
"help text",
185 MakeIntegerChecker<int16_t> ())
186 .AddAttribute (
"TestUint8",
"help text",
189 MakeUintegerChecker<uint8_t> ())
190 .AddAttribute (
"TestEnum",
"help text",
196 .AddAttribute (
"TestEnumSetGet",
"help text",
203 .AddAttribute (
"TestRandom",
"help text",
204 StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"),
206 MakePointerChecker <RandomVariableStream>())
207 .AddAttribute (
"TestFloat",
"help text",
210 MakeDoubleChecker<float> ())
211 .AddAttribute (
"TestVector1",
"help text",
214 MakeObjectVectorChecker<Derived> ())
215 .AddAttribute (
"TestVector2",
"help text",
219 MakeObjectVectorChecker<Derived> ())
220 .AddAttribute (
"TestMap1",
"help text",
223 MakeObjectMapChecker<Derived> ())
224 .AddAttribute (
"IntegerTraceSource1",
"help text",
227 MakeIntegerChecker<int8_t> ())
228 .AddAttribute (
"IntegerTraceSource2",
"help text",
232 MakeIntegerChecker<int8_t> ())
233 .AddAttribute (
"UIntegerTraceSource",
"help text",
236 MakeIntegerChecker<uint8_t> ())
237 .AddAttribute (
"DoubleTraceSource",
"help text",
240 MakeDoubleChecker<double> ())
241 .AddAttribute (
"BoolTraceSource",
"help text",
245 .AddAttribute (
"EnumTraceSource",
"help text",
249 .AddAttribute (
"ValueClassSource",
"help text",
253 .AddTraceSource (
"Source1",
"help test",
255 "ns3::TracedValueCallback::Int8")
256 .AddTraceSource (
"Source2",
"help text",
258 "ns3::AttributeObjectTest::NumericTracedCallback")
259 .AddTraceSource (
"ValueSource",
"help text",
261 "ns3::ValueClassTest::TracedValueCallback")
262 .AddAttribute (
"Pointer",
"help text",
265 MakePointerChecker<Derived> ())
266 .AddAttribute (
"PointerInitialized",
"help text",
269 MakePointerChecker<Derived> ())
270 .AddAttribute (
"PointerInitialized2",
"help text",
273 MakePointerChecker<Derived> ())
274 .AddAttribute (
"Callback",
"help text",
278 .AddAttribute (
"TestTimeWithBounds",
"help text",
282 .AddAttribute (
"TestDeprecated",
"help text",
287 "DEPRECATED test working.")
303 m_vector1.push_back (CreateObject<Derived> ());
308 m_vector2.push_back (CreateObject<Derived> ());
317 m_map1.insert (std::pair <uint32_t,
Ptr<Derived> > (i, CreateObject<Derived> ()));
337 if (!m_cbValue.IsNull ())
366 return m_int16SetGet;
382 return m_vector2.size ();
443 std::map <uint32_t, Ptr<Derived> >
m_map1;
449 typedef void (* NumericTracedCallback) (double, int, float);
470 template <
typename T>
491 bool CheckGetCodePaths (
Ptr<Object> p, std::string attributeName, std::string expectedString, T expectedValue);
494 template <
typename T>
499 template <
typename T>
503 template <
typename T>
bool
506 std::string attributeName,
507 std::string expectedString,
517 bool ok2 = stringValue.
Get () == expectedString;
523 bool ok4 = expectedValue.Get () == actualValue.Get ();
525 return ok1 && ok2 && ok3 && ok4;
537 p = CreateObject<AttributeObjectTest> ();
545 p = CreateObject<AttributeObjectTest> ();
548 ok = CheckGetCodePaths (p,
"TestBoolName",
"true",
BooleanValue (
true));
551 std::string expected (
"Attribute 'TestDeprecated' is deprecated: DEPRECATED test working.\n");
553 std::stringstream buffer;
554 std::streambuf *oldBuffer = std::cerr.rdbuf (buffer.rdbuf());
561 std::cerr.rdbuf (oldBuffer);
571 p = CreateObject<AttributeObjectTest> ();
574 ok = CheckGetCodePaths (p,
"TestBoolName",
"false",
BooleanValue (
false));
580 ok = p->SetAttributeFailSafe (
"TestBoolName",
StringValue (
"true"));
583 ok = CheckGetCodePaths (p,
"TestBoolName",
"true",
BooleanValue (
true));
584 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
589 ok = p->SetAttributeFailSafe (
"TestBoolName",
StringValue (
"false"));
592 ok = CheckGetCodePaths (p,
"TestBoolName",
"false",
BooleanValue (
false));
593 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
598 p = CreateObject<AttributeObjectTest> ();
607 ok = p->SetAttributeFailSafe (
"TestBoolA",
StringValue (
"true"));
610 ok = CheckGetCodePaths (p,
"TestBoolA",
"true",
BooleanValue (
true));
611 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
616 ok = p->SetAttributeFailSafe (
"TestBoolA",
StringValue (
"false"));
619 ok = CheckGetCodePaths (p,
"TestBoolA",
"false",
BooleanValue (
false));
620 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (getter/setter) via StringValue");
629 p = CreateObject<AttributeObjectTest> ();
636 ok = CheckGetCodePaths (p,
"TestInt16",
"-2",
IntegerValue (-2));
642 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"-5"));
645 ok = CheckGetCodePaths (p,
"TestInt16",
"-5",
IntegerValue (-5));
646 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
651 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"+2"));
654 ok = CheckGetCodePaths (p,
"TestInt16",
"2",
IntegerValue (2));
655 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
660 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"-32768"));
663 ok = CheckGetCodePaths (p,
"TestInt16",
"-32768",
IntegerValue (-32768));
664 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (most negative) via StringValue");
670 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"-32769"));
671 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via StringValue to -32769");
673 ok = CheckGetCodePaths (p,
"TestInt16",
"-32768",
IntegerValue (-32768));
679 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"32767"));
682 ok = CheckGetCodePaths (p,
"TestInt16",
"32767",
IntegerValue (32767));
683 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (most positive) via StringValue");
689 ok = p->SetAttributeFailSafe (
"TestInt16",
StringValue (
"32768"));
690 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via StringValue to 32768");
692 ok = CheckGetCodePaths (p,
"TestInt16",
"32767",
IntegerValue (32767));
699 ok = p->SetAttributeFailSafe (
"TestInt16WithBounds",
IntegerValue (10));
702 ok = CheckGetCodePaths (p,
"TestInt16WithBounds",
"10",
IntegerValue (10));
703 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (positive limit) via StringValue");
708 ok = p->SetAttributeFailSafe (
"TestInt16WithBounds",
IntegerValue (11));
709 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11");
711 ok = CheckGetCodePaths (p,
"TestInt16WithBounds",
"10",
IntegerValue (10));
717 ok = p->SetAttributeFailSafe (
"TestInt16WithBounds",
IntegerValue (-5));
720 ok = CheckGetCodePaths (p,
"TestInt16WithBounds",
"-5",
IntegerValue (-5));
721 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (negative limit) via StringValue");
726 ok = p->SetAttributeFailSafe (
"TestInt16WithBounds",
IntegerValue (-6));
727 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6");
729 ok = CheckGetCodePaths (p,
"TestInt16WithBounds",
"-5",
IntegerValue (-5));
739 p = CreateObject<AttributeObjectTest> ();
746 ok = CheckGetCodePaths (p,
"TestUint8",
"1",
UintegerValue (1));
752 ok = p->SetAttributeFailSafe (
"TestUint8",
UintegerValue (0));
755 ok = CheckGetCodePaths (p,
"TestUint8",
"0",
UintegerValue (0));
756 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
761 ok = p->SetAttributeFailSafe (
"TestUint8",
UintegerValue (255));
764 ok = CheckGetCodePaths (p,
"TestUint8",
"255",
UintegerValue (255));
765 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() (positive limit) via UintegerValue");
771 ok = p->SetAttributeFailSafe (
"TestUint8",
UintegerValue (256));
774 ok = CheckGetCodePaths (p,
"TestUint8",
"255",
UintegerValue (255));
781 ok = p->SetAttributeFailSafe (
"TestUint8",
StringValue (
"255"));
784 ok = CheckGetCodePaths (p,
"TestUint8",
"255",
UintegerValue (255));
785 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
791 ok = p->SetAttributeFailSafe (
"TestUint8",
StringValue (
"256"));
792 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via StringValue to 256");
794 ok = CheckGetCodePaths (p,
"TestUint8",
"255",
UintegerValue (255));
800 ok = p->SetAttributeFailSafe (
"TestUint8",
StringValue (
"-1"));
801 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via StringValue to -1");
810 p = CreateObject<AttributeObjectTest> ();
817 ok = CheckGetCodePaths (p,
"TestFloat",
"-1.1",
DoubleValue ((
float)-1.1));
823 ok = p->SetAttributeFailSafe (
"TestFloat",
DoubleValue ((
float)2.3));
826 ok = CheckGetCodePaths (p,
"TestFloat",
"2.3",
DoubleValue ((
float)2.3));
827 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via DoubleValue");
836 p = CreateObject<AttributeObjectTest> ();
853 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via EnumValue");
869 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via EnumValue");
874 ok = p->SetAttributeFailSafe (
"TestEnum",
StringValue (
"TestB"));
878 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe() via StringValue");
894 ok = p->SetAttributeFailSafe (
"TestEnum",
EnumValue (5));
907 p = CreateObject<AttributeObjectTest> ();
911 Time::SetResolution (Time::NS);
916 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
TimeValue (
Seconds (5)));
919 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"+5e+09ns",
TimeValue (
Seconds (5)));
920 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe(5s) via TimeValue");
922 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
StringValue (
"3s"));
925 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"+3e+09ns",
TimeValue (
Seconds (3)));
926 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe(3s) via StringValue");
937 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
TimeValue (
Seconds (10)));
940 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue (
Seconds (10)));
941 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe(10s [positive limit]) via StringValue");
946 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
TimeValue (
Seconds (11)));
947 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via TimeValue to 11s [greater than positive limit]");
949 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"+1e+10ns",
TimeValue (
Seconds (10)));
955 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
TimeValue (
Seconds (-5)));
958 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue (
Seconds (-5)));
959 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Attribute not set properly by SetAttributeFailSafe(-5s [negative limit]) via StringValue");
964 ok = p->SetAttributeFailSafe (
"TestTimeWithBounds",
TimeValue (
Seconds (-6)));
967 ok = CheckGetCodePaths (p,
"TestTimeWithBounds",
"-5e+09ns",
TimeValue (
Seconds (-5)));
1000 virtual void DoRun (
void);
1027 p = CreateObject<AttributeObjectTest> ();
1033 ok = p->SetAttributeFailSafe (
"TestRandom",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
1039 ok = p->SetAttributeFailSafe (
"TestRandom",
StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"));
1062 virtual void DoRun (
void);
1075 p = CreateObject<AttributeObjectTest> ();
1082 p->GetAttribute (
"TestVector1", vector);
1094 p->GetAttribute (
"TestVector1", vector);
1112 p->GetAttribute (
"TestVector1", vector);
1133 virtual void DoRun (
void);
1146 p = CreateObject<AttributeObjectTest> ();
1153 p->GetAttribute (
"TestMap1", map);
1165 p->GetAttribute (
"TestMap1", map);
1183 p->GetAttribute (
"TestMap1", map);
1205 virtual void DoRun (
void);
1219 p = CreateObject<AttributeObjectTest> ();
1226 p->GetAttribute (
"IntegerTraceSource1", iv);
1232 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (5));
1235 p->GetAttribute (
"IntegerTraceSource1", iv);
1241 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (127));
1244 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (128));
1245 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1247 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (-128));
1250 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (-129));
1251 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1257 p->GetAttribute (
"IntegerTraceSource2", iv);
1263 ok = p->SetAttributeFailSafe (
"IntegerTraceSource2",
IntegerValue (5));
1266 p->GetAttribute (
"IntegerTraceSource2", iv);
1272 ok = p->SetAttributeFailSafe (
"IntegerTraceSource2",
IntegerValue (127));
1275 ok = p->SetAttributeFailSafe (
"IntegerTraceSource2",
IntegerValue (128));
1276 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128");
1278 ok = p->SetAttributeFailSafe (
"IntegerTraceSource2",
IntegerValue (-128));
1281 ok = p->SetAttributeFailSafe (
"IntegerTraceSource2",
IntegerValue (-129));
1282 NS_TEST_ASSERT_MSG_EQ (ok,
false,
"Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129");
1303 virtual void DoRun (
void);
1327 p = CreateObject<AttributeObjectTest> ();
1336 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (-1));
1346 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1353 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (0));
1363 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Could not TraceConnectWithoutContext() \"Source1\" to NodifySource1()");
1365 ok = p->SetAttributeFailSafe (
"IntegerTraceSource1",
IntegerValue (1));
1389 virtual void DoRun (
void);
1415 p = CreateObject<AttributeObjectTest> ();
1431 p->InvokeCb (1.0, -5, 0.0);
1445 p->InvokeCb (1.0, -5, 0.0);
1456 p->InvokeCb (-1.0, -5, 0.0);
1478 virtual void DoRun (
void);
1504 p = CreateObject<AttributeObjectTest> ();
1513 p->GetAttribute (
"Pointer", ptr);
1515 NS_TEST_ASSERT_MSG_EQ (derived, 0,
"Unexpectedly found non-null pointer in newly initialized PointerValue Attribute");
1521 derived = Create<Derived> ();
1522 ok = p->SetAttributeFailSafe (
"Pointer",
PointerValue (derived));
1523 NS_TEST_ASSERT_MSG_EQ (ok,
true,
"Could not SetAttributeFailSafe() a PointerValue of the correct type");
1529 p->GetAttribute (
"Pointer", ptr);
1539 p->GetAttribute (
"Pointer", ptr);
1541 NS_TEST_ASSERT_MSG_EQ (storedBase, stored,
"Retrieved Ptr<Object> does not match stored Ptr<Derived>");
1547 p->GetAttribute (
"Pointer", ptr);
1555 p->GetAttribute (
"PointerInitialized", ptr);
1559 p2->GetAttribute (
"PointerInitialized", ptr2);
1561 NS_TEST_ASSERT_MSG_NE (storedPtr, storedPtr2,
"ptr and ptr2 both have PointerInitialized pointing to the same object");
1563 p2->GetAttribute (
"PointerInitialized", ptr3);
1565 NS_TEST_ASSERT_MSG_NE (storedPtr, storedPtr3,
"ptr and ptr3 both have PointerInitialized pointing to the same object");
1571 factory.
SetTypeId (
"ns3::AttributeObjectTest");
1572 factory.
Set (
"PointerInitialized",
StringValue (
"ns3::Derived"));
1579 aotPtr->GetAttribute (
"PointerInitialized", ptr4);
1582 aotPtr2->GetAttribute (
"PointerInitialized", ptr5);
1584 NS_TEST_ASSERT_MSG_NE (storedPtr4, storedPtr5,
"aotPtr and aotPtr2 are unique, but their Derived member is not");
1616 virtual void DoRun (
void);
1642 p = CreateObject<AttributeObjectTest> ();
1662 p->InvokeCbValue (2);
1667 ok = p->SetAttributeFailSafe (
"Callback", cbValue);
1673 p->InvokeCbValue (2);
1676 ok = p->SetAttributeFailSafe (
"Callback",
CallbackValue (MakeNullCallback<void,int8_t> ()));
1682 p->InvokeCbValue (3);
static AttributesTestSuite g_attributesTestSuite
Static variable for test initialization.
Class used to check attributes.
bool DoSetIntSrc(int8_t v)
Set the m_intSrc2 value.
bool m_boolTest
Boolean test.
static TypeId GetTypeId(void)
Get the type ID.
std::map< uint32_t, Ptr< Derived > > m_map1
Map of uint32_t, derived objects.
int16_t m_int16SetGet
16-bit integer 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.
Ptr< RandomVariableStream > m_random
Random number generator.
bool m_boolTestA
Boolean test A.
int16_t m_int16
16-bit integer.
std::vector< Ptr< Derived > > m_vector1
First vector of derived objects.
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).
AttributeObjectTest(void)
Test_e DoGetEnum(void) const
Get the m_enumSetGet value.
Ptr< Derived > m_ptr
Pointer to Derived class.
virtual ~AttributeObjectTest(void)
int8_t DoGetIntSrc(void) const
Get the m_intSrc2 value.
void AddToVector1(void)
Add an object to the first vector.
int16_t m_int16WithBounds
16-bit integer with bounds.
TracedValue< int8_t > m_intSrc1
First int8_t Traced value.
Callback< void, int8_t > m_cbValue
Callback accepting an integer.
Ptr< Derived > m_ptrInitialized
Pointer to Derived class.
Ptr< Derived > m_ptrInitialized2
Pointer to Derived class.
std::size_t DoGetVectorN(void) const
Get the length of m_vector2.
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.
int16_t DoGetInt16(void) const
Get the m_int16SetGet value.
TracedValue< bool > m_boolSrc
bool Traced value.
TracedValue< int8_t > m_intSrc2
Second int8_t Traced value.
TracedValue< enum Test_e > m_enumSrc
enum Traced value.
bool DoGetTestA(void) const
Get the m_boolTestA value.
Time m_timeWithBounds
Time with bounds.
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 AddToVector2(void)
Add an object to the second vector.
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...
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool CheckGetCodePaths(Ptr< Object > p, std::string attributeName, std::string expectedString, T expectedValue)
Check the attribute path and value.
virtual ~AttributeTestCase()
AttributeTestCase(std::string description)
Constructor.
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.
Callback< void, int8_t > m_cbValue
The callback.
void InvokeCbValue(int8_t a)
Function to invoke the callback.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~CallbackValueTestCase()
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(void)
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~IntegerTraceSourceAttributeTestCase()
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.
void NotifySource1([[maybe_unused]] int8_t old, int8_t n)
Notify the call of source 1.
virtual ~IntegerTraceSourceTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test case for Object Map Attributes.
ObjectMapAttributeTestCase(std::string description)
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~ObjectMapAttributeTestCase()
Test case for Object Vector Attributes.
virtual void DoRun(void)
Implementation to actually run this TestCase.
ObjectVectorAttributeTestCase(std::string description)
Constructor.
virtual ~ObjectVectorAttributeTestCase()
Smart pointers (Ptr) are central to our architecture, so they must work as attributes.
void NotifySource2(double a, [[maybe_unused]] int b, [[maybe_unused]] float c)
Notify the call of source 2.
double m_got2
Value used to verify that source 2 was called.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~PointerAttributeTestCase()
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.
virtual ~RandomVariableStreamAttributeTestCase()
virtual void DoRun(void)
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, [[maybe_unused]] int b, [[maybe_unused]] float c)
Notify the call of source 2.
TracedCallbackTestCase(std::string description)
Constructor.
double m_got2
Value used to verify that source 2 was called.
virtual ~TracedCallbackTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
AttributeValue implementation for Boolean.
bool IsNull(void) 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 erros.
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
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(void) const
Get a pointer to the requested aggregated Object.
Container for a set of ns3::Object pointers.
std::size_t GetN(void) 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.
std::string Get(void) const
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(void)
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 AttributeChecker > MakeBooleanChecker(void)
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 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(void)
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.
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
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.
Ptr< const AttributeAccessor > MakeValueClassTestAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeValueClassTestChecker(void)
#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.
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.
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
list x
Random number samples.