EnumValue -> Value
This commit is contained in:
@@ -5,27 +5,27 @@
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
EnumValue::EnumValue (int v)
|
||||
Enum::Enum (int v)
|
||||
: m_v (v)
|
||||
{}
|
||||
void
|
||||
EnumValue::Set (int v)
|
||||
Enum::Set (int v)
|
||||
{
|
||||
m_v = v;
|
||||
}
|
||||
int
|
||||
EnumValue::Get (void) const
|
||||
Enum::Get (void) const
|
||||
{
|
||||
return m_v;
|
||||
}
|
||||
|
||||
Attribute
|
||||
EnumValue::Copy (void) const
|
||||
Enum::Copy (void) const
|
||||
{
|
||||
return Attribute::Create<EnumValue> (*this);
|
||||
return Attribute::Create<Enum> (*this);
|
||||
}
|
||||
std::string
|
||||
EnumValue::SerializeToString (Ptr<const AttributeChecker> checker) const
|
||||
Enum::SerializeToString (Ptr<const AttributeChecker> checker) const
|
||||
{
|
||||
const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
|
||||
NS_ASSERT (p != 0);
|
||||
@@ -37,12 +37,12 @@ EnumValue::SerializeToString (Ptr<const AttributeChecker> checker) const
|
||||
}
|
||||
}
|
||||
|
||||
NS_FATAL_ERROR ("The user has set an invalid C++ value in this EnumValue");
|
||||
NS_FATAL_ERROR ("The user has set an invalid C++ value in this Enum");
|
||||
// quiet compiler.
|
||||
return "";
|
||||
}
|
||||
bool
|
||||
EnumValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
|
||||
Enum::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
|
||||
{
|
||||
const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
|
||||
NS_ASSERT (p != 0);
|
||||
@@ -57,18 +57,18 @@ EnumValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker>
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumValue::EnumValue (Attribute value)
|
||||
Enum::Enum (Attribute value)
|
||||
{
|
||||
const EnumValue *v = value.DynCast<const EnumValue *> ();
|
||||
const Enum *v = value.DynCast<const Enum *> ();
|
||||
if (v == 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("assigning non-Enum value to Enum value.");
|
||||
}
|
||||
m_v = v->m_v;
|
||||
}
|
||||
EnumValue::operator Attribute () const
|
||||
Enum::operator Attribute () const
|
||||
{
|
||||
return Attribute::Create<EnumValue> (*this);
|
||||
return Attribute::Create<Enum> (*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ EnumChecker::Add (int v, std::string name)
|
||||
bool
|
||||
EnumChecker::Check (Attribute value) const
|
||||
{
|
||||
const EnumValue *p = value.DynCast<const EnumValue *> ();
|
||||
const Enum *p = value.DynCast<const Enum *> ();
|
||||
if (p == 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class EnumValue : public AttributeValue
|
||||
class Enum : public AttributeValue
|
||||
{
|
||||
public:
|
||||
EnumValue (int v);
|
||||
Enum (int v);
|
||||
void Set (int v);
|
||||
int Get (void) const;
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
|
||||
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
|
||||
|
||||
EnumValue (Attribute value);
|
||||
Enum (Attribute value);
|
||||
operator Attribute () const;
|
||||
private:
|
||||
int m_v;
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
virtual bool Check (Attribute value) const;
|
||||
|
||||
private:
|
||||
friend class EnumValue;
|
||||
friend class Enum;
|
||||
typedef std::list<std::pair<int,std::string> > ValueSet;
|
||||
ValueSet m_valueSet;
|
||||
};
|
||||
@@ -68,13 +68,13 @@ namespace ns3 {
|
||||
template <typename T1>
|
||||
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1)
|
||||
{
|
||||
return MakeAccessorHelper<EnumAccessor,EnumValue> (a1);
|
||||
return MakeAccessorHelper<EnumAccessor,Enum> (a1);
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
Ptr<const AttributeAccessor> MakeEnumAccessor (T1 a1, T2 a2)
|
||||
{
|
||||
return MakeAccessorHelper<EnumAccessor,EnumValue> (a1, a2);
|
||||
return MakeAccessorHelper<EnumAccessor,Enum> (a1, a2);
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
MakeUintegerAccessor (&AccessorObjectTest::m_uint8),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
.AddParameter ("TestEnum", "help text",
|
||||
EnumValue (TEST_A),
|
||||
Enum (TEST_A),
|
||||
MakeEnumAccessor (&AccessorObjectTest::m_enum),
|
||||
MakeEnumChecker (TEST_A, "TestA",
|
||||
TEST_B, "TestB",
|
||||
@@ -289,19 +289,19 @@ AccessorTest::RunTests (void)
|
||||
CHECK_GET_PARAM (p, "TestFloat", FpValue, (float)+2.3);
|
||||
|
||||
CHECK_GET_STR (p, "TestEnum", "TestA");
|
||||
CHECK_GET_PARAM (p, "TestEnum", EnumValue, AccessorObjectTest::TEST_A);
|
||||
NS_TEST_ASSERT (p->Set ("TestEnum", EnumValue (AccessorObjectTest::TEST_C)));
|
||||
CHECK_GET_PARAM (p, "TestEnum", Enum, AccessorObjectTest::TEST_A);
|
||||
NS_TEST_ASSERT (p->Set ("TestEnum", Enum (AccessorObjectTest::TEST_C)));
|
||||
CHECK_GET_STR (p, "TestEnum", "TestC");
|
||||
CHECK_GET_PARAM (p, "TestEnum", EnumValue, AccessorObjectTest::TEST_C);
|
||||
CHECK_GET_PARAM (p, "TestEnum", Enum, AccessorObjectTest::TEST_C);
|
||||
NS_TEST_ASSERT (p->Set ("TestEnum", "TestB"));
|
||||
CHECK_GET_STR (p, "TestEnum", "TestB");
|
||||
CHECK_GET_PARAM (p, "TestEnum", EnumValue, AccessorObjectTest::TEST_B);
|
||||
CHECK_GET_PARAM (p, "TestEnum", Enum, AccessorObjectTest::TEST_B);
|
||||
NS_TEST_ASSERT (!p->Set ("TestEnum", "TestD"));
|
||||
CHECK_GET_STR (p, "TestEnum", "TestB");
|
||||
CHECK_GET_PARAM (p, "TestEnum", EnumValue, AccessorObjectTest::TEST_B);
|
||||
NS_TEST_ASSERT (!p->Set ("TestEnum", EnumValue (5)));
|
||||
CHECK_GET_PARAM (p, "TestEnum", Enum, AccessorObjectTest::TEST_B);
|
||||
NS_TEST_ASSERT (!p->Set ("TestEnum", Enum (5)));
|
||||
CHECK_GET_STR (p, "TestEnum", "TestB");
|
||||
CHECK_GET_PARAM (p, "TestEnum", EnumValue, AccessorObjectTest::TEST_B);
|
||||
CHECK_GET_PARAM (p, "TestEnum", Enum, AccessorObjectTest::TEST_B);
|
||||
|
||||
RandomVariable ran = p->Get ("TestRandom");
|
||||
NS_TEST_ASSERT (p->Set ("TestRandom", UniformVariable (0.0, 1.0)));
|
||||
|
||||
@@ -74,7 +74,7 @@ GridPositionAllocator::GetTypeId (void)
|
||||
MakeFpAccessor (&GridPositionAllocator::m_deltaY),
|
||||
MakeFpChecker<double> ())
|
||||
.AddParameter ("LayoutType", "The type of layout.",
|
||||
EnumValue (ROW_FIRST),
|
||||
Enum (ROW_FIRST),
|
||||
MakeEnumAccessor (&GridPositionAllocator::m_layoutType),
|
||||
MakeEnumChecker (ROW_FIRST, "RowFirst",
|
||||
COLUMN_FIRST, "ColumnFirst"))
|
||||
|
||||
@@ -55,7 +55,7 @@ RandomWalk2dMobilityModel::GetTypeId (void)
|
||||
.AddParameter ("mode",
|
||||
"The mode indicates the condition used to "
|
||||
"change the current speed and direction",
|
||||
EnumValue (RandomWalk2dMobilityModel::MODE_DISTANCE),
|
||||
Enum (RandomWalk2dMobilityModel::MODE_DISTANCE),
|
||||
MakeEnumAccessor (&RandomWalk2dMobilityModel::m_mode),
|
||||
MakeEnumChecker (RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance",
|
||||
RandomWalk2dMobilityModel::MODE_TIME, "Time"))
|
||||
|
||||
Reference in New Issue
Block a user