split checker from ParamSpec.
--- a/src/core/boolean-value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/boolean-value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -22,7 +22,7 @@
return PValue::Create<BooleanValue> (*this);
}
std::string
-BooleanValue::SerializeToString (Ptr<const ParamSpec> spec) const
+BooleanValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::string value;
if (m_value)
@@ -36,7 +36,7 @@
return value;
}
bool
-BooleanValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+BooleanValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
if (value == "true" ||
value == "1" ||
@@ -71,4 +71,9 @@
return PValue::Create<BooleanValue> (*this);
}
+Ptr<AttributeChecker> MakeBooleanChecker (void)
+{
+ return MakeSimpleAttributeChecker<BooleanValue> ();
+}
+
} // namespace ns3
--- a/src/core/boolean-value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/boolean-value.h Mon Feb 18 00:18:45 2008 +0100
@@ -15,8 +15,8 @@
bool Get (void) const;
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
BooleanValue (PValue value);
operator PValue () const;
@@ -33,6 +33,8 @@
template <typename T1, typename T2>
Ptr<ParamSpec> MakeBooleanParamSpec (T1 a1, T2 a2);
+Ptr<AttributeChecker> MakeBooleanChecker (void);
+
} // namespace ns3
@@ -51,8 +53,6 @@
return MakeParamSpecHelper<BooleanParamSpec,BooleanValue> (a1, a2);
}
-
-
} // namespace ns3
#endif /* BOOLEAN_PARAMETER_H */
--- a/src/core/class-value-helper.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/class-value-helper.h Mon Feb 18 00:18:45 2008 +0100
@@ -26,12 +26,12 @@
virtual PValue Copy (void) const {
return PValue::Create<ClassValue<T,U> > (*this);
}
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const {
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const {
std::ostringstream oss;
oss << m_value;
return oss.str ();
}
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec) {
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) {
std::istringstream iss;
iss.str (value);
iss >> m_value;
--- a/src/core/enum-value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/enum-value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -25,11 +25,11 @@
return PValue::Create<EnumValue> (*this);
}
std::string
-EnumValue::SerializeToString (Ptr<const ParamSpec> spec) const
+EnumValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
- const EnumParamSpec *p = dynamic_cast<const EnumParamSpec *> (PeekPointer (spec));
+ const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
NS_ASSERT (p != 0);
- for (EnumParamSpec::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
+ for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
{
if (i->first == m_v)
{
@@ -42,11 +42,11 @@
return "";
}
bool
-EnumValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+EnumValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
- const EnumParamSpec *p = dynamic_cast<const EnumParamSpec *> (PeekPointer (spec));
+ const EnumChecker *p = dynamic_cast<const EnumChecker *> (PeekPointer (checker));
NS_ASSERT (p != 0);
- for (EnumParamSpec::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
+ for (EnumChecker::ValueSet::const_iterator i = p->m_valueSet.begin (); i != p->m_valueSet.end (); i++)
{
if (i->second == value)
{
@@ -73,44 +73,21 @@
-EnumParamSpec::EnumParamSpec ()
+EnumChecker::EnumChecker ()
{}
void
-EnumParamSpec::AddDefault (int v, std::string name)
+EnumChecker::AddDefault (int v, std::string name)
{
m_valueSet.push_front (std::make_pair (v, name));
}
void
-EnumParamSpec::Add (int v, std::string name)
+EnumChecker::Add (int v, std::string name)
{
m_valueSet.push_back (std::make_pair (v, name));
}
-
bool
-EnumParamSpec::Set (ObjectBase * object, PValue value) const
-{
- const EnumValue *p = value.DynCast<const EnumValue *> ();
- if (p == 0)
- {
- return false;
- }
- DoSet (object, p);
- return true;
-}
-bool
-EnumParamSpec::Get (const ObjectBase * object, PValue value) const
-{
- EnumValue *p = value.DynCast<EnumValue *> ();
- if (p == 0)
- {
- return false;
- }
- DoGet (object, p);
- return true;
-}
-bool
-EnumParamSpec::Check (PValue value) const
+EnumChecker::Check (PValue value) const
{
const EnumValue *p = value.DynCast<const EnumValue *> ();
if (p == 0)
@@ -127,4 +104,79 @@
return false;
}
+Ptr<AttributeChecker>
+MakeEnumChecker (int v1, std::string n1,
+ int v2, std::string n2,
+ int v3, std::string n3,
+ int v4, std::string n4,
+ int v5, std::string n5,
+ int v6, std::string n6,
+ int v7, std::string n7,
+ int v8, std::string n8,
+ int v9, std::string n9,
+ int v10, std::string n10,
+ int v11, std::string n11,
+ int v12, std::string n12)
+{
+ Ptr<EnumChecker> checker = Create<EnumChecker> ();
+ checker->AddDefault (v1, n1);
+ if (n2 == "")
+ {
+ return checker;
+ }
+ checker->Add (v2, n2);
+ if (n3 == "")
+ {
+ return checker;
+ }
+ checker->Add (v3, n3);
+ if (n4 == "")
+ {
+ return checker;
+ }
+ checker->Add (v4, n4);
+ if (n5 == "")
+ {
+ return checker;
+ }
+ checker->Add (v5, n5);
+ if (n6 == "")
+ {
+ return checker;
+ }
+ checker->Add (v6, n6);
+ if (n7 == "")
+ {
+ return checker;
+ }
+ checker->Add (v7, n7);
+ if (n8 == "")
+ {
+ return checker;
+ }
+ checker->Add (v8, n8);
+ if (n9 == "")
+ {
+ return checker;
+ }
+ checker->Add (v9, n9);
+ if (n10 == "")
+ {
+ return checker;
+ }
+ checker->Add (v10, n10);
+ if (n11 == "")
+ {
+ return checker;
+ }
+ checker->Add (v11, n11);
+ if (n12 == "")
+ {
+ return checker;
+ }
+ checker->Add (v12, n12);
+ return checker;
+}
+
+
} // namespace ns3
--- a/src/core/enum-value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/enum-value.h Mon Feb 18 00:18:45 2008 +0100
@@ -15,8 +15,8 @@
int Get (void) const;
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
EnumValue (PValue value);
operator PValue () const;
@@ -24,145 +24,57 @@
int m_v;
};
-class EnumParamSpec : public ParamSpec
+class EnumParamSpec : public ParamSpec {};
+class EnumChecker : public AttributeChecker
{
public:
- EnumParamSpec ();
+ EnumChecker ();
void AddDefault (int v, std::string name);
void Add (int v, std::string name);
- virtual bool Set (ObjectBase* object, PValue value) const;
- virtual bool Get (const ObjectBase* object, PValue value) const;
virtual bool Check (PValue value) const;
private:
- virtual bool DoSet (ObjectBase *object, const EnumValue *value) const = 0;
- virtual bool DoGet (const ObjectBase *object, EnumValue *value) const = 0;
friend class EnumValue;
typedef std::list<std::pair<int,std::string> > ValueSet;
ValueSet m_valueSet;
};
-template <typename T, typename U>
-Ptr<ParamSpec> MakeEnumParamSpec (U T::*v,
- int v1, std::string n1,
- int v2 = 0, std::string n2 = "",
- int v3 = 0, std::string n3 = "",
- int v4 = 0, std::string n4 = "",
- int v5 = 0, std::string n5 = "",
- int v6 = 0, std::string n6 = "",
- int v7 = 0, std::string n7 = "",
- int v8 = 0, std::string n8 = "",
- int v9 = 0, std::string n9 = "",
- int v10 = 0, std::string n10 = "",
- int v11 = 0, std::string n11 = "",
- int v12 = 0, std::string n12 = "");
+template <typename T1>
+Ptr<ParamSpec> MakeEnumParamSpec (T1 a1);
+
+template <typename T1, typename T2>
+Ptr<ParamSpec> MakeEnumParamSpec (T1 a1, T2 a2);
+
+Ptr<AttributeChecker> MakeEnumChecker (int v1, std::string n1,
+ int v2 = 0, std::string n2 = "",
+ int v3 = 0, std::string n3 = "",
+ int v4 = 0, std::string n4 = "",
+ int v5 = 0, std::string n5 = "",
+ int v6 = 0, std::string n6 = "",
+ int v7 = 0, std::string n7 = "",
+ int v8 = 0, std::string n8 = "",
+ int v9 = 0, std::string n9 = "",
+ int v10 = 0, std::string n10 = "",
+ int v11 = 0, std::string n11 = "",
+ int v12 = 0, std::string n12 = "");
} // namespace ns3
namespace ns3 {
-template <typename T, typename U>
-Ptr<ParamSpec> MakeEnumParamSpec (U T::*v,
- int v1, std::string n1,
- int v2 = 0, std::string n2 = "",
- int v3 = 0, std::string n3 = "",
- int v4 = 0, std::string n4 = "",
- int v5 = 0, std::string n5 = "",
- int v6 = 0, std::string n6 = "",
- int v7 = 0, std::string n7 = "",
- int v8 = 0, std::string n8 = "",
- int v9 = 0, std::string n9 = "",
- int v10 = 0, std::string n10 = "",
- int v11 = 0, std::string n11 = "",
- int v12 = 0, std::string n12 = "")
+template <typename T1>
+Ptr<ParamSpec> MakeEnumParamSpec (T1 a1)
{
- class MemberVariable : public EnumParamSpec
- {
- private:
- U T::*m_memberVariable;
- public:
- MemberVariable (U T::*memberVariable)
- : m_memberVariable (memberVariable) {}
- virtual bool DoSet (ObjectBase *object, const EnumValue *value) const {
- T *o = dynamic_cast<T *> (object);
- if (o == 0)
- {
- return false;
- }
- (o->*m_memberVariable) = U (value->Get ());
- return true;
- }
- virtual bool DoGet (const ObjectBase *object, EnumValue *value) const {
- const T *o = dynamic_cast<const T *> (object);
- if (o == 0)
- {
- return false;
- }
- value->Set (o->*m_memberVariable);
- return true;
- }
- };
- Ptr<EnumParamSpec> spec = Ptr<EnumParamSpec> (new MemberVariable (v), false);
- spec->AddDefault (v1, n1);
- if (n2 == "")
- {
- return spec;
- }
- spec->Add (v2, n2);
- if (n3 == "")
- {
- return spec;
- }
- spec->Add (v3, n3);
- if (n4 == "")
- {
- return spec;
- }
- spec->Add (v4, n4);
- if (n5 == "")
- {
- return spec;
- }
- spec->Add (v5, n5);
- if (n6 == "")
- {
- return spec;
- }
- spec->Add (v6, n6);
- if (n7 == "")
- {
- return spec;
- }
- spec->Add (v7, n7);
- if (n8 == "")
- {
- return spec;
- }
- spec->Add (v8, n8);
- if (n9 == "")
- {
- return spec;
- }
- spec->Add (v9, n9);
- if (n10 == "")
- {
- return spec;
- }
- spec->Add (v10, n10);
- if (n11 == "")
- {
- return spec;
- }
- spec->Add (v11, n11);
- if (n12 == "")
- {
- return spec;
- }
- spec->Add (v12, n12);
- return spec;
+ return MakeParamSpecHelper<EnumParamSpec,EnumValue> (a1);
+}
+
+template <typename T1, typename T2>
+Ptr<ParamSpec> MakeEnumParamSpec (T1 a1, T2 a2)
+{
+ return MakeParamSpecHelper<EnumParamSpec,EnumValue> (a1, a2);
}
} // namespace ns3
--- a/src/core/fp-value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/fp-value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -24,14 +24,14 @@
return m_value;
}
std::string
-FpValue::SerializeToString (Ptr<const ParamSpec> spec) const
+FpValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::ostringstream oss;
oss << m_value;
return oss.str ();
}
bool
-FpValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+FpValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
double v;
std::istringstream iss;
@@ -59,16 +59,4 @@
return PValue::Create<FpValue> (*this);
}
-
-
-FpValueChecker::FpValueChecker (double min, double max)
- : m_min (min),
- m_max (max)
-{}
-bool
-FpValueChecker::Check (double v) const
-{
- return v >= m_min && v <= m_max;
-}
-
} // namespace ns3
--- a/src/core/fp-value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/fp-value.h Mon Feb 18 00:18:45 2008 +0100
@@ -13,8 +13,8 @@
FpValue (double value);
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
void Set (double value);
double Get (void) const;
@@ -30,71 +30,59 @@
template <typename T1>
Ptr<ParamSpec> MakeFpParamSpec (T1 a1);
template <typename T1, typename T2>
-Ptr<ParamSpec> MakeFpParamSpec (T1 a1, T2 a2,
- double minValue,
- double maxValue);
+Ptr<ParamSpec> MakeFpParamSpec (T1 a1, T2 a2);
+
+template <typename T>
+Ptr<AttributeChecker> MakeFpChecker (void);
+template <typename T>
+Ptr<AttributeChecker> MakeFpChecker (T min, T max);
+
+
} // namespace ns3
namespace ns3 {
-class FpValueChecker
+template <typename T1>
+Ptr<ParamSpec> MakeFpParamSpec (T1 a1)
{
-public:
- FpValueChecker (double minValue, double maxValue);
- bool Check (double value) const;
-
- template <typename T, typename U>
- static FpValueChecker Create (U T::*) {
- return FpValueChecker (-std::numeric_limits<U>::max (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static FpValueChecker Create (U (T::*) (void) const) {
- return FpValueChecker (-std::numeric_limits<U>::max (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static FpValueChecker Create (void (T::*) (U)) {
- return FpValueChecker (-std::numeric_limits<U>::max (),
- std::numeric_limits<U>::max ());
- }
-private:
- double m_min;
- double m_max;
-};
-
-template <typename T1>
-Ptr<ParamSpec>
-MakeFpParamSpec (T1 a1)
-{
- return MakeParamSpecHelperWithChecker<FpParamSpec,FpValue> (a1,
- FpValueChecker::Create (a1));
-}
-
-template <typename T1>
-Ptr<ParamSpec> MakeFpParamSpec (T1 a1,
- double minValue,
- double maxValue)
-{
- return MakeParamSpecHelperWithChecker<FpParamSpec,FpValue> (a1,
- FpValueChecker (minValue, maxValue));
+ return MakeParamSpecHelper<FpParamSpec,FpValue> (a1);
}
template <typename T1, typename T2>
Ptr<ParamSpec> MakeFpParamSpec (T1 a1, T2 a2)
{
- return MakeParamSpecHelperWithChecker<FpParamSpec,FpValue> (a1, a2,
- FpValueChecker::Create (a1));
+ return MakeParamSpecHelper<FpParamSpec,FpValue> (a1, a2);
+}
+
+template <typename T>
+Ptr<AttributeChecker> MakeFpChecker (void)
+{
+ return MakeFpChecker (-std::numeric_limits<T>::max (),
+ std::numeric_limits<T>::max ());
}
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeFpParamSpec (T1 a1, T2 a2,
- double minValue,
- double maxValue)
+template <typename T>
+Ptr<AttributeChecker> MakeFpChecker (T min, T max)
{
- return MakeParamSpecHelperWithChecker<FpParamSpec,FpValue> (a1, a2,
- FpValueChecker (minValue, maxValue));
+ struct Checker : public AttributeChecker
+ {
+ Checker (double minValue, double maxValue)
+ : m_minValue (minValue),
+ m_maxValue (maxValue) {}
+ virtual bool Check (PValue value) const {
+ const FpValue *v = value.DynCast<const FpValue *> ();
+ if (v == 0)
+ {
+ return false;
+ }
+ return v->Get () >= m_minValue && v->Get () <= m_maxValue;
+ }
+ double m_minValue;
+ double m_maxValue;
+ } *checker = new Checker (min, max);
+ return Ptr<AttributeChecker> (checker, false);
}
+
} // namespace ns3
--- a/src/core/int-value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/int-value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -24,14 +24,14 @@
return m_value;
}
std::string
-IntValue::SerializeToString (Ptr<const ParamSpec> spec) const
+IntValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::ostringstream oss;
oss << m_value;
return oss.str ();
}
bool
-IntValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+IntValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
int64_t v;
std::istringstream iss;
@@ -60,16 +60,4 @@
}
-IntValueChecker::IntValueChecker (int64_t minValue, int64_t maxValue)
- : m_minValue (minValue),
- m_maxValue (maxValue)
-{}
-bool
-IntValueChecker::Check (const int64_t &value) const
-{
- return value >= m_minValue && value <= m_maxValue;
-}
-
-
-
} // namespace ns3
--- a/src/core/int-value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/int-value.h Mon Feb 18 00:18:45 2008 +0100
@@ -15,8 +15,8 @@
int64_t Get (void) const;
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
IntValue (PValue value);
operator PValue () const;
@@ -28,78 +28,63 @@
template <typename T1>
Ptr<ParamSpec> MakeIntParamSpec (T1 a1);
-template <typename T1>
-Ptr<ParamSpec> MakeIntParamSpec (T1 a1,
- int64_t minValue,
- int64_t maxValue);
template <typename T1, typename T2>
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2);
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2,
- int64_t minValue,
- int64_t maxValue);
+
+template <typename T>
+Ptr<AttributeChecker> MakeIntChecker (void);
+
+template <typename T>
+Ptr<AttributeChecker> MakeIntChecker (T min, T max);
} // namespace ns3
namespace ns3 {
-class IntValueChecker
-{
-public:
- IntValueChecker (int64_t minValue, int64_t maxValue);
- bool Check (const int64_t &value) const;
-
- template <typename T, typename U>
- static IntValueChecker Create (U T::*) {
- return IntValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static IntValueChecker Create (U (T::*) (void) const) {
- return IntValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static IntValueChecker Create (void (T::*) (U)) {
- return IntValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
-private:
- int64_t m_minValue;
- int64_t m_maxValue;
-};
-
template <typename T1>
Ptr<ParamSpec>
MakeIntParamSpec (T1 a1)
{
- return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1,
- IntValueChecker::Create (a1));
-}
-
-template <typename T1>
-Ptr<ParamSpec> MakeIntParamSpec (T1 a1,
- int64_t minValue,
- int64_t maxValue)
-{
- return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1,
- IntValueChecker (minValue, maxValue));
+ return MakeParamSpecHelper<IntParamSpec,IntValue> (a1);
}
template <typename T1, typename T2>
Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2)
{
- return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1, a2,
- IntValueChecker::Create (a1));
+ return MakeParamSpecHelper<IntParamSpec,IntValue> (a1, a2);
+}
+
+template <typename T>
+Ptr<AttributeChecker>
+MakeIntChecker (void)
+{
+ return MakeIntChecker (std::numeric_limits<T>::min (),
+ std::numeric_limits<T>::max ());
}
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeIntParamSpec (T1 a1, T2 a2,
- int64_t minValue,
- int64_t maxValue)
+
+template <typename T>
+Ptr<AttributeChecker>
+MakeIntChecker (T min, T max)
{
- return MakeParamSpecHelperWithChecker<IntParamSpec,IntValue> (a1, a2,
- IntValueChecker (minValue, maxValue));
+ struct IntChecker : public AttributeChecker
+ {
+ IntChecker (int64_t minValue, int64_t maxValue)
+ : m_minValue (minValue),
+ m_maxValue (maxValue) {}
+ virtual bool Check (PValue value) const {
+ const IntValue *v = value.DynCast<const IntValue *> ();
+ if (v == 0)
+ {
+ return false;
+ }
+ return v->Get () >= m_minValue && v->Get () <= m_maxValue;
+ }
+ int64_t m_minValue;
+ int64_t m_maxValue;
+ } *checker = new IntChecker (min, max);
+ return Ptr<AttributeChecker> (checker, false);
}
+
} // namespace ns3
#endif /* INT_VALUE_H */
--- a/src/core/object-vector.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/object-vector.cc Mon Feb 18 00:18:45 2008 +0100
@@ -61,13 +61,13 @@
return PValue::Create<ObjectVectorValue> (*this);
}
std::string
-ObjectVectorValue::SerializeToString (Ptr<const ParamSpec> spec) const
+ObjectVectorValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
// XXX
return "";
}
bool
-ObjectVectorValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+ObjectVectorValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
// XXX ?? Can we implement this correctly ?? I doubt it very much.
return true;
@@ -101,11 +101,10 @@
}
return true;
}
-bool
-ObjectVectorParamSpec::Check (PValue value) const
+Ptr<AttributeChecker>
+MakeObjectVectorChecker (void)
{
- const ObjectVectorValue *v = value.DynCast<const ObjectVectorValue *> ();
- return v != 0;
+ return MakeSimpleAttributeChecker<ObjectVectorValue> ();
}
} // name
--- a/src/core/object-vector.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/object-vector.h Mon Feb 18 00:18:45 2008 +0100
@@ -42,6 +42,8 @@
Ptr<U> (T::*get) (INDEX) const);
+Ptr<AttributeChecker> MakeObjectVectorChecker (void);
+
} // namespace ns3
namespace ns3 {
@@ -55,8 +57,8 @@
ObjectVector Get (void) const;
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
private:
friend class ObjectVectorParamSpec;
@@ -68,7 +70,6 @@
public:
virtual bool Set (ObjectBase * object, PValue value) const;
virtual bool Get (const ObjectBase * object, PValue value) const;
- virtual bool Check (PValue value) const;
private:
virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0;
virtual Ptr<Object> DoGet (const ObjectBase *object, uint32_t i) const = 0;
--- a/src/core/object.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/object.cc Mon Feb 18 00:18:45 2008 +0100
@@ -58,12 +58,14 @@
std::string help,
uint32_t flags,
ns3::PValue initialValue,
- ns3::Ptr<const ns3::ParamSpec> spec);
+ ns3::Ptr<const ns3::ParamSpec> spec,
+ ns3::Ptr<const ns3::AttributeChecker> checker);
uint32_t GetParametersN (uint16_t uid) const;
std::string GetParameterName (uint16_t uid, uint32_t i) const;
uint32_t GetParameterFlags (uint16_t uid, uint32_t i) const;
ns3::PValue GetParameterInitialValue (uint16_t uid, uint32_t i) const;
ns3::Ptr<const ns3::ParamSpec> GetParameterParamSpec (uint16_t uid, uint32_t i) const;
+ ns3::Ptr<const ns3::AttributeChecker> GetParameterChecker (uint16_t uid, uint32_t i) const;
private:
struct ConstructorInformation {
ns3::CallbackBase cb;
@@ -75,6 +77,7 @@
uint32_t flags;
ns3::PValue initialValue;
ns3::Ptr<const ns3::ParamSpec> param;
+ ns3::Ptr<const ns3::AttributeChecker> checker;
};
struct IidInformation {
std::string name;
@@ -244,7 +247,8 @@
std::string help,
uint32_t flags,
ns3::PValue initialValue,
- ns3::Ptr<const ns3::ParamSpec> spec)
+ ns3::Ptr<const ns3::ParamSpec> spec,
+ ns3::Ptr<const ns3::AttributeChecker> checker)
{
struct IidInformation *information = LookupInformation (uid);
for (std::vector<struct ParameterInformation>::const_iterator j = information->parameters.begin ();
@@ -262,6 +266,7 @@
param.flags = flags;
param.initialValue = initialValue;
param.param = spec;
+ param.checker = checker;
information->parameters.push_back (param);
}
@@ -300,6 +305,13 @@
NS_ASSERT (i < information->parameters.size ());
return information->parameters[i].param;
}
+ns3::Ptr<const ns3::AttributeChecker>
+IidManager::GetParameterChecker (uint16_t uid, uint32_t i) const
+{
+ struct IidInformation *information = LookupInformation (uid);
+ NS_ASSERT (i < information->parameters.size ());
+ return information->parameters[i].checker;
+}
} // anonymous namespace
@@ -437,6 +449,7 @@
info->spec = GetParameterParamSpec (i);
info->flags = GetParameterFlags (i);
info->initialValue = tid.GetParameterInitialValue (i);
+ info->checker = tid.GetParameterChecker (i);
return true;
}
}
@@ -459,6 +472,7 @@
info->spec = tid.GetParameterParamSpec (j);
info->flags = tid.GetParameterFlags (j);
info->initialValue = tid.GetParameterInitialValue (j);
+ info->checker = tid.GetParameterChecker (j);
return true;
}
cur++;
@@ -530,9 +544,10 @@
TypeId::AddParameter (std::string name,
std::string help,
PValue initialValue,
- Ptr<const ParamSpec> param)
+ Ptr<const ParamSpec> param,
+ Ptr<const AttributeChecker> checker)
{
- Singleton<IidManager>::Get ()->AddParameter (m_tid, name, help, PARAM_SGC, initialValue, param);
+ Singleton<IidManager>::Get ()->AddParameter (m_tid, name, help, PARAM_SGC, initialValue, param, checker);
return *this;
}
@@ -541,9 +556,10 @@
std::string help,
uint32_t flags,
PValue initialValue,
- Ptr<const ParamSpec> param)
+ Ptr<const ParamSpec> param,
+ Ptr<const AttributeChecker> checker)
{
- Singleton<IidManager>::Get ()->AddParameter (m_tid, name, help, flags, initialValue, param);
+ Singleton<IidManager>::Get ()->AddParameter (m_tid, name, help, flags, initialValue, param, checker);
return *this;
}
@@ -607,6 +623,13 @@
uint32_t flags = Singleton<IidManager>::Get ()->GetParameterFlags (m_tid, i);
return flags;
}
+Ptr<const AttributeChecker>
+TypeId::GetParameterChecker (uint32_t i) const
+{
+ // Used exclusively by the Object class.
+ Ptr<const AttributeChecker> checker = Singleton<IidManager>::Get ()->GetParameterChecker (m_tid, i);
+ return checker;
+}
bool operator == (TypeId a, TypeId b)
@@ -631,7 +654,7 @@
for (Params::const_iterator i = o.m_parameters.begin (); i != o.m_parameters.end (); i++)
{
struct Param param;
- param.spec = i->spec;
+ param.checker = i->checker;
param.value = i->value.Copy ();
m_parameters.push_back (param);
}
@@ -643,7 +666,7 @@
for (Params::const_iterator i = o.m_parameters.begin (); i != o.m_parameters.end (); i++)
{
struct Param param;
- param.spec = i->spec;
+ param.checker = i->checker;
param.value = i->value.Copy ();
m_parameters.push_back (param);
}
@@ -678,13 +701,13 @@
}
void
-Parameters::DoSetOne (Ptr<const ParamSpec> spec, PValue value)
+Parameters::DoSetOne (Ptr<const AttributeChecker> checker, PValue value)
{
// get rid of any previous value stored in this
// vector of values.
for (Params::iterator k = m_parameters.begin (); k != m_parameters.end (); k++)
{
- if (k->spec == spec)
+ if (k->checker == checker)
{
m_parameters.erase (k);
break;
@@ -692,18 +715,18 @@
}
// store the new value.
struct Param p;
- p.spec = spec;
+ p.checker = checker;
p.value = value.Copy ();
m_parameters.push_back (p);
}
bool
Parameters::DoSet (struct TypeId::ParameterInfo *info, PValue value)
{
- if (info->spec == 0)
+ if (info->checker == 0)
{
return false;
}
- bool ok = info->spec->Check (value);
+ bool ok = info->checker->Check (value);
if (!ok)
{
// attempt to convert to string.
@@ -714,19 +737,19 @@
}
// attempt to convert back to value.
PValue v = info->initialValue.Copy ();
- ok = v.DeserializeFromString (str->Get (), info->spec);
+ ok = v.DeserializeFromString (str->Get (), info->checker);
if (!ok)
{
return false;
}
- ok = info->spec->Check (v);
+ ok = info->checker->Check (v);
if (!ok)
{
return false;
}
value = v;
}
- DoSetOne (info->spec, value);
+ DoSetOne (info->checker, value);
return true;
}
void
@@ -741,14 +764,14 @@
}
std::string
-Parameters::LookupParameterFullNameByParamSpec (Ptr<const ParamSpec> spec) const
+Parameters::LookupParameterFullNameByChecker (Ptr<const AttributeChecker> checker) const
{
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); i++)
{
TypeId tid = TypeId::GetRegistered (i);
for (uint32_t j = 0; j < tid.GetParametersN (); j++)
{
- if (spec == tid.GetParameterParamSpec (j))
+ if (checker == tid.GetParameterChecker (j))
{
return tid.GetParameterFullName (j);
}
@@ -765,8 +788,8 @@
std::ostringstream oss;
for (Params::const_iterator i = m_parameters.begin (); i != m_parameters.end (); i++)
{
- std::string name = LookupParameterFullNameByParamSpec (i->spec);
- oss << name << "=" << i->value.SerializeToString (PeekPointer (i->spec));
+ std::string name = LookupParameterFullNameByChecker (i->checker);
+ oss << name << "=" << i->value.SerializeToString (i->checker);
if (i != m_parameters.end ())
{
oss << "|";
@@ -812,7 +835,7 @@
cur++;
}
PValue val = info.initialValue.Copy ();
- bool ok = val.DeserializeFromString (value, info.spec);
+ bool ok = val.DeserializeFromString (value, info.checker);
if (!ok)
{
// XXX invalid value
@@ -820,7 +843,7 @@
}
else
{
- DoSetOne (info.spec, val);
+ DoSetOne (info.checker, val);
}
}
}
@@ -875,6 +898,7 @@
{
Ptr<const ParamSpec> paramSpec = tid.GetParameterParamSpec (i);
PValue initial = tid.GetParameterInitialValue (i);
+ Ptr<const AttributeChecker> checker = tid.GetParameterChecker (i);
NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<<
tid.GetParameterName (i)<<"\"");
if (!(tid.GetParameterFlags (i) & TypeId::PARAM_CONSTRUCT))
@@ -886,10 +910,10 @@
for (Parameters::Params::const_iterator j = parameters.m_parameters.begin ();
j != parameters.m_parameters.end (); j++)
{
- if (j->spec == paramSpec)
+ if (j->checker == checker)
{
// We have a matching parameter value.
- DoSet (paramSpec, initial, j->value);
+ DoSet (paramSpec, initial, checker, j->value);
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
tid.GetParameterName (i)<<"\"");
found = true;
@@ -902,10 +926,10 @@
for (Parameters::Params::const_iterator j = Parameters::GetGlobal ()->m_parameters.begin ();
j != Parameters::GetGlobal ()->m_parameters.end (); j++)
{
- if (j->spec == paramSpec)
+ if (j->checker == checker)
{
// We have a matching parameter value.
- DoSet (paramSpec, initial, j->value);
+ DoSet (paramSpec, initial, checker, j->value);
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
tid.GetParameterName (i)<<"\" from global");
found = true;
@@ -926,9 +950,10 @@
NotifyConstructionCompleted ();
}
bool
-Object::DoSet (Ptr<const ParamSpec> spec, PValue initialValue, PValue value)
+Object::DoSet (Ptr<const ParamSpec> spec, PValue initialValue,
+ Ptr<const AttributeChecker> checker, PValue value)
{
- bool ok = spec->Check (value);
+ bool ok = checker->Check (value);
if (!ok)
{
// attempt to convert to string
@@ -939,12 +964,12 @@
}
// attempt to convert back from string.
PValue v = initialValue.Copy ();
- ok = v.DeserializeFromString (str->Get (), spec);
+ ok = v.DeserializeFromString (str->Get (), checker);
if (!ok)
{
return false;
}
- ok = spec->Check (v);
+ ok = checker->Check (v);
if (!ok)
{
return false;
@@ -966,7 +991,7 @@
{
return false;
}
- return DoSet (info.spec, info.initialValue, value);
+ return DoSet (info.spec, info.initialValue, info.checker, value);
}
bool
Object::Get (std::string name, std::string &value) const
@@ -984,7 +1009,7 @@
bool ok = info.spec->Get (this, v);
if (ok)
{
- value = v.SerializeToString (info.spec);
+ value = v.SerializeToString (info.checker);
}
return ok;
}
--- a/src/core/object.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/object.h Mon Feb 18 00:18:45 2008 +0100
@@ -213,7 +213,8 @@
TypeId AddParameter (std::string name,
std::string help,
PValue initialValue,
- Ptr<const ParamSpec> spec);
+ Ptr<const ParamSpec> spec,
+ Ptr<const AttributeChecker> checker);
/**
* \param name the name of the new parameter
@@ -229,7 +230,8 @@
std::string help,
uint32_t flags,
PValue initialValue,
- Ptr<const ParamSpec> spec);
+ Ptr<const ParamSpec> spec,
+ Ptr<const AttributeChecker> checker);
// construct an invalid TypeId.
TypeId ();
@@ -244,6 +246,7 @@
Ptr<const ParamSpec> spec;
PValue initialValue;
uint32_t flags;
+ Ptr<const AttributeChecker> checker;
};
/**
@@ -267,6 +270,7 @@
CallbackBase LookupConstructor (uint32_t nArguments) const;
Ptr<const ParamSpec> GetParameterParamSpec (uint32_t i) const;
uint32_t GetParameterFlags (uint32_t i) const;
+ Ptr<const AttributeChecker> GetParameterChecker (uint32_t i) const;
uint16_t m_tid;
};
@@ -320,7 +324,7 @@
private:
friend class Object;
struct Param {
- Ptr<const ParamSpec> spec;
+ Ptr<const AttributeChecker> checker;
PValue value;
};
typedef std::vector<struct Param> Params;
@@ -330,8 +334,8 @@
bool DoSet (struct TypeId::ParameterInfo *info, PValue param);
- void DoSetOne (Ptr<const ParamSpec> spec, PValue param);
- std::string LookupParameterFullNameByParamSpec (Ptr<const ParamSpec> spec) const;
+ void DoSetOne (Ptr<const AttributeChecker> checker, PValue param);
+ std::string LookupParameterFullNameByChecker (Ptr<const AttributeChecker> checker) const;
Params m_parameters;
};
@@ -469,7 +473,8 @@
friend Ptr<T> CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7);
- bool DoSet (Ptr<const ParamSpec> spec, PValue intialValue, PValue value);
+ bool DoSet (Ptr<const ParamSpec> spec, PValue intialValue,
+ Ptr<const AttributeChecker> checker, PValue value);
Ptr<Object> DoGetObject (TypeId tid) const;
void DoCollectSources (std::string path, const TraceContext &context,
TraceResolver::SourceCollection *collection) const;
--- a/src/core/param-spec-helper.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/param-spec-helper.h Mon Feb 18 00:18:45 2008 +0100
@@ -11,14 +11,6 @@
Ptr<ParamSpec>
MakeParamSpecHelper (T1 a1, T2 a2);
-template <typename BASE, typename V, typename T1, typename CHECKER>
-Ptr<ParamSpec>
-MakeParamSpecHelperWithChecker (T1 a1, CHECKER checker);
-
-template <typename BASE, typename V, typename T1, typename T2, typename CHECKER>
-Ptr<ParamSpec>
-MakeParamSpecHelperWithChecker (T1 a1, T2 a2, CHECKER checker);
-
} // namespace ns3
/***************************************************************
@@ -29,12 +21,11 @@
namespace ns3 {
-template <typename BASE, typename T, typename U, typename CHECKER>
+template <typename BASE, typename T, typename U>
class ParamSpecHelper : public BASE
{
public:
- ParamSpecHelper (CHECKER checker)
- : m_checker (checker) {}
+ ParamSpecHelper () {}
virtual bool Set (ObjectBase * object, PValue val) const {
const U *value = val.DynCast<const U*> ();
@@ -64,43 +55,26 @@
return DoGet (obj, value);
}
- virtual bool Check (PValue value) const {
- const U *val = value.DynCast<const U*> ();
- if (val == 0)
- {
- return false;
- }
- return m_checker.Check (val->Get ());
- }
-
private:
virtual bool DoSet (T *object, const U *v) const = 0;
virtual bool DoGet (const T *object, U *v) const = 0;
- CHECKER m_checker;
-};
-
-template <typename T>
-class ParamSpecHelperSimpleChecker
-{
-public:
- bool Check (const T &value) const {return true;}
};
-template <typename BASE, typename V, typename T, typename U, typename CHECKER>
+template <typename BASE, typename V, typename T, typename U>
Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (U T::*memberVariable, CHECKER checker)
+DoMakeParamSpecHelperOne (U T::*memberVariable)
{
- class MemberVariable : public ParamSpecHelper<BASE,T,V,CHECKER>
+ class MemberVariable : public ParamSpecHelper<BASE,T,V>
{
public:
- MemberVariable (U T::*memberVariable, CHECKER checker)
- : ParamSpecHelper<BASE,T,V,CHECKER> (checker),
+ MemberVariable (U T::*memberVariable)
+ : ParamSpecHelper<BASE,T,V> (),
m_memberVariable (memberVariable)
{}
private:
virtual bool DoSet (T *object, const V *v) const {
- (object->*m_memberVariable) = v->Get ();
+ (object->*m_memberVariable) = U (v->Get ());
return true;
}
virtual bool DoGet (const T *object, V *v) const {
@@ -110,27 +84,18 @@
U T::*m_memberVariable;
};
- return Ptr<ParamSpec> (new MemberVariable (memberVariable, checker), false);
-}
-template <typename BASE, typename V, typename T, typename U>
-Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (U T::*memberVariable)
-{
- return DoMakeParamSpecHelperOne<BASE,V> (memberVariable, ParamSpecHelperSimpleChecker<U> ());
+ return Ptr<ParamSpec> (new MemberVariable (memberVariable), false);
}
-
-template <typename BASE, typename V, typename T, typename U, typename CHECKER>
+template <typename BASE, typename V, typename T, typename U>
Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (U (T::*getter) (void) const,
- CHECKER checker)
+DoMakeParamSpecHelperOne (U (T::*getter) (void) const)
{
- class MemberMethod : public ParamSpecHelper<BASE,T,V,CHECKER>
+ class MemberMethod : public ParamSpecHelper<BASE,T,V>
{
public:
- MemberMethod (U (T::*getter) (void) const,
- CHECKER checker)
- : ParamSpecHelper<BASE,T,V,CHECKER> (checker),
+ MemberMethod (U (T::*getter) (void) const)
+ : ParamSpecHelper<BASE,T,V> (),
m_getter (getter)
{}
private:
@@ -143,29 +108,19 @@
}
U (T::*m_getter) (void) const;
};
- return Ptr<ParamSpec> (new MemberMethod (getter, checker), false);
-}
-
-template <typename BASE, typename V, typename T, typename U>
-Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (U (T::*getter) (void) const)
-{
- return DoMakeParamSpecHelperOne<BASE,V> (getter, ParamSpecHelperSimpleChecker<U> ());
+ return Ptr<ParamSpec> (new MemberMethod (getter), false);
}
-
-template <typename BASE, typename V, typename T, typename U, typename CHECKER>
+template <typename BASE, typename V, typename T, typename U>
Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (void (T::*setter) (U),
- CHECKER checker)
+DoMakeParamSpecHelperOne (void (T::*setter) (U))
{
- class MemberMethod : public ParamSpecHelper<BASE,T,V,CHECKER>
+ class MemberMethod : public ParamSpecHelper<BASE,T,V>
{
public:
- MemberMethod (void (T::*setter) (U),
- CHECKER checker)
- : ParamSpecHelper<BASE,T,V,CHECKER> (checker),
+ MemberMethod (void (T::*setter) (U))
+ : ParamSpecHelper<BASE,T,V> (),
m_setter (setter)
{}
private:
@@ -178,31 +133,20 @@
}
void (T::*m_setter) (U);
};
- return Ptr<ParamSpec> (new MemberMethod (setter, checker), false);
+ return Ptr<ParamSpec> (new MemberMethod (setter), false);
}
-template <typename BASE, typename V, typename T, typename U>
-Ptr<ParamSpec>
-DoMakeParamSpecHelperOne (void (T::*setter) (U))
-{
- return DoMakeParamSpecHelperOne<BASE,V> (setter,
- ParamSpecHelperSimpleChecker<typename TypeTraits<U>::ReferencedType> ());
-}
-
-
-template <typename BASE, typename W, typename T, typename U, typename V, typename CHECKER>
+template <typename BASE, typename W, typename T, typename U, typename V>
Ptr<ParamSpec>
DoMakeParamSpecHelperTwo (void (T::*setter) (U),
- V (T::*getter) (void) const,
- CHECKER checker = ParamSpecHelperSimpleChecker<V> ())
+ V (T::*getter) (void) const)
{
- class MemberMethod : public ParamSpecHelper<BASE,T,W,CHECKER>
+ class MemberMethod : public ParamSpecHelper<BASE,T,W>
{
public:
MemberMethod (void (T::*setter) (U),
- V (T::*getter) (void) const,
- CHECKER checker)
- : ParamSpecHelper<BASE,T,W,CHECKER> (checker),
+ V (T::*getter) (void) const)
+ : ParamSpecHelper<BASE,T,W> (),
m_setter (setter),
m_getter (getter)
{}
@@ -218,28 +162,11 @@
void (T::*m_setter) (U);
V (T::*m_getter) (void) const;
};
- return Ptr<ParamSpec> (new MemberMethod (setter, getter, checker), false);
+ return Ptr<ParamSpec> (new MemberMethod (setter, getter), false);
}
template <typename BASE, typename W, typename T, typename U, typename V>
Ptr<ParamSpec>
-DoMakeParamSpecHelperTwo (void (T::*setter) (U),
- V (T::*getter) (void) const)
-{
- return DoMakeParamSpecHelperTwo<BASE,W> (setter, getter, ParamSpecHelperSimpleChecker<V> ());
-}
-
-template <typename BASE, typename W, typename T, typename U, typename V, typename CHECKER>
-Ptr<ParamSpec>
-DoMakeParamSpecHelperTwo (V (T::*getter) (void) const,
- void (T::*setter) (U),
- CHECKER checker)
-{
- return DoMakeParamSpecHelperTwo<BASE,W> (setter, getter, checker);
-}
-
-template <typename BASE, typename W, typename T, typename U, typename V, typename CHECKER>
-Ptr<ParamSpec>
DoMakeParamSpecHelperTwo (V (T::*getter) (void) const,
void (T::*setter) (U))
{
@@ -260,20 +187,6 @@
return DoMakeParamSpecHelperTwo<BASE,V> (a1, a2);
}
-template <typename BASE, typename V, typename T1, typename CHECKER>
-Ptr<ParamSpec>
-MakeParamSpecHelperWithChecker (T1 a1, CHECKER checker)
-{
- return DoMakeParamSpecHelperOne<BASE,V> (a1, checker);
-}
-
-template <typename BASE, typename V, typename T1, typename T2, typename CHECKER>
-Ptr<ParamSpec>
-MakeParamSpecHelperWithChecker (T1 a1, T2 a2, CHECKER checker)
-{
- return DoMakeParamSpecHelperTwo<BASE,V> (a1, a2, checker);
-}
-
} // namespace ns3
#endif /* PARAM_SPEC_HELPER_H */
--- a/src/core/random-variable.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/random-variable.cc Mon Feb 18 00:18:45 2008 +0100
@@ -309,6 +309,12 @@
return ClassValueHelperConvertTo<RandomVariable,RandomVariableValue> (this);
}
+Ptr<AttributeChecker>
+MakeRandomVariableChecker (void)
+{
+ return MakeSimpleAttributeChecker<RandomVariableValue> ();
+}
+
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
--- a/src/core/random-variable.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/random-variable.h Mon Feb 18 00:18:45 2008 +0100
@@ -673,6 +673,7 @@
template <typename T1, typename T2>
Ptr<ParamSpec> MakeRandomVariableParamSpec (T1 a1, T2 a2);
+Ptr<AttributeChecker> MakeRandomVariableChecker (void);
}//namespace ns3
--- a/src/core/uint-value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/uint-value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -24,14 +24,14 @@
return m_value;
}
std::string
-UintValue::SerializeToString (Ptr<const ParamSpec> spec) const
+UintValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::ostringstream oss;
oss << m_value;
return oss.str ();
}
bool
-UintValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+UintValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
uint64_t v;
std::istringstream iss;
@@ -59,17 +59,4 @@
return PValue::Create<UintValue> (*this);
}
-
-
-UintValueChecker::UintValueChecker (uint64_t minValue, uint64_t maxValue)
- : m_minValue (minValue),
- m_maxValue (maxValue)
-{}
-bool
-UintValueChecker::Check (const uint64_t &value) const
-{
- return value >= m_minValue && value <= m_maxValue;
-}
-
-
} // namespace ns3
--- a/src/core/uint-value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/uint-value.h Mon Feb 18 00:18:45 2008 +0100
@@ -12,8 +12,8 @@
public:
UintValue (uint64_t value);
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
void Set (uint64_t value);
uint64_t Get (void) const;
@@ -28,76 +28,57 @@
template <typename T1>
Ptr<ParamSpec> MakeUintParamSpec (T1 a1);
-template <typename T1>
-Ptr<ParamSpec> MakeUintParamSpec (T1 a1,
- uint64_t minValue,
- uint64_t maxValue);
template <typename T1, typename T2>
Ptr<ParamSpec> MakeUintParamSpec (T1 a1, T2 a2);
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeUintParamSpec (T1 a1, T2 a2,
- uint64_t minValue,
- uint64_t maxValue);
+
+template <typename T>
+Ptr<AttributeChecker> MakeUintChecker (void);
+template <typename T>
+Ptr<AttributeChecker> MakeUintChecker (T min, T max);
} // namespace ns3
namespace ns3 {
-class UintValueChecker
-{
-public:
- UintValueChecker (uint64_t minValue, uint64_t maxValue);
- bool Check (const uint64_t &value) const;
-
- template <typename T, typename U>
- static UintValueChecker Create (U T::*) {
- return UintValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static UintValueChecker Create (U (T::*) (void) const) {
- return UintValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
- template <typename T, typename U>
- static UintValueChecker Create (void (T::*) (U)) {
- return UintValueChecker (std::numeric_limits<U>::min (),
- std::numeric_limits<U>::max ());
- }
-private:
- uint64_t m_minValue;
- uint64_t m_maxValue;
-};
-
template <typename T1>
Ptr<ParamSpec>
MakeUintParamSpec (T1 a1)
{
- return MakeParamSpecHelperWithChecker<UintParamSpec,UintValue> (a1,
- UintValueChecker::Create (a1));
+ return MakeParamSpecHelper<UintParamSpec,UintValue> (a1);
}
-template <typename T1>
-Ptr<ParamSpec> MakeUintParamSpec (T1 a1,
- uint64_t minValue,
- uint64_t maxValue)
-{
- return MakeParamSpecHelperWithChecker<UintParamSpec,UintValue> (a1,
- UintValueChecker (minValue, maxValue));
-}
template <typename T1, typename T2>
Ptr<ParamSpec> MakeUintParamSpec (T1 a1, T2 a2)
{
- return MakeParamSpecHelperWithChecker<UintParamSpec,UintValue> (a1, a2,
- UintValueChecker::Create (a1));
+ return MakeParamSpecHelper<UintParamSpec,UintValue> (a1, a2);
+}
+
+template <typename T>
+Ptr<AttributeChecker> MakeUintChecker (void)
+{
+ return MakeUintChecker (std::numeric_limits<T>::min (),
+ std::numeric_limits<T>::max ());
}
-template <typename T1, typename T2>
-Ptr<ParamSpec> MakeUintParamSpec (T1 a1, T2 a2,
- uint64_t minValue,
- uint64_t maxValue)
+template <typename T>
+Ptr<AttributeChecker> MakeUintChecker (T min, T max)
{
- return MakeParamSpecHelperWithChecker<UintParamSpec,UintValue> (a1, a2,
- UintValueChecker (minValue, maxValue));
+ struct Checker : public AttributeChecker
+ {
+ Checker (uint64_t minValue, uint64_t maxValue)
+ : m_minValue (minValue),
+ m_maxValue (maxValue) {}
+ virtual bool Check (PValue value) const {
+ const UintValue *v = value.DynCast<const UintValue *> ();
+ if (v == 0)
+ {
+ return false;
+ }
+ return v->Get () >= m_minValue && v->Get () <= m_maxValue;
+ }
+ uint64_t m_minValue;
+ uint64_t m_maxValue;
+ } *checker = new Checker (min, max);
+ return Ptr<AttributeChecker> (checker, false);
}
} // namespace ns3
--- a/src/core/value-helper.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/value-helper.h Mon Feb 18 00:18:45 2008 +0100
@@ -10,6 +10,7 @@
#define VALUE_HELPER_HEADER_2(type) \
class type##Value : public Value {}; \
class type##ParamSpec : public ParamSpec {}; \
+ Ptr<AttributeChecker> Make##type##Checker (void); \
template <typename T1> \
Ptr<ParamSpec> Make##type##ParamSpec (T1 a1) \
{ \
@@ -24,6 +25,10 @@
}
#define VALUE_HELPER_CPP(type) \
+ Ptr<AttributeChecker> Make##type##Checker (void) \
+ { \
+ return MakeSimpleAttributeChecker<type> (); \
+ } \
type::type (PValue value) \
{ \
*this = ClassValueHelperExtractFrom<type,type##Value> (value); \
--- a/src/core/value-test.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/value-test.cc Mon Feb 18 00:18:45 2008 +0100
@@ -43,47 +43,57 @@
.SetParent<Object> ()
.AddParameter ("TestBoolName", "help text",
BooleanValue (false),
- MakeBooleanParamSpec (&ParamSpecObjectTest::m_boolTest))
+ MakeBooleanParamSpec (&ParamSpecObjectTest::m_boolTest),
+ MakeBooleanChecker ())
.AddParameter ("TestBoolA", "help text",
BooleanValue (false),
MakeBooleanParamSpec (&ParamSpecObjectTest::DoSetTestB,
- &ParamSpecObjectTest::DoGetTestB))
+ &ParamSpecObjectTest::DoGetTestB),
+ MakeBooleanChecker ())
.AddParameter ("TestPtr", "help text",
Ptr<Derived> (0),
- MakePtrParamSpec (&ParamSpecObjectTest::m_derived))
+ MakePtrParamSpec (&ParamSpecObjectTest::m_derived),
+ MakePtrChecker<Derived> ())
.AddParameter ("TestInt16", "help text",
IntValue (-2),
- MakeIntParamSpec (&ParamSpecObjectTest::m_int16))
+ MakeIntParamSpec (&ParamSpecObjectTest::m_int16),
+ MakeIntChecker<int16_t> ())
.AddParameter ("TestInt16WithBounds", "help text",
IntValue (-2),
- MakeIntParamSpec (&ParamSpecObjectTest::m_int16WithBounds,
- -5, 10))
+ MakeIntParamSpec (&ParamSpecObjectTest::m_int16WithBounds),
+ MakeIntChecker (-5, 10))
.AddParameter ("TestInt16SetGet", "help text",
IntValue (6),
MakeIntParamSpec (&ParamSpecObjectTest::DoSetInt16,
- &ParamSpecObjectTest::DoGetInt16))
+ &ParamSpecObjectTest::DoGetInt16),
+ MakeIntChecker<int16_t> ())
.AddParameter ("TestUint8", "help text",
UintValue (1),
- MakeUintParamSpec (&ParamSpecObjectTest::m_uint8))
+ MakeUintParamSpec (&ParamSpecObjectTest::m_uint8),
+ MakeUintChecker<uint8_t> ())
.AddParameter ("TestEnum", "help text",
EnumValue (TEST_A),
- MakeEnumParamSpec (&ParamSpecObjectTest::m_enum,
- TEST_A, "TestA",
- TEST_B, "TestB",
- TEST_C, "TestC"))
+ MakeEnumParamSpec (&ParamSpecObjectTest::m_enum),
+ MakeEnumChecker (TEST_A, "TestA",
+ TEST_B, "TestB",
+ TEST_C, "TestC"))
.AddParameter ("TestRandom", "help text",
ConstantVariable (1.0),
- MakeRandomVariableParamSpec (&ParamSpecObjectTest::m_random))
+ MakeRandomVariableParamSpec (&ParamSpecObjectTest::m_random),
+ MakeRandomVariableChecker ())
.AddParameter ("TestFloat", "help text",
FpValue (-1.1),
- MakeFpParamSpec (&ParamSpecObjectTest::m_float))
+ MakeFpParamSpec (&ParamSpecObjectTest::m_float),
+ MakeFpChecker<float> ())
.AddParameter ("TestVector1", "help text",
ObjectVector (),
- MakeObjectVectorParamSpec (&ParamSpecObjectTest::m_vector1))
+ MakeObjectVectorParamSpec (&ParamSpecObjectTest::m_vector1),
+ MakeObjectVectorChecker ())
.AddParameter ("TestVector2", "help text",
ObjectVector (),
MakeObjectVectorParamSpec (&ParamSpecObjectTest::DoGetVectorN,
- &ParamSpecObjectTest::DoGetVector))
+ &ParamSpecObjectTest::DoGetVector),
+ MakeObjectVectorChecker ())
;
return tid;
--- a/src/core/value.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/value.cc Mon Feb 18 00:18:45 2008 +0100
@@ -103,14 +103,14 @@
return m_value->Copy ();
}
std::string
-PValue::SerializeToString (Ptr<const ParamSpec> spec) const
+PValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
- return m_value->SerializeToString (spec);
+ return m_value->SerializeToString (checker);
}
bool
-PValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+PValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
- return m_value->DeserializeFromString (value, spec);
+ return m_value->DeserializeFromString (value, checker);
}
PValue::PValue (const char *value)
@@ -141,6 +141,25 @@
ParamSpec::~ParamSpec ()
{}
+AttributeChecker::AttributeChecker ()
+ : m_count (1)
+{}
+void
+AttributeChecker::Ref (void) const
+{
+ m_count++;
+}
+void
+AttributeChecker::Unref (void) const
+{
+ m_count--;
+ if (m_count == 0)
+ {
+ delete this;
+ }
+}
+AttributeChecker::~AttributeChecker ()
+{}
StringValue::StringValue (const char *value)
: m_value (value)
@@ -164,12 +183,12 @@
return PValue::Create<StringValue> (*this);
}
std::string
-StringValue::SerializeToString (Ptr<const ParamSpec> spec) const
+StringValue::SerializeToString (Ptr<const AttributeChecker> checker) const
{
return m_value;
}
bool
-StringValue::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+StringValue::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
m_value = value;
return true;
@@ -190,7 +209,7 @@
std::string
-PtrValueBase::SerializeToString (Ptr<const ParamSpec> spec) const
+PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::ostringstream oss;
oss << PeekObjectBase ();
@@ -198,7 +217,7 @@
}
bool
-PtrValueBase::DeserializeFromString (std::string value, Ptr<const ParamSpec> spec)
+PtrValueBase::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
// XXX
return false;
--- a/src/core/value.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/core/value.h Mon Feb 18 00:18:45 2008 +0100
@@ -9,6 +9,7 @@
namespace ns3 {
class ParamSpec;
+class AttributeChecker;
class PValue;
class Value
@@ -20,8 +21,8 @@
virtual ~Value ();
virtual PValue Copy (void) const = 0;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const = 0;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec) = 0;
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const = 0;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0;
private:
friend class PValue;
uint32_t m_count;
@@ -36,8 +37,8 @@
~PValue ();
PValue Copy (void) const;
- std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
template <typename T>
static PValue Create (void);
@@ -75,11 +76,25 @@
*/
virtual bool Set (ObjectBase * object, PValue value) const = 0;
virtual bool Get (const ObjectBase * object, PValue value) const = 0;
+private:
+ mutable uint32_t m_count;
+};
+
+class AttributeChecker : public ObjectBase
+{
+public:
+ AttributeChecker ();
+ void Ref (void) const;
+ void Unref (void) const;
+ virtual ~AttributeChecker ();
virtual bool Check (PValue value) const = 0;
private:
mutable uint32_t m_count;
};
+template <typename T>
+Ptr<AttributeChecker>
+MakeSimpleAttributeChecker (void);
template <typename T, typename U>
Ptr<const ParamSpec>
@@ -110,8 +125,8 @@
std::string Get (void) const;
virtual PValue Copy (void) const;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
StringValue (PValue value);
operator PValue () const;
@@ -130,8 +145,8 @@
public:
virtual ObjectBase *PeekObjectBase (void) const = 0;
virtual bool SetObjectBase (ObjectBase *object) = 0;
- virtual std::string SerializeToString (Ptr<const ParamSpec> spec) const;
- virtual bool DeserializeFromString (std::string value, Ptr<const ParamSpec> spec);
+ virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
+ virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
};
/********************************************************
@@ -253,23 +268,6 @@
}
return value->SetObjectBase (PeekPointer (DoGet (obj)));
}
- virtual bool Check (PValue val) const {
- const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
- if (value == 0)
- {
- return false;
- }
- if (value->PeekObjectBase () == 0)
- {
- return true;
- }
- U *ptr = dynamic_cast<U*> (value->PeekObjectBase ());
- if (ptr == 0)
- {
- return false;
- }
- return true;
- }
private:
virtual void DoSet (T *object, Ptr<U> value) const = 0;
virtual Ptr<U> DoGet (const T *object) const = 0;
@@ -340,6 +338,47 @@
return Ptr<const ParamSpec> (spec, false);
}
+template <typename T>
+Ptr<AttributeChecker>
+MakePtrChecker (void)
+{
+ struct PtrChecker : public AttributeChecker
+ {
+ virtual bool Check (PValue val) const {
+ const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
+ if (value == 0)
+ {
+ return false;
+ }
+ if (value->PeekObjectBase () == 0)
+ {
+ return true;
+ }
+ T *ptr = dynamic_cast<T*> (value->PeekObjectBase ());
+ if (ptr == 0)
+ {
+ return false;
+ }
+ return true;
+ }
+ } *checker = new PtrChecker ();
+ return Ptr<AttributeChecker> (checker, false);
+}
+
+template <typename T>
+Ptr<AttributeChecker>
+MakeSimpleAttributeChecker (void)
+{
+ struct SimpleAttributeChecker : public AttributeChecker
+ {
+ virtual bool Check (PValue value) const {
+ return value.DynCast<const T *> () != 0;
+ }
+ } *checker = new SimpleAttributeChecker ();
+ return Ptr<AttributeChecker> (checker, false);
+}
+
+
} // namespace ns3
#endif /* VALUE_H */
--- a/src/mobility/hierarchical-mobility-model.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/hierarchical-mobility-model.cc Mon Feb 18 00:18:45 2008 +0100
@@ -32,10 +32,12 @@
.AddConstructor<HierarchicalMobilityModel> ()
.AddParameter ("child", "The child mobility model.",
Ptr<MobilityModel> (0),
- MakePtrParamSpec (&HierarchicalMobilityModel::SetChild))
+ MakePtrParamSpec (&HierarchicalMobilityModel::SetChild),
+ MakePtrChecker<MobilityModel> ())
.AddParameter ("parent", "The parent mobility model.",
Ptr<MobilityModel> (0),
- MakePtrParamSpec (&HierarchicalMobilityModel::SetParent))
+ MakePtrParamSpec (&HierarchicalMobilityModel::SetParent),
+ MakePtrChecker<MobilityModel> ())
;
return tid;
}
--- a/src/mobility/mobility-model.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/mobility-model.cc Mon Feb 18 00:18:45 2008 +0100
@@ -32,11 +32,13 @@
TypeId::PARAM_SGC,
Vector (0.0, 0.0, 0.0),
MakeVectorParamSpec (&MobilityModel::SetPosition,
- &MobilityModel::GetPosition))
+ &MobilityModel::GetPosition),
+ MakeVectorChecker ())
.AddParameter ("velocity", "The current velocity of the mobility model.",
TypeId::PARAM_GET,
Vector (0.0, 0.0, 0.0), // ignored initial value.
- MakeVectorParamSpec (&MobilityModel::GetVelocity))
+ MakeVectorParamSpec (&MobilityModel::GetVelocity),
+ MakeVectorChecker ())
;
return tid;
}
--- a/src/mobility/position-allocator.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/position-allocator.cc Mon Feb 18 00:18:45 2008 +0100
@@ -55,24 +55,29 @@
.AddConstructor<GridPositionAllocator> ()
.AddParameter ("GridWidth", "The number of objects layed out on a line.",
IntValue (10),
- MakeIntParamSpec (&GridPositionAllocator::m_n))
+ MakeIntParamSpec (&GridPositionAllocator::m_n),
+ MakeIntChecker<uint32_t> ())
.AddParameter ("MinX", "The x coordinate where the grid starts.",
FpValue (1.0),
- MakeFpParamSpec (&GridPositionAllocator::m_xMin))
+ MakeFpParamSpec (&GridPositionAllocator::m_xMin),
+ MakeFpChecker<double> ())
.AddParameter ("MinY", "The y coordinate where the grid starts.",
FpValue (0.0),
- MakeFpParamSpec (&GridPositionAllocator::m_yMin))
+ MakeFpParamSpec (&GridPositionAllocator::m_yMin),
+ MakeFpChecker<double> ())
.AddParameter ("DeltaX", "The x space between objects.",
FpValue (1.0),
- MakeFpParamSpec (&GridPositionAllocator::m_deltaX))
+ MakeFpParamSpec (&GridPositionAllocator::m_deltaX),
+ MakeFpChecker<double> ())
.AddParameter ("DeltaY", "The y space between objects.",
FpValue (1.0),
- MakeFpParamSpec (&GridPositionAllocator::m_deltaY))
+ MakeFpParamSpec (&GridPositionAllocator::m_deltaY),
+ MakeFpChecker<double> ())
.AddParameter ("LayoutType", "The type of layout.",
EnumValue (ROW_FIRST),
- MakeEnumParamSpec (&GridPositionAllocator::m_layoutType,
- ROW_FIRST, "RowFirst",
- COLUMN_FIRST, "ColumnFirst"))
+ MakeEnumParamSpec (&GridPositionAllocator::m_layoutType),
+ MakeEnumChecker (ROW_FIRST, "RowFirst",
+ COLUMN_FIRST, "ColumnFirst"))
;
return tid;
}
@@ -111,11 +116,13 @@
.AddParameter ("X",
"A random variable which represents the x coordinate of a position in a random rectangle.",
UniformVariable (0.0, 1.0),
- MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_x))
+ MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_x),
+ MakeRandomVariableChecker ())
.AddParameter ("Y",
"A random variable which represents the y coordinate of a position in a random rectangle.",
UniformVariable (0.0, 1.0),
- MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_y));
+ MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_y),
+ MakeRandomVariableChecker ());
return tid;
}
@@ -143,19 +150,24 @@
.AddParameter ("Theta",
"A random variable which represents the angle (gradients) of a position in a random disc.",
UniformVariable (0.0, 6.2830),
- MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_theta))
+ MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_theta),
+ MakeRandomVariableChecker ())
.AddParameter ("Rho",
"A random variable which represents the radius of a position in a random disc.",
UniformVariable (0.0, 200.0),
- MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_rho))
+ MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_rho),
+ MakeRandomVariableChecker ())
.AddParameter ("X",
"The x coordinate of the center of the random position disc.",
FpValue (0.0),
- MakeFpParamSpec (&RandomDiscPositionAllocator::m_x))
+ MakeFpParamSpec (&RandomDiscPositionAllocator::m_x),
+ MakeFpChecker<double> ())
.AddParameter ("Y",
"The y coordinate of the center of the random position disc.",
FpValue (0.0),
- MakeFpParamSpec (&RandomDiscPositionAllocator::m_y));
+ MakeFpParamSpec (&RandomDiscPositionAllocator::m_y),
+ MakeFpChecker<double> ())
+ ;
return tid;
}
--- a/src/mobility/random-direction-2d-mobility-model.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/random-direction-2d-mobility-model.cc Mon Feb 18 00:18:45 2008 +0100
@@ -43,13 +43,17 @@
.AddConstructor<RandomDirection2dMobilityModel> ()
.AddParameter ("bounds", "The 2d bounding area",
Rectangle (-100, 100, -100, 100),
- MakeRectangleParamSpec (&RandomDirection2dMobilityModel::m_bounds))
+ MakeRectangleParamSpec (&RandomDirection2dMobilityModel::m_bounds),
+ MakeRectangleChecker ())
.AddParameter ("speed", "A random variable to control the speed (m/s).",
UniformVariable (1.0, 2.0),
- MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_speed))
+ MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_speed),
+ MakeRandomVariableChecker ())
.AddParameter ("pause", "A random variable to control the pause (s).",
ConstantVariable (2.0),
- MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_pause));
+ MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_pause),
+ MakeRandomVariableChecker ())
+ ;
return tid;
}
--- a/src/mobility/random-walk-2d-mobility-model.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/random-walk-2d-mobility-model.cc Mon Feb 18 00:18:45 2008 +0100
@@ -40,30 +40,35 @@
.AddParameter ("bounds",
"Bounds of the area to cruise.",
Rectangle (0.0, 0.0, 100.0, 100.0),
- MakeRectangleParamSpec (&RandomWalk2dMobilityModel::m_bounds))
+ MakeRectangleParamSpec (&RandomWalk2dMobilityModel::m_bounds),
+ MakeRectangleChecker ())
.AddParameter ("time",
"Change current direction and speed after moving for this delay.",
Seconds (1.0),
- MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime))
+ MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime),
+ MakeTimeChecker ())
.AddParameter ("distance",
"Change current direction and speed after moving for this distance.",
Seconds (1.0),
- MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime))
+ MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime),
+ MakeTimeChecker ())
.AddParameter ("mode",
"The mode indicates the condition used to "
"change the current speed and direction",
EnumValue (RandomWalk2dMobilityModel::MODE_DISTANCE),
- MakeEnumParamSpec (&RandomWalk2dMobilityModel::m_mode,
- RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance",
- RandomWalk2dMobilityModel::MODE_TIME, "Time"))
+ MakeEnumParamSpec (&RandomWalk2dMobilityModel::m_mode),
+ MakeEnumChecker (RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance",
+ RandomWalk2dMobilityModel::MODE_TIME, "Time"))
.AddParameter ("direction",
"A random variable used to pick the direction (gradients).",
UniformVariable (0.0, 6.283184),
- MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_direction))
+ MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_direction),
+ MakeRandomVariableChecker ())
.AddParameter ("speed",
"A random variable used to pick the speed (m/s).",
UniformVariable (2.0, 4.0),
- MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_speed));
+ MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_speed),
+ MakeRandomVariableChecker ());
return tid;
}
--- a/src/mobility/random-waypoint-mobility-model.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/mobility/random-waypoint-mobility-model.cc Mon Feb 18 00:18:45 2008 +0100
@@ -39,15 +39,18 @@
.AddParameter ("speed",
"A random variable used to pick the speed of a random waypoint model.",
UniformVariable (0.3, 0.7),
- MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_speed))
+ MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_speed),
+ MakeRandomVariableChecker ())
.AddParameter ("pause",
"A random variable used to pick the pause of a random waypoint model.",
ConstantVariable (2.0),
- MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_pause))
+ MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_pause),
+ MakeRandomVariableChecker ())
.AddParameter ("position",
"The position model used to pick a destination point.",
Ptr<PositionAllocator> (0),
- MakePtrParamSpec (&RandomWaypointMobilityModel::m_position));
+ MakePtrParamSpec (&RandomWaypointMobilityModel::m_position),
+ MakePtrChecker<PositionAllocator> ());
return tid;
}
--- a/src/node/drop-tail-queue.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/node/drop-tail-queue.cc Mon Feb 18 00:18:45 2008 +0100
@@ -34,7 +34,8 @@
.AddConstructor<DropTailQueue> ()
.AddParameter ("MaxPackets", "The maximum number of packets accepted by this DropTailQueue.",
UintValue (100),
- MakeUintParamSpec (&DropTailQueue::m_maxPackets))
+ MakeUintParamSpec (&DropTailQueue::m_maxPackets),
+ MakeUintChecker<uint32_t> ())
;
return tid;
--- a/src/simulator/nstime.h Sun Feb 17 04:38:52 2008 +0100
+++ b/src/simulator/nstime.h Mon Feb 18 00:18:45 2008 +0100
@@ -678,6 +678,9 @@
template <typename T1, typename T2>
Ptr<ParamSpec> MakeTimeParamSpec (T1 a1, T2 a2);
+Ptr<AttributeChecker> MakeTimeChecker (void);
+
+
} // namespace ns3
@@ -696,6 +699,7 @@
}
+
} // namespace ns3
#endif /* TIME_H */
--- a/src/simulator/time.cc Sun Feb 17 04:38:52 2008 +0100
+++ b/src/simulator/time.cc Mon Feb 18 00:18:45 2008 +0100
@@ -305,6 +305,11 @@
return ClassValueHelperConvertTo<Time,TimeValue> (this);
}
+Ptr<AttributeChecker> MakeTimeChecker (void)
+{
+ return MakeSimpleAttributeChecker<Time> ();
+}
+
Time MilliSeconds (uint64_t ms)
{
uint64_t ts = TimeUnit<1>::UnitsToTimestep(ms, TimeStepPrecision::MS_FACTOR);