From cf9ed2855f60217e961ea686d6ef22692c330dc1 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Sun, 17 Feb 2008 04:38:34 +0100 Subject: [PATCH] split initial value from ParamSpec. --- src/applications/onoff/onoff-application.cc | 2 +- src/core/boolean-value.h | 12 +- src/core/class-value-helper.h | 8 +- src/core/enum-value.cc | 7 - src/core/enum-value.h | 1 - src/core/fp-value.h | 20 +-- src/core/int-value.h | 24 ++-- src/core/object-vector.cc | 10 +- src/core/object-vector.h | 2 +- src/core/object.cc | 81 +++++++---- src/core/object.h | 12 +- src/core/param-spec-helper.h | 127 ++++++++---------- src/core/random-variable.h | 16 +-- src/core/uint-value.h | 24 ++-- src/core/value-helper.h | 10 +- src/core/value-test.cc | 33 +++-- src/core/value.h | 4 - .../point-to-point-net-device.cc | 2 +- src/mobility/hierarchical-mobility-model.cc | 2 + src/mobility/mobility-model.cc | 9 +- src/mobility/position-allocator.cc | 38 +++--- .../random-direction-2d-mobility-model.cc | 12 +- src/mobility/random-walk-2d-mobility-model.cc | 21 +-- .../random-waypoint-mobility-model.cc | 9 +- src/node/drop-tail-queue.cc | 40 +++--- src/simulator/nstime.h | 16 +-- 26 files changed, 269 insertions(+), 273 deletions(-) diff --git a/src/applications/onoff/onoff-application.cc b/src/applications/onoff/onoff-application.cc index d6adf0231..04a2ea336 100644 --- a/src/applications/onoff/onoff-application.cc +++ b/src/applications/onoff/onoff-application.cc @@ -45,7 +45,7 @@ namespace ns3 { // Defaults for rate/size static DataRateDefaultValue g_defaultRate ("OnOffApplicationDataRate", "The data rate in on state for OnOffApplication", - DataRate ("500kb/s")); + MakeDataRate ("500kb/s")); static NumericDefaultValue g_defaultSize ("OnOffApplicationPacketSize", "The size of packets sent in on state for OnOffApplication", 512, 1); diff --git a/src/core/boolean-value.h b/src/core/boolean-value.h index d4054fa2d..0c3962d62 100644 --- a/src/core/boolean-value.h +++ b/src/core/boolean-value.h @@ -28,10 +28,10 @@ class BooleanParamSpec : public ParamSpec {}; template -Ptr MakeBooleanParamSpec (T1 a1, bool initialValue); +Ptr MakeBooleanParamSpec (T1 a1); template -Ptr MakeBooleanParamSpec (T1 a1, T2 a2, bool initialValue); +Ptr MakeBooleanParamSpec (T1 a1, T2 a2); } // namespace ns3 @@ -40,15 +40,15 @@ Ptr MakeBooleanParamSpec (T1 a1, T2 a2, bool initialValue); namespace ns3 { template -Ptr MakeBooleanParamSpec (T1 a1, bool initialValue) +Ptr MakeBooleanParamSpec (T1 a1) { - return MakeParamSpecHelper (a1, BooleanValue (initialValue)); + return MakeParamSpecHelper (a1); } template -Ptr MakeBooleanParamSpec (T1 a1, T2 a2, bool initialValue) +Ptr MakeBooleanParamSpec (T1 a1, T2 a2) { - return MakeParamSpecHelper (a1, a2, BooleanValue (initialValue)); + return MakeParamSpecHelper (a1, a2); } diff --git a/src/core/class-value-helper.h b/src/core/class-value-helper.h index 3ad76e81e..bbf9295b4 100644 --- a/src/core/class-value-helper.h +++ b/src/core/class-value-helper.h @@ -78,17 +78,17 @@ ClassValueHelperConvertTo (const T *self) template Ptr -MakeClassValueHelperParamSpec (T1 a1, const T &initialValue) +MakeClassValueHelperParamSpec (T1 a1) { - return MakeParamSpecHelper (a1, ClassValue (initialValue)); + return MakeParamSpecHelper > (a1); } template Ptr -MakeClassValueHelperParamSpec (T1 a1, T2 a2, const T &initialValue) +MakeClassValueHelperParamSpec (T1 a1, T2 a2) { - return MakeParamSpecHelper (a1, a2, ClassValue (initialValue)); + return MakeParamSpecHelper > (a1, a2); } } // namespace ns3 diff --git a/src/core/enum-value.cc b/src/core/enum-value.cc index 1701b2d4d..f4959da38 100644 --- a/src/core/enum-value.cc +++ b/src/core/enum-value.cc @@ -127,11 +127,4 @@ EnumParamSpec::Check (PValue value) const return false; } -PValue -EnumParamSpec::GetInitialValue (void) const -{ - NS_ASSERT (!m_valueSet.empty ()); - return PValue::Create (m_valueSet.front ().first); -} - } // namespace ns3 diff --git a/src/core/enum-value.h b/src/core/enum-value.h index af3b5ccee..98ed30d2d 100644 --- a/src/core/enum-value.h +++ b/src/core/enum-value.h @@ -36,7 +36,6 @@ public: virtual bool Get (const ObjectBase* object, PValue value) const; virtual bool Check (PValue value) const; - virtual PValue GetInitialValue (void) const; private: virtual bool DoSet (ObjectBase *object, const EnumValue *value) const = 0; virtual bool DoGet (const ObjectBase *object, EnumValue *value) const = 0; diff --git a/src/core/fp-value.h b/src/core/fp-value.h index d733b06b9..8bcd89b53 100644 --- a/src/core/fp-value.h +++ b/src/core/fp-value.h @@ -28,11 +28,9 @@ private: class FpParamSpec : public ParamSpec {}; template -Ptr MakeFpParamSpec (T1 a1, - double initialValue); +Ptr MakeFpParamSpec (T1 a1); template Ptr MakeFpParamSpec (T1 a1, T2 a2, - double initialValue, double minValue, double maxValue); @@ -68,36 +66,32 @@ private: template Ptr -MakeFpParamSpec (T1 a1, - double initialValue) +MakeFpParamSpec (T1 a1) { - return MakeParamSpecHelperWithChecker (a1, FpValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, FpValueChecker::Create (a1)); } template Ptr MakeFpParamSpec (T1 a1, - double initialValue, double minValue, double maxValue) { - return MakeParamSpecHelperWithChecker (a1, FpValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, FpValueChecker (minValue, maxValue)); } template -Ptr MakeFpParamSpec (T1 a1, T2 a2, - double initialValue) +Ptr MakeFpParamSpec (T1 a1, T2 a2) { - return MakeParamSpecHelperWithChecker (a1, a2, FpValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, FpValueChecker::Create (a1)); } template Ptr MakeFpParamSpec (T1 a1, T2 a2, - double initialValue, double minValue, double maxValue) { - return MakeParamSpecHelperWithChecker (a1, a2, FpValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, FpValueChecker (minValue, maxValue)); } diff --git a/src/core/int-value.h b/src/core/int-value.h index 2281336e0..d9c3de429 100644 --- a/src/core/int-value.h +++ b/src/core/int-value.h @@ -27,19 +27,15 @@ private: class IntParamSpec : public ParamSpec {}; template -Ptr MakeIntParamSpec (T1 a1, - int64_t initialValue); +Ptr MakeIntParamSpec (T1 a1); template Ptr MakeIntParamSpec (T1 a1, - int64_t initialValue, int64_t minValue, int64_t maxValue); template -Ptr MakeIntParamSpec (T1 a1, T2 a2, - int64_t initialValue); +Ptr MakeIntParamSpec (T1 a1, T2 a2); template Ptr MakeIntParamSpec (T1 a1, T2 a2, - int64_t initialValue, int64_t minValue, int64_t maxValue); @@ -75,36 +71,32 @@ private: template Ptr -MakeIntParamSpec (T1 a1, - int64_t initialValue) +MakeIntParamSpec (T1 a1) { - return MakeParamSpecHelperWithChecker (a1, IntValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, IntValueChecker::Create (a1)); } template Ptr MakeIntParamSpec (T1 a1, - int64_t initialValue, int64_t minValue, int64_t maxValue) { - return MakeParamSpecHelperWithChecker (a1, IntValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, IntValueChecker (minValue, maxValue)); } template -Ptr MakeIntParamSpec (T1 a1, T2 a2, - int64_t initialValue) +Ptr MakeIntParamSpec (T1 a1, T2 a2) { - return MakeParamSpecHelperWithChecker (a1, a2, IntValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, IntValueChecker::Create (a1)); } template Ptr MakeIntParamSpec (T1 a1, T2 a2, - int64_t initialValue, int64_t minValue, int64_t maxValue) { - return MakeParamSpecHelperWithChecker (a1, a2, IntValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, IntValueChecker (minValue, maxValue)); } diff --git a/src/core/object-vector.cc b/src/core/object-vector.cc index 9280439a0..0137136be 100644 --- a/src/core/object-vector.cc +++ b/src/core/object-vector.cc @@ -36,6 +36,11 @@ ObjectVector::ObjectVector (PValue value) *this = v->Get (); } +ObjectVector::operator PValue () const +{ + return PValue::Create (); +} + ObjectVectorValue::ObjectVectorValue () : m_vector () {} @@ -102,10 +107,5 @@ ObjectVectorParamSpec::Check (PValue value) const const ObjectVectorValue *v = value.DynCast (); return v != 0; } -PValue -ObjectVectorParamSpec::GetInitialValue (void) const -{ - return PValue::Create (); -} } // name diff --git a/src/core/object-vector.h b/src/core/object-vector.h index d7e258f40..b204b6fe4 100644 --- a/src/core/object-vector.h +++ b/src/core/object-vector.h @@ -21,6 +21,7 @@ public: Ptr Get (uint32_t i) const; ObjectVector (PValue value); + operator PValue () const; private: friend class ObjectVectorParamSpec; std::vector > m_objects; @@ -68,7 +69,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; - virtual PValue GetInitialValue (void) const; private: virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0; virtual Ptr DoGet (const ObjectBase *object, uint32_t i) const = 0; diff --git a/src/core/object.cc b/src/core/object.cc index 63e447da4..2722c2a4e 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -61,11 +61,12 @@ public: std::string name, std::string help, uint32_t flags, + ns3::PValue initialValue, ns3::Ptr spec); 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; - uint32_t GetParameterUid (uint16_t uid, uint32_t i) const; + ns3::PValue GetParameterInitialValue (uint16_t uid, uint32_t i) const; ns3::Ptr GetParameterParamSpec (uint16_t uid, uint32_t i) const; private: struct ConstructorInformation { @@ -76,7 +77,7 @@ private: std::string name; std::string help; uint32_t flags; - uint32_t uid; + ns3::PValue initialValue; ns3::Ptr param; }; struct IidInformation { @@ -246,6 +247,7 @@ IidManager::AddParameter (uint16_t uid, std::string name, std::string help, uint32_t flags, + ns3::PValue initialValue, ns3::Ptr spec) { struct IidInformation *information = LookupInformation (uid); @@ -262,6 +264,7 @@ IidManager::AddParameter (uint16_t uid, param.name = name; param.help = help; param.flags = flags; + param.initialValue = initialValue; param.param = spec; information->parameters.push_back (param); } @@ -287,6 +290,13 @@ IidManager::GetParameterFlags (uint16_t uid, uint32_t i) const NS_ASSERT (i < information->parameters.size ()); return information->parameters[i].flags; } +ns3::PValue +IidManager::GetParameterInitialValue (uint16_t uid, uint32_t i) const +{ + struct IidInformation *information = LookupInformation (uid); + NS_ASSERT (i < information->parameters.size ()); + return information->parameters[i].initialValue; +} ns3::Ptr IidManager::GetParameterParamSpec (uint16_t uid, uint32_t i) const { @@ -295,7 +305,6 @@ IidManager::GetParameterParamSpec (uint16_t uid, uint32_t i) const return information->parameters[i].param; } - } // anonymous namespace /********************************************************************* @@ -431,6 +440,7 @@ TypeId::LookupParameterByName (std::string name, struct TypeId::ParameterInfo *i { info->spec = GetParameterParamSpec (i); info->flags = GetParameterFlags (i); + info->initialValue = tid.GetParameterInitialValue (i); return true; } } @@ -452,6 +462,7 @@ TypeId::LookupParameterByPosition (uint32_t i, struct TypeId::ParameterInfo *inf { info->spec = tid.GetParameterParamSpec (j); info->flags = tid.GetParameterFlags (j); + info->initialValue = tid.GetParameterInitialValue (j); return true; } cur++; @@ -522,9 +533,10 @@ TypeId::DoAddConstructor (CallbackBase cb, uint32_t nArguments) TypeId TypeId::AddParameter (std::string name, std::string help, + PValue initialValue, Ptr param) { - Singleton::Get ()->AddParameter (m_tid, name, help, PARAM_SGC, param); + Singleton::Get ()->AddParameter (m_tid, name, help, PARAM_SGC, initialValue, param); return *this; } @@ -532,9 +544,10 @@ TypeId TypeId::AddParameter (std::string name, std::string help, uint32_t flags, + PValue initialValue, Ptr param) { - Singleton::Get ()->AddParameter (m_tid, name, help, flags, param); + Singleton::Get ()->AddParameter (m_tid, name, help, flags, initialValue, param); return *this; } @@ -578,6 +591,12 @@ TypeId::GetParameterFullName (uint32_t i) const { return GetName () + "::" + GetParameterName (i); } +PValue +TypeId::GetParameterInitialValue (uint32_t i) const +{ + PValue value = Singleton::Get ()->GetParameterInitialValue (m_tid, i); + return value; +} Ptr TypeId::GetParameterParamSpec (uint32_t i) const { @@ -644,7 +663,7 @@ Parameters::Set (std::string name, PValue value) { struct TypeId::ParameterInfo info; TypeId::LookupParameterByFullName (name, &info); - bool ok = DoSet (info.spec, value); + bool ok = DoSet (&info, value); return ok; } void @@ -652,14 +671,14 @@ Parameters::SetWithTid (TypeId tid, std::string name, PValue value) { struct TypeId::ParameterInfo info; tid.LookupParameterByName (name, &info); - DoSet (info.spec, value); + DoSet (&info, value); } void Parameters::SetWithTid (TypeId tid, uint32_t position, PValue value) { struct TypeId::ParameterInfo info; tid.LookupParameterByPosition (position, &info); - DoSet (info.spec, value); + DoSet (&info, value); } void @@ -682,32 +701,36 @@ Parameters::DoSetOne (Ptr spec, PValue value) m_parameters.push_back (p); } bool -Parameters::DoSet (Ptr spec, PValue value) +Parameters::DoSet (struct TypeId::ParameterInfo *info, PValue value) { - if (spec == 0) + if (info->spec == 0) { return false; } - bool ok = spec->Check (value); + bool ok = info->spec->Check (value); if (!ok) { // attempt to convert to string. - std::string str = value.SerializeToString (0); + const StringValue *str = value.DynCast (); + if (str == 0) + { + return false; + } // attempt to convert back to value. - PValue v = spec->GetInitialValue ().Copy (); - ok = v.DeserializeFromString (str, spec); + PValue v = info->initialValue.Copy (); + ok = v.DeserializeFromString (str->Get (), info->spec); if (!ok) { return false; } - ok = spec->Check (v); + ok = info->spec->Check (v); if (!ok) { return false; } value = v; } - DoSetOne (spec, value); + DoSetOne (info->spec, value); return true; } void @@ -792,7 +815,7 @@ Parameters::DeserializeFromString (std::string str) value = str.substr (equal+1, next - (equal+1)); cur++; } - PValue val = info.spec->GetInitialValue ().Copy (); + PValue val = info.initialValue.Copy (); bool ok = val.DeserializeFromString (value, info.spec); if (!ok) { @@ -855,6 +878,7 @@ Object::Construct (const Parameters ¶meters) for (uint32_t i = 0; i < tid.GetParametersN (); i++) { Ptr paramSpec = tid.GetParameterParamSpec (i); + PValue initial = tid.GetParameterInitialValue (i); NS_LOG_DEBUG ("try to construct \""<< tid.GetName ()<<"::"<< tid.GetParameterName (i)<<"\""); if (!(tid.GetParameterFlags (i) & TypeId::PARAM_CONSTRUCT)) @@ -869,7 +893,7 @@ Object::Construct (const Parameters ¶meters) if (j->spec == paramSpec) { // We have a matching parameter value. - DoSet (paramSpec, j->value); + DoSet (paramSpec, initial, j->value); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< tid.GetParameterName (i)<<"\""); found = true; @@ -885,7 +909,7 @@ Object::Construct (const Parameters ¶meters) if (j->spec == paramSpec) { // We have a matching parameter value. - DoSet (paramSpec, j->value); + DoSet (paramSpec, initial, j->value); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< tid.GetParameterName (i)<<"\" from global"); found = true; @@ -896,7 +920,6 @@ Object::Construct (const Parameters ¶meters) if (!found) { // No matching parameter value so we set the default value. - PValue initial = paramSpec->GetInitialValue (); paramSpec->Set (this, initial); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< tid.GetParameterName (i)<<"\" from local"); @@ -907,16 +930,20 @@ Object::Construct (const Parameters ¶meters) NotifyConstructionCompleted (); } bool -Object::DoSet (Ptr spec, PValue value) +Object::DoSet (Ptr spec, PValue initialValue, PValue value) { bool ok = spec->Check (value); if (!ok) { // attempt to convert to string - std::string str = value.SerializeToString (0); + const StringValue *str = value.DynCast (); + if (str == 0) + { + return false; + } // attempt to convert back from string. - PValue v = spec->GetInitialValue ().Copy (); - ok = v.DeserializeFromString (str, spec); + PValue v = initialValue.Copy (); + ok = v.DeserializeFromString (str->Get (), spec); if (!ok) { return false; @@ -943,7 +970,7 @@ Object::Set (std::string name, PValue value) { return false; } - return DoSet (info.spec, value); + return DoSet (info.spec, info.initialValue, value); } bool Object::SetUint (std::string name, uint64_t value) @@ -978,7 +1005,7 @@ Object::Get (std::string name, std::string &value) const { return false; } - PValue v = info.spec->GetInitialValue ().Copy (); + PValue v = info.initialValue.Copy (); bool ok = info.spec->Get (this, v); if (ok) { @@ -999,7 +1026,7 @@ Object::Get (std::string name) const { return PValue (); } - PValue value = info.spec->GetInitialValue ().Copy (); + PValue value = info.initialValue.Copy (); bool ok = info.spec->Get (this, value); if (!ok) { diff --git a/src/core/object.h b/src/core/object.h index 8b8c2fb7c..af9b58607 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -141,6 +141,8 @@ public: */ std::string GetParameterFullName (uint32_t i) const; + PValue GetParameterInitialValue (uint32_t i) const; + Ptr CreateObject (const Parameters ¶meters) const; @@ -209,7 +211,9 @@ public: * Record in this TypeId the fact that a new parameter exists. */ TypeId AddParameter (std::string name, - std::string help, Ptr spec); + std::string help, + PValue initialValue, + Ptr spec); /** * \param name the name of the new parameter @@ -224,6 +228,7 @@ public: TypeId AddParameter (std::string name, std::string help, uint32_t flags, + PValue initialValue, Ptr spec); // construct an invalid TypeId. @@ -237,6 +242,7 @@ private: struct ParameterInfo { Ptr spec; + PValue initialValue; uint32_t flags; }; @@ -323,7 +329,7 @@ private: - bool DoSet (Ptr spec, PValue param); + bool DoSet (struct TypeId::ParameterInfo *info, PValue param); void DoSetOne (Ptr spec, PValue param); std::string LookupParameterFullNameByParamSpec (Ptr spec) const; @@ -474,7 +480,7 @@ private: friend Ptr CreateObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); - bool DoSet (Ptr spec, PValue value); + bool DoSet (Ptr spec, PValue intialValue, PValue value); Ptr DoGetObject (TypeId tid) const; void DoCollectSources (std::string path, const TraceContext &context, TraceResolver::SourceCollection *collection) const; diff --git a/src/core/param-spec-helper.h b/src/core/param-spec-helper.h index 31730eecf..edb76856d 100644 --- a/src/core/param-spec-helper.h +++ b/src/core/param-spec-helper.h @@ -3,21 +3,21 @@ namespace ns3 { -template +template Ptr -MakeParamSpecHelper (T1 a1, V initialValue); +MakeParamSpecHelper (T1 a1); -template +template Ptr -MakeParamSpecHelper (T1 a1, T2 a2, V initialValue); +MakeParamSpecHelper (T1 a1, T2 a2); -template +template Ptr -MakeParamSpecHelperWithChecker (T1 a1, V initialValue, CHECKER checker); +MakeParamSpecHelperWithChecker (T1 a1, CHECKER checker); -template +template Ptr -MakeParamSpecHelperWithChecker (T1 a1, T2 a2, V initialValue, CHECKER checker); +MakeParamSpecHelperWithChecker (T1 a1, T2 a2, CHECKER checker); } // namespace ns3 @@ -33,9 +33,8 @@ template class ParamSpecHelper : public BASE { public: - ParamSpecHelper (PValue initialValue, CHECKER checker) - : m_initialValue (initialValue), - m_checker (checker) {} + ParamSpecHelper (CHECKER checker) + : m_checker (checker) {} virtual bool Set (ObjectBase * object, PValue val) const { const U *value = val.DynCast (); @@ -74,14 +73,10 @@ public: return m_checker.Check (val->Get ()); } - virtual PValue GetInitialValue (void) const { - return m_initialValue; - } private: virtual bool DoSet (T *object, const U *v) const = 0; virtual bool DoGet (const T *object, U *v) const = 0; - PValue m_initialValue; CHECKER m_checker; }; @@ -92,15 +87,15 @@ public: bool Check (const T &value) const {return true;} }; -template +template Ptr -DoMakeParamSpecHelperOne (U T::*memberVariable, V initialValue, CHECKER checker) +DoMakeParamSpecHelperOne (U T::*memberVariable, CHECKER checker) { class MemberVariable : public ParamSpecHelper { public: - MemberVariable (U T::*memberVariable, V initialValue, CHECKER checker) - : ParamSpecHelper (initialValue, checker), + MemberVariable (U T::*memberVariable, CHECKER checker) + : ParamSpecHelper (checker), m_memberVariable (memberVariable) {} private: @@ -115,27 +110,27 @@ DoMakeParamSpecHelperOne (U T::*memberVariable, V initialValue, CHECKER checker) U T::*m_memberVariable; }; - return Ptr (new MemberVariable (memberVariable, initialValue, checker), false); + return Ptr (new MemberVariable (memberVariable, checker), false); } -template +template Ptr -DoMakeParamSpecHelperOne (U T::*memberVariable, V initialValue) +DoMakeParamSpecHelperOne (U T::*memberVariable) { - return DoMakeParamSpecHelperOne (memberVariable, initialValue, ParamSpecHelperSimpleChecker ()); + return DoMakeParamSpecHelperOne (memberVariable, ParamSpecHelperSimpleChecker ()); } -template +template Ptr DoMakeParamSpecHelperOne (U (T::*getter) (void) const, - V initialValue, CHECKER checker) + CHECKER checker) { class MemberMethod : public ParamSpecHelper { public: MemberMethod (U (T::*getter) (void) const, - V initialValue, CHECKER checker) - : ParamSpecHelper (initialValue, checker), + CHECKER checker) + : ParamSpecHelper (checker), m_getter (getter) {} private: @@ -148,30 +143,29 @@ DoMakeParamSpecHelperOne (U (T::*getter) (void) const, } U (T::*m_getter) (void) const; }; - return Ptr (new MemberMethod (getter, initialValue, checker), false); + return Ptr (new MemberMethod (getter, checker), false); } -template +template Ptr -DoMakeParamSpecHelperOne (U (T::*getter) (void) const, - V initialValue) +DoMakeParamSpecHelperOne (U (T::*getter) (void) const) { - return DoMakeParamSpecHelperOne (getter, initialValue, ParamSpecHelperSimpleChecker ()); + return DoMakeParamSpecHelperOne (getter, ParamSpecHelperSimpleChecker ()); } -template +template Ptr DoMakeParamSpecHelperOne (void (T::*setter) (U), - V initialValue, CHECKER checker) + CHECKER checker) { class MemberMethod : public ParamSpecHelper { public: MemberMethod (void (T::*setter) (U), - V initialValue, CHECKER checker) - : ParamSpecHelper (initialValue, checker), + CHECKER checker) + : ParamSpecHelper (checker), m_setter (setter) {} private: @@ -184,24 +178,22 @@ DoMakeParamSpecHelperOne (void (T::*setter) (U), } void (T::*m_setter) (U); }; - return Ptr (new MemberMethod (setter, initialValue, checker), false); + return Ptr (new MemberMethod (setter, checker), false); } -template +template Ptr -DoMakeParamSpecHelperOne (void (T::*setter) (U), - V initialValue) +DoMakeParamSpecHelperOne (void (T::*setter) (U)) { - return DoMakeParamSpecHelperOne (setter, initialValue, + return DoMakeParamSpecHelperOne (setter, ParamSpecHelperSimpleChecker::ReferencedType> ()); } -template +template Ptr DoMakeParamSpecHelperTwo (void (T::*setter) (U), V (T::*getter) (void) const, - W initialValue, CHECKER checker = ParamSpecHelperSimpleChecker ()) { class MemberMethod : public ParamSpecHelper @@ -209,8 +201,8 @@ DoMakeParamSpecHelperTwo (void (T::*setter) (U), public: MemberMethod (void (T::*setter) (U), V (T::*getter) (void) const, - W initialValue, CHECKER checker) - : ParamSpecHelper (initialValue, checker), + CHECKER checker) + : ParamSpecHelper (checker), m_setter (setter), m_getter (getter) {} @@ -226,63 +218,60 @@ DoMakeParamSpecHelperTwo (void (T::*setter) (U), void (T::*m_setter) (U); V (T::*m_getter) (void) const; }; - return Ptr (new MemberMethod (setter, getter, initialValue, checker), false); + return Ptr (new MemberMethod (setter, getter, checker), false); } -template +template Ptr DoMakeParamSpecHelperTwo (void (T::*setter) (U), - V (T::*getter) (void) const, - W initialValue) + V (T::*getter) (void) const) { - return DoMakeParamSpecHelperTwo (setter, getter, initialValue, ParamSpecHelperSimpleChecker ()); + return DoMakeParamSpecHelperTwo (setter, getter, ParamSpecHelperSimpleChecker ()); } -template +template Ptr DoMakeParamSpecHelperTwo (V (T::*getter) (void) const, void (T::*setter) (U), - W initialValue, CHECKER checker) { - return DoMakeParamSpecHelperTwo (setter, getter, initialValue, checker); + return DoMakeParamSpecHelperTwo (setter, getter, checker); } -template +template Ptr DoMakeParamSpecHelperTwo (V (T::*getter) (void) const, - void (T::*setter) (U), - W initialValue) + void (T::*setter) (U)) { - return DoMakeParamSpecHelperTwo (setter, getter, initialValue); + return DoMakeParamSpecHelperTwo (setter, getter); } -template +template Ptr -MakeParamSpecHelper (T1 a1, V initialValue) +MakeParamSpecHelper (T1 a1) { - return DoMakeParamSpecHelperOne (a1, initialValue); + return DoMakeParamSpecHelperOne (a1); } -template +template Ptr -MakeParamSpecHelper (T1 a1, T2 a2, V initialValue) +MakeParamSpecHelper (T1 a1, T2 a2) { - return DoMakeParamSpecHelperTwo (a1, a2, initialValue); + return DoMakeParamSpecHelperTwo (a1, a2); } -template +template Ptr -MakeParamSpecHelperWithChecker (T1 a1, V initialValue, CHECKER checker) +MakeParamSpecHelperWithChecker (T1 a1, CHECKER checker) { - return DoMakeParamSpecHelperOne (a1, initialValue, checker); + return DoMakeParamSpecHelperOne (a1, checker); } -template +template Ptr -MakeParamSpecHelperWithChecker (T1 a1, T2 a2, V initialValue, CHECKER checker) +MakeParamSpecHelperWithChecker (T1 a1, T2 a2, CHECKER checker) { - return DoMakeParamSpecHelperTwo (a1, a2, initialValue, checker); + return DoMakeParamSpecHelperTwo (a1, a2, checker); } } // namespace ns3 diff --git a/src/core/random-variable.h b/src/core/random-variable.h index e251f0a74..d5bc96002 100644 --- a/src/core/random-variable.h +++ b/src/core/random-variable.h @@ -669,11 +669,9 @@ class RandomVariableValue : public Value {}; class RandomVariableParamSpec : public ParamSpec {}; template -Ptr MakeRandomVariableParamSpec (T1 a1, - RandomVariable initialValue); +Ptr MakeRandomVariableParamSpec (T1 a1); template -Ptr MakeRandomVariableParamSpec (T1 a1, T2 a2, - RandomVariable initialValue); +Ptr MakeRandomVariableParamSpec (T1 a1, T2 a2); }//namespace ns3 @@ -682,19 +680,17 @@ Ptr MakeRandomVariableParamSpec (T1 a1, T2 a2, namespace ns3 { template -Ptr MakeRandomVariableParamSpec (T1 a1, - RandomVariable initialValue) +Ptr MakeRandomVariableParamSpec (T1 a1) { return MakeClassValueHelperParamSpec (a1, initialValue); + RandomVariableValue, RandomVariableParamSpec> (a1); } template -Ptr MakeRandomVariableParamSpec (T1 a1, T2 a2, - RandomVariable initialValue) +Ptr MakeRandomVariableParamSpec (T1 a1, T2 a2) { return MakeClassValueHelperParamSpec (a1, a2, initialValue); + RandomVariableValue,RandomVariableParamSpec> (a1, a2); } diff --git a/src/core/uint-value.h b/src/core/uint-value.h index 21ffad5dc..46426bffa 100644 --- a/src/core/uint-value.h +++ b/src/core/uint-value.h @@ -27,19 +27,15 @@ private: class UintParamSpec : public ParamSpec {}; template -Ptr MakeUintParamSpec (T1 a1, - uint64_t initialValue); +Ptr MakeUintParamSpec (T1 a1); template Ptr MakeUintParamSpec (T1 a1, - uint64_t initialValue, uint64_t minValue, uint64_t maxValue); template -Ptr MakeUintParamSpec (T1 a1, T2 a2, - uint64_t initialValue); +Ptr MakeUintParamSpec (T1 a1, T2 a2); template Ptr MakeUintParamSpec (T1 a1, T2 a2, - uint64_t initialValue, uint64_t minValue, uint64_t maxValue); @@ -75,36 +71,32 @@ private: template Ptr -MakeUintParamSpec (T1 a1, - uint64_t initialValue) +MakeUintParamSpec (T1 a1) { - return MakeParamSpecHelperWithChecker (a1, UintValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, UintValueChecker::Create (a1)); } template Ptr MakeUintParamSpec (T1 a1, - uint64_t initialValue, uint64_t minValue, uint64_t maxValue) { - return MakeParamSpecHelperWithChecker (a1, UintValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, UintValueChecker (minValue, maxValue)); } template -Ptr MakeUintParamSpec (T1 a1, T2 a2, - uint64_t initialValue) +Ptr MakeUintParamSpec (T1 a1, T2 a2) { - return MakeParamSpecHelperWithChecker (a1, a2, UintValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, UintValueChecker::Create (a1)); } template Ptr MakeUintParamSpec (T1 a1, T2 a2, - uint64_t initialValue, uint64_t minValue, uint64_t maxValue) { - return MakeParamSpecHelperWithChecker (a1, a2, UintValue (initialValue), + return MakeParamSpecHelperWithChecker (a1, a2, UintValueChecker (minValue, maxValue)); } diff --git a/src/core/value-helper.h b/src/core/value-helper.h index f53fb95ce..91850c453 100644 --- a/src/core/value-helper.h +++ b/src/core/value-helper.h @@ -11,18 +11,16 @@ class type##Value : public Value {}; \ class type##ParamSpec : public ParamSpec {}; \ template \ - Ptr Make##type##ParamSpec (T1 a1, \ - type initialValue) \ + Ptr Make##type##ParamSpec (T1 a1) \ { \ return MakeClassValueHelperParamSpec< type , \ - type##Value, type##ParamSpec> (a1, initialValue); \ + type##Value, type##ParamSpec> (a1); \ } \ template \ - Ptr Make##type##ParamSpec (T1 a1, T2 a2, \ - type initialValue) \ + Ptr Make##type##ParamSpec (T1 a1, T2 a2) \ { \ return MakeClassValueHelperParamSpec (a1, a2, initialValue); \ + type##Value,type##ParamSpec> (a1, a2); \ } #define VALUE_HELPER_CPP(type) \ diff --git a/src/core/value-test.cc b/src/core/value-test.cc index aab20b899..34f7cabe2 100644 --- a/src/core/value-test.cc +++ b/src/core/value-test.cc @@ -42,39 +42,46 @@ public: static TypeId tid = TypeId ("ParamSpecObjectTest") .SetParent () .AddParameter ("TestBoolName", "help text", - MakeBooleanParamSpec (&ParamSpecObjectTest::m_boolTest, false)) + BooleanValue (false), + MakeBooleanParamSpec (&ParamSpecObjectTest::m_boolTest)) .AddParameter ("TestBoolA", "help text", + BooleanValue (false), MakeBooleanParamSpec (&ParamSpecObjectTest::DoSetTestB, - &ParamSpecObjectTest::DoGetTestB, - false)) + &ParamSpecObjectTest::DoGetTestB)) .AddParameter ("TestPtr", "help text", + Ptr (0), MakePtrParamSpec (&ParamSpecObjectTest::m_derived)) .AddParameter ("TestInt16", "help text", - MakeIntParamSpec (&ParamSpecObjectTest::m_int16, - -2)) + IntValue (-2), + MakeIntParamSpec (&ParamSpecObjectTest::m_int16)) .AddParameter ("TestInt16WithBounds", "help text", + IntValue (-2), MakeIntParamSpec (&ParamSpecObjectTest::m_int16WithBounds, - -2, -5, 10)) + -5, 10)) .AddParameter ("TestInt16SetGet", "help text", + IntValue (6), MakeIntParamSpec (&ParamSpecObjectTest::DoSetInt16, - &ParamSpecObjectTest::DoGetInt16, - 6)) + &ParamSpecObjectTest::DoGetInt16)) .AddParameter ("TestUint8", "help text", - MakeUintParamSpec (&ParamSpecObjectTest::m_uint8, - 1)) + UintValue (1), + MakeUintParamSpec (&ParamSpecObjectTest::m_uint8)) .AddParameter ("TestEnum", "help text", + EnumValue (TEST_A), MakeEnumParamSpec (&ParamSpecObjectTest::m_enum, TEST_A, "TestA", TEST_B, "TestB", TEST_C, "TestC")) .AddParameter ("TestRandom", "help text", - MakeRandomVariableParamSpec (&ParamSpecObjectTest::m_random, - ConstantVariable (1.0))) + ConstantVariable (1.0), + MakeRandomVariableParamSpec (&ParamSpecObjectTest::m_random)) .AddParameter ("TestFloat", "help text", - MakeFpParamSpec (&ParamSpecObjectTest::m_float, -1.1)) + FpValue (-1.1), + MakeFpParamSpec (&ParamSpecObjectTest::m_float)) .AddParameter ("TestVector1", "help text", + ObjectVector (), MakeObjectVectorParamSpec (&ParamSpecObjectTest::m_vector1)) .AddParameter ("TestVector2", "help text", + ObjectVector (), MakeObjectVectorParamSpec (&ParamSpecObjectTest::DoGetVectorN, &ParamSpecObjectTest::DoGetVector)) ; diff --git a/src/core/value.h b/src/core/value.h index 38754ff70..87e33de70 100644 --- a/src/core/value.h +++ b/src/core/value.h @@ -76,7 +76,6 @@ public: virtual bool Set (ObjectBase * object, PValue value) const = 0; virtual bool Get (const ObjectBase * object, PValue value) const = 0; virtual bool Check (PValue value) const = 0; - virtual PValue GetInitialValue (void) const = 0; private: mutable uint32_t m_count; }; @@ -271,9 +270,6 @@ public: } return true; } - virtual PValue GetInitialValue (void) const { - return PValue::Create > (Ptr (0)); - } private: virtual void DoSet (T *object, Ptr value) const = 0; virtual Ptr DoGet (const T *object) const = 0; diff --git a/src/devices/point-to-point/point-to-point-net-device.cc b/src/devices/point-to-point/point-to-point-net-device.cc index 5fafd7eeb..c93f0cd15 100644 --- a/src/devices/point-to-point/point-to-point-net-device.cc +++ b/src/devices/point-to-point/point-to-point-net-device.cc @@ -37,7 +37,7 @@ namespace ns3 { DataRateDefaultValue PointToPointNetDevice::g_defaultRate( "PointToPointLinkDataRate", "The default data rate for point to point links", - DataRate ("10Mb/s")); + MakeDataRate ("10Mb/s")); PointToPointTraceType::PointToPointTraceType (enum Type type) : m_type (type) diff --git a/src/mobility/hierarchical-mobility-model.cc b/src/mobility/hierarchical-mobility-model.cc index bc4cda238..73151c1f4 100644 --- a/src/mobility/hierarchical-mobility-model.cc +++ b/src/mobility/hierarchical-mobility-model.cc @@ -31,8 +31,10 @@ HierarchicalMobilityModel::GetTypeId (void) .SetParent () .AddConstructor () .AddParameter ("child", "The child mobility model.", + Ptr (0), MakePtrParamSpec (&HierarchicalMobilityModel::SetChild)) .AddParameter ("parent", "The parent mobility model.", + Ptr (0), MakePtrParamSpec (&HierarchicalMobilityModel::SetParent)) ; return tid; diff --git a/src/mobility/mobility-model.cc b/src/mobility/mobility-model.cc index 33d82f717..941cfdc63 100644 --- a/src/mobility/mobility-model.cc +++ b/src/mobility/mobility-model.cc @@ -30,14 +30,13 @@ MobilityModel::GetTypeId (void) .SetParent () .AddParameter ("position", "The current position of the mobility model.", TypeId::PARAM_SGC, + Vector (0.0, 0.0, 0.0), MakeVectorParamSpec (&MobilityModel::SetPosition, - &MobilityModel::GetPosition, - Vector (0.0, 0.0, 0.0))) + &MobilityModel::GetPosition)) .AddParameter ("velocity", "The current velocity of the mobility model.", TypeId::PARAM_GET, - MakeVectorParamSpec (&MobilityModel::GetVelocity, - Vector (0.0, 0.0, 0.0) // ignored initial value. - )) + Vector (0.0, 0.0, 0.0), // ignored initial value. + MakeVectorParamSpec (&MobilityModel::GetVelocity)) ; return tid; } diff --git a/src/mobility/position-allocator.cc b/src/mobility/position-allocator.cc index 03ace15ba..d4d21afdd 100644 --- a/src/mobility/position-allocator.cc +++ b/src/mobility/position-allocator.cc @@ -54,16 +54,22 @@ GridPositionAllocator::GetTypeId (void) .SetGroupName ("Mobility") .AddConstructor () .AddParameter ("GridWidth", "The number of objects layed out on a line.", - MakeIntParamSpec (&GridPositionAllocator::m_n, 10)) + IntValue (10), + MakeIntParamSpec (&GridPositionAllocator::m_n)) .AddParameter ("MinX", "The x coordinate where the grid starts.", - MakeFpParamSpec (&GridPositionAllocator::m_xMin, 0.0)) + FpValue (1.0), + MakeFpParamSpec (&GridPositionAllocator::m_xMin)) .AddParameter ("MinY", "The y coordinate where the grid starts.", - MakeFpParamSpec (&GridPositionAllocator::m_yMin, 0.0)) + FpValue (0.0), + MakeFpParamSpec (&GridPositionAllocator::m_yMin)) .AddParameter ("DeltaX", "The x space between objects.", - MakeFpParamSpec (&GridPositionAllocator::m_deltaX, 1.0)) + FpValue (1.0), + MakeFpParamSpec (&GridPositionAllocator::m_deltaX)) .AddParameter ("DeltaY", "The y space between objects.", - MakeFpParamSpec (&GridPositionAllocator::m_deltaY, 1.0)) + FpValue (1.0), + MakeFpParamSpec (&GridPositionAllocator::m_deltaY)) .AddParameter ("LayoutType", "The type of layout.", + EnumValue (ROW_FIRST), MakeEnumParamSpec (&GridPositionAllocator::m_layoutType, ROW_FIRST, "RowFirst", COLUMN_FIRST, "ColumnFirst")) @@ -104,12 +110,12 @@ RandomRectanglePositionAllocator::GetTypeId (void) .AddConstructor () .AddParameter ("X", "A random variable which represents the x coordinate of a position in a random rectangle.", - MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_x, - UniformVariable (0.0, 1.0))) + UniformVariable (0.0, 1.0), + MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_x)) .AddParameter ("Y", "A random variable which represents the y coordinate of a position in a random rectangle.", - MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_y, - UniformVariable (0.0, 1.0))); + UniformVariable (0.0, 1.0), + MakeRandomVariableParamSpec (&RandomRectanglePositionAllocator::m_y)); return tid; } @@ -136,18 +142,20 @@ RandomDiscPositionAllocator::GetTypeId (void) .AddConstructor () .AddParameter ("Theta", "A random variable which represents the angle (gradients) of a position in a random disc.", - MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_theta, - UniformVariable (0.0, 6.2830))) + UniformVariable (0.0, 6.2830), + MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_theta)) .AddParameter ("Rho", "A random variable which represents the radius of a position in a random disc.", - MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_rho, - UniformVariable (0.0, 200.0))) + UniformVariable (0.0, 200.0), + MakeRandomVariableParamSpec (&RandomDiscPositionAllocator::m_rho)) .AddParameter ("X", "The x coordinate of the center of the random position disc.", - MakeFpParamSpec (&RandomDiscPositionAllocator::m_x, 0.0)) + FpValue (0.0), + MakeFpParamSpec (&RandomDiscPositionAllocator::m_x)) .AddParameter ("Y", "The y coordinate of the center of the random position disc.", - MakeFpParamSpec (&RandomDiscPositionAllocator::m_y, 0.0)); + FpValue (0.0), + MakeFpParamSpec (&RandomDiscPositionAllocator::m_y)); return tid; } diff --git a/src/mobility/random-direction-2d-mobility-model.cc b/src/mobility/random-direction-2d-mobility-model.cc index 8e0d090ce..1f1f42272 100644 --- a/src/mobility/random-direction-2d-mobility-model.cc +++ b/src/mobility/random-direction-2d-mobility-model.cc @@ -42,14 +42,14 @@ RandomDirection2dMobilityModel::GetTypeId (void) .SetGroupName ("Mobility") .AddConstructor () .AddParameter ("bounds", "The 2d bounding area", - MakeRectangleParamSpec (&RandomDirection2dMobilityModel::m_bounds, - Rectangle (-100, 100, -100, 100))) + Rectangle (-100, 100, -100, 100), + MakeRectangleParamSpec (&RandomDirection2dMobilityModel::m_bounds)) .AddParameter ("speed", "A random variable to control the speed (m/s).", - MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_speed, - UniformVariable (1.0, 2.0))) + UniformVariable (1.0, 2.0), + MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_speed)) .AddParameter ("pause", "A random variable to control the pause (s).", - MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_pause, - ConstantVariable (2.0))); + ConstantVariable (2.0), + MakeRandomVariableParamSpec (&RandomDirection2dMobilityModel::m_pause)); return tid; } diff --git a/src/mobility/random-walk-2d-mobility-model.cc b/src/mobility/random-walk-2d-mobility-model.cc index 4e11fedf8..1953c0634 100644 --- a/src/mobility/random-walk-2d-mobility-model.cc +++ b/src/mobility/random-walk-2d-mobility-model.cc @@ -39,30 +39,31 @@ RandomWalk2dMobilityModel::GetTypeId (void) .AddConstructor () .AddParameter ("bounds", "Bounds of the area to cruise.", - MakeRectangleParamSpec (&RandomWalk2dMobilityModel::m_bounds, - Rectangle (0.0, 0.0, 100.0, 100.0))) + Rectangle (0.0, 0.0, 100.0, 100.0), + MakeRectangleParamSpec (&RandomWalk2dMobilityModel::m_bounds)) .AddParameter ("time", "Change current direction and speed after moving for this delay.", - MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime, - Seconds (1.0))) + Seconds (1.0), + MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime)) .AddParameter ("distance", "Change current direction and speed after moving for this distance.", - MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime, - Seconds (1.0))) + Seconds (1.0), + MakeTimeParamSpec (&RandomWalk2dMobilityModel::m_modeTime)) .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")) .AddParameter ("direction", "A random variable used to pick the direction (gradients).", - MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_direction, - UniformVariable (0.0, 6.283184))) + UniformVariable (0.0, 6.283184), + MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_direction)) .AddParameter ("speed", "A random variable used to pick the speed (m/s).", - MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_speed, - UniformVariable (2.0, 4.0))); + UniformVariable (2.0, 4.0), + MakeRandomVariableParamSpec (&RandomWalk2dMobilityModel::m_speed)); return tid; } diff --git a/src/mobility/random-waypoint-mobility-model.cc b/src/mobility/random-waypoint-mobility-model.cc index bf926a26d..52def3c6a 100644 --- a/src/mobility/random-waypoint-mobility-model.cc +++ b/src/mobility/random-waypoint-mobility-model.cc @@ -38,14 +38,15 @@ RandomWaypointMobilityModel::GetTypeId (void) .AddConstructor () .AddParameter ("speed", "A random variable used to pick the speed of a random waypoint model.", - MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_speed, - UniformVariable (0.3, 0.7))) + UniformVariable (0.3, 0.7), + MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_speed)) .AddParameter ("pause", "A random variable used to pick the pause of a random waypoint model.", - MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_pause, - ConstantVariable (2.0))) + ConstantVariable (2.0), + MakeRandomVariableParamSpec (&RandomWaypointMobilityModel::m_pause)) .AddParameter ("position", "The position model used to pick a destination point.", + Ptr (0), MakePtrParamSpec (&RandomWaypointMobilityModel::m_position)); return tid; diff --git a/src/node/drop-tail-queue.cc b/src/node/drop-tail-queue.cc index 07be6e8de..7e92adda9 100644 --- a/src/node/drop-tail-queue.cc +++ b/src/node/drop-tail-queue.cc @@ -33,8 +33,8 @@ TypeId DropTailQueue::GetTypeId (void) .SetParent () .AddConstructor () .AddParameter ("MaxPackets", "The maximum number of packets accepted by this DropTailQueue.", - MakeUintParamSpec (&DropTailQueue::m_maxPackets, - 100)) + UintValue (100), + MakeUintParamSpec (&DropTailQueue::m_maxPackets)) ; return tid; @@ -131,8 +131,8 @@ DropTailQueueTest::RunTests (void) { bool result = true; - DropTailQueue queue; - queue.Set ("MaxPackets", UintValue (3)); + Ptr queue = CreateObject (); + NS_TEST_ASSERT (queue->Set ("MaxPackets", UintValue (3))); Ptr p1, p2, p3, p4; p1 = Create (); @@ -140,34 +140,34 @@ DropTailQueueTest::RunTests (void) p3 = Create (); p4 = Create (); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 0); - queue.Enqueue (p1); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 1); - queue.Enqueue (p2); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 2); - queue.Enqueue (p3); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 3); - queue.Enqueue (p4); // will be dropped - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 3); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 0); + queue->Enqueue (p1); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 1); + queue->Enqueue (p2); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 2); + queue->Enqueue (p3); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 3); + queue->Enqueue (p4); // will be dropped + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 3); Ptr p; - p = queue.Dequeue (); + p = queue->Dequeue (); NS_TEST_ASSERT (p != 0); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 2); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 2); NS_TEST_ASSERT_EQUAL (p->GetUid (), p1->GetUid ()); - p = queue.Dequeue (); + p = queue->Dequeue (); NS_TEST_ASSERT (p != 0); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 1); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 1); NS_TEST_ASSERT_EQUAL (p->GetUid (), p2->GetUid ()); - p = queue.Dequeue (); + p = queue->Dequeue (); NS_TEST_ASSERT (p != 0); - NS_TEST_ASSERT_EQUAL (queue.GetNPackets (), 0); + NS_TEST_ASSERT_EQUAL (queue->GetNPackets (), 0); NS_TEST_ASSERT_EQUAL (p->GetUid (), p3->GetUid ()); - p = queue.Dequeue (); + p = queue->Dequeue (); NS_TEST_ASSERT (p == 0); return result; diff --git a/src/simulator/nstime.h b/src/simulator/nstime.h index 4673100db..c97f5f884 100644 --- a/src/simulator/nstime.h +++ b/src/simulator/nstime.h @@ -674,11 +674,9 @@ class TimeValue : public Value {}; class TimeParamSpec : public ParamSpec {}; template -Ptr MakeTimeParamSpec (T1 a1, - Time initialValue); +Ptr MakeTimeParamSpec (T1 a1); template -Ptr MakeTimeParamSpec (T1 a1, T2 a2, - Time initialValue); +Ptr MakeTimeParamSpec (T1 a1, T2 a2); } // namespace ns3 @@ -686,17 +684,15 @@ Ptr MakeTimeParamSpec (T1 a1, T2 a2, namespace ns3 { template -Ptr MakeTimeParamSpec (T1 a1, - Time initialValue) +Ptr MakeTimeParamSpec (T1 a1) { - return MakeClassValueHelperParamSpec (a1, initialValue); + return MakeClassValueHelperParamSpec (a1); } template -Ptr MakeTimeParamSpec (T1 a1, T2 a2, - Time initialValue) +Ptr MakeTimeParamSpec (T1 a1, T2 a2) { - return MakeClassValueHelperParamSpec (a1, a2, initialValue); + return MakeClassValueHelperParamSpec (a1, a2); }