fix attribute accessor for DropTailQueue Mode attribute (reported by Chip Webb)
This commit is contained in:
@@ -136,6 +136,13 @@ public:
|
||||
MakeEnumChecker (TEST_A, "TestA",
|
||||
TEST_B, "TestB",
|
||||
TEST_C, "TestC"))
|
||||
.AddAttribute ("TestEnumSetGet", "help text",
|
||||
EnumValue (TEST_B),
|
||||
MakeEnumAccessor (&AttributeObjectTest::DoSetEnum,
|
||||
&AttributeObjectTest::DoGetEnum),
|
||||
MakeEnumChecker (TEST_A, "TestA",
|
||||
TEST_B, "TestB",
|
||||
TEST_C, "TestC"))
|
||||
.AddAttribute ("TestRandom", "help text",
|
||||
StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
|
||||
MakePointerAccessor (&AttributeObjectTest::m_random),
|
||||
@@ -228,6 +235,7 @@ public:
|
||||
NS_UNUSED (m_uint8);
|
||||
NS_UNUSED (m_float);
|
||||
NS_UNUSED (m_enum);
|
||||
NS_UNUSED (m_enumSetGet);
|
||||
}
|
||||
|
||||
virtual ~AttributeObjectTest (void) {};
|
||||
@@ -255,6 +263,8 @@ private:
|
||||
Ptr<Derived> DoGetVector (uint32_t i) const { return m_vector2[i]; }
|
||||
bool DoSetIntSrc (int8_t v) { m_intSrc2 = v; return true; }
|
||||
int8_t DoGetIntSrc (void) const { return m_intSrc2; }
|
||||
bool DoSetEnum (Test_e v) { m_enumSetGet = v; return true; }
|
||||
Test_e DoGetEnum (void) const { return m_enumSetGet; }
|
||||
|
||||
bool m_boolTestA;
|
||||
bool m_boolTest;
|
||||
@@ -264,6 +274,7 @@ private:
|
||||
uint8_t m_uint8;
|
||||
float m_float;
|
||||
enum Test_e m_enum;
|
||||
enum Test_e m_enumSetGet;
|
||||
Ptr<RandomVariableStream> m_random;
|
||||
std::vector<Ptr<Derived> > m_vector1;
|
||||
std::vector<Ptr<Derived> > m_vector2;
|
||||
@@ -653,6 +664,22 @@ AttributeTestCase<EnumValue>::DoRun (void)
|
||||
ok = CheckGetCodePaths (p, "TestEnum", "TestC", EnumValue (AttributeObjectTest::TEST_C));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
|
||||
|
||||
//
|
||||
// When the object is first created, the Attribute should have the default
|
||||
// value.
|
||||
//
|
||||
ok = CheckGetCodePaths (p, "TestEnumSetGet", "TestB", EnumValue (AttributeObjectTest::TEST_B));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by default value");
|
||||
|
||||
//
|
||||
// Set the Attribute using the EnumValue type.
|
||||
//
|
||||
ok = p->SetAttributeFailSafe ("TestEnumSetGet", EnumValue (AttributeObjectTest::TEST_C));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to TEST_C");
|
||||
|
||||
ok = CheckGetCodePaths (p, "TestEnumSetGet", "TestC", EnumValue (AttributeObjectTest::TEST_C));
|
||||
NS_TEST_ASSERT_MSG_EQ (ok, true, "Attribute not set properly by SetAttributeFailSafe() via EnumValue");
|
||||
|
||||
//
|
||||
// Set the Attribute using the StringValue type.
|
||||
//
|
||||
|
||||
@@ -36,7 +36,8 @@ TypeId DropTailQueue::GetTypeId (void)
|
||||
.AddAttribute ("Mode",
|
||||
"Whether to use bytes (see MaxBytes) or packets (see MaxPackets) as the maximum queue size metric.",
|
||||
EnumValue (QUEUE_MODE_PACKETS),
|
||||
MakeEnumAccessor (&DropTailQueue::SetMode),
|
||||
MakeEnumAccessor (&DropTailQueue::SetMode,
|
||||
&DropTailQueue::GetMode),
|
||||
MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
|
||||
QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
|
||||
.AddAttribute ("MaxPackets",
|
||||
@@ -75,7 +76,7 @@ DropTailQueue::SetMode (DropTailQueue::QueueMode mode)
|
||||
}
|
||||
|
||||
DropTailQueue::QueueMode
|
||||
DropTailQueue::GetMode (void)
|
||||
DropTailQueue::GetMode (void) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_mode;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
*
|
||||
* \returns The encapsulation mode of this device.
|
||||
*/
|
||||
DropTailQueue::QueueMode GetMode (void);
|
||||
DropTailQueue::QueueMode GetMode (void) const;
|
||||
|
||||
private:
|
||||
virtual bool DoEnqueue (Ptr<Packet> p);
|
||||
|
||||
Reference in New Issue
Block a user