split ParamSpec::CreateInitialValue -> ParamSpec::GetInitialValue + ParamSpec::CreateValue

This commit is contained in:
Mathieu Lacage
2008-02-04 22:48:26 +01:00
parent 6d6ba0c668
commit b1495e485e
3 changed files with 22 additions and 10 deletions

View File

@@ -694,7 +694,7 @@ Parameters::DoSet (Ptr<const ParamSpec> spec, std::string value)
{
return false;
}
PValue v = spec->CreateInitialValue ();
PValue v = spec->CreateValue ();
bool ok = v.DeserializeFromString (value, spec);
if (!ok)
{
@@ -790,7 +790,7 @@ Parameters::DeserializeFromString (std::string str)
value = str.substr (equal+1, next - (equal+1));
cur++;
}
PValue val = spec->CreateInitialValue ();
PValue val = spec->CreateValue ();
bool ok = val.DeserializeFromString (value, spec);
if (!ok)
{
@@ -890,7 +890,7 @@ Object::Construct (const Parameters &parameters)
if (!found)
{
// No matching parameter value so we set the default value.
PValue initial = paramSpec->CreateInitialValue ();
PValue initial = paramSpec->GetInitialValue ();
paramSpec->Set (this, initial);
NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<<
tid.GetParameterName (i)<<"\" from local");
@@ -929,7 +929,7 @@ Object::Set (std::string name, std::string value)
{
return false;
}
PValue v = spec->CreateInitialValue ();
PValue v = spec->CreateValue ();
bool ok = v.DeserializeFromString (value, spec);
if (!ok)
{
@@ -951,7 +951,7 @@ Object::Get (std::string name, std::string &value) const
{
return false;
}
PValue v = paramSpec->CreateInitialValue ();
PValue v = paramSpec->CreateValue ();
bool ok = paramSpec->Get (this, v);
if (ok)
{
@@ -968,7 +968,7 @@ Object::Get (std::string name) const
{
return PValue ();
}
PValue value = paramSpec->CreateInitialValue ();
PValue value = paramSpec->CreateValue ();
bool ok = paramSpec->Get (this, value);
if (!ok)
{

View File

@@ -31,7 +31,8 @@ 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 CreateInitialValue (void) const;
virtual PValue GetInitialValue (void) const;
virtual PValue CreateValue (void) const;
private:
virtual void DoSet (T *object, const U *v) const = 0;
@@ -244,11 +245,18 @@ ParamSpecHelper<T,U,CHECKER>::Check (PValue value) const
}
template <typename T, typename U, typename CHECKER>
PValue
ParamSpecHelper<T,U,CHECKER>::CreateInitialValue (void) const
ParamSpecHelper<T,U,CHECKER>::GetInitialValue (void) const
{
return m_initialValue;
}
template <typename T, typename U, typename CHECKER>
PValue
ParamSpecHelper<T,U,CHECKER>::CreateValue (void) const
{
return m_initialValue.Copy ();
}
} // namespace ns3
#endif /* PARAM_SPEC_HELPER_H */

View File

@@ -74,7 +74,8 @@ 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 CreateInitialValue (void) const = 0;
virtual PValue GetInitialValue (void) const = 0;
virtual PValue CreateValue (void) const = 0;
private:
mutable uint32_t m_count;
};
@@ -246,7 +247,10 @@ public:
}
return true;
}
virtual PValue CreateInitialValue (void) const {
virtual PValue GetInitialValue (void) const {
return CreateValue ();
}
virtual PValue CreateValue (void) const {
return PValue::Create<PtrValue<U> > (Ptr<U> (0));
}
private: