From 33be90636bc297ca8d64ddf895e55b618f2a81fb Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 21 Feb 2008 19:28:41 +0100 Subject: [PATCH] AddParameter -> AddAttribute --- src/core/attribute-test.cc | 30 +- src/core/initial-value.cc | 2 +- src/core/object-factory.h | 2 +- src/core/object.cc | 298 +++++++++--------- src/core/object.h | 158 +++++----- src/mobility/hierarchical-mobility-model.cc | 4 +- src/mobility/mobility-model.cc | 4 +- src/mobility/position-allocator.cc | 24 +- .../random-direction-2d-mobility-model.cc | 6 +- src/mobility/random-walk-2d-mobility-model.cc | 12 +- .../random-waypoint-mobility-model.cc | 6 +- src/node/drop-tail-queue.cc | 2 +- 12 files changed, 274 insertions(+), 274 deletions(-) diff --git a/src/core/attribute-test.cc b/src/core/attribute-test.cc index caae9b45b..414a87bf9 100644 --- a/src/core/attribute-test.cc +++ b/src/core/attribute-test.cc @@ -41,55 +41,55 @@ public: static TypeId GetTypeId (void) { static TypeId tid = TypeId ("AttributeObjectTest") .SetParent () - .AddParameter ("TestBoolName", "help text", + .AddAttribute ("TestBoolName", "help text", Boolean (false), MakeBooleanAccessor (&AttributeObjectTest::m_boolTest), MakeBooleanChecker ()) - .AddParameter ("TestBoolA", "help text", + .AddAttribute ("TestBoolA", "help text", Boolean (false), MakeBooleanAccessor (&AttributeObjectTest::DoSetTestB, &AttributeObjectTest::DoGetTestB), MakeBooleanChecker ()) - .AddParameter ("TestPtr", "help text", + .AddAttribute ("TestPtr", "help text", Ptr (0), MakePtrAccessor (&AttributeObjectTest::m_derived), MakePtrChecker ()) - .AddParameter ("TestInt16", "help text", + .AddAttribute ("TestInt16", "help text", Integer (-2), MakeIntegerAccessor (&AttributeObjectTest::m_int16), MakeIntegerChecker ()) - .AddParameter ("TestInt16WithBounds", "help text", + .AddAttribute ("TestInt16WithBounds", "help text", Integer (-2), MakeIntegerAccessor (&AttributeObjectTest::m_int16WithBounds), MakeIntegerChecker (-5, 10)) - .AddParameter ("TestInt16SetGet", "help text", + .AddAttribute ("TestInt16SetGet", "help text", Integer (6), MakeIntegerAccessor (&AttributeObjectTest::DoSetInt16, &AttributeObjectTest::DoGetInt16), MakeIntegerChecker ()) - .AddParameter ("TestUint8", "help text", + .AddAttribute ("TestUint8", "help text", Uinteger (1), MakeUintegerAccessor (&AttributeObjectTest::m_uint8), MakeUintegerChecker ()) - .AddParameter ("TestEnum", "help text", + .AddAttribute ("TestEnum", "help text", Enum (TEST_A), MakeEnumAccessor (&AttributeObjectTest::m_enum), MakeEnumChecker (TEST_A, "TestA", TEST_B, "TestB", TEST_C, "TestC")) - .AddParameter ("TestRandom", "help text", + .AddAttribute ("TestRandom", "help text", ConstantVariable (1.0), MakeRandomVariableAccessor (&AttributeObjectTest::m_random), MakeRandomVariableChecker ()) - .AddParameter ("TestFloat", "help text", + .AddAttribute ("TestFloat", "help text", Double (-1.1), MakeDoubleAccessor (&AttributeObjectTest::m_float), MakeDoubleChecker ()) - .AddParameter ("TestVector1", "help text", + .AddAttribute ("TestVector1", "help text", ObjectVector (), MakeObjectVectorAccessor (&AttributeObjectTest::m_vector1), MakeObjectVectorChecker ()) - .AddParameter ("TestVector2", "help text", + .AddAttribute ("TestVector2", "help text", ObjectVector (), MakeObjectVectorAccessor (&AttributeObjectTest::DoGetVectorN, &AttributeObjectTest::DoGetVector), @@ -167,7 +167,7 @@ AttributeTest::RunTests (void) { bool result = true; - Parameters params; + Attributes params; Ptr p; NS_TEST_ASSERT (params.Set ("AttributeObjectTest::TestBoolName", "false")); p = CreateObject (params); @@ -344,11 +344,11 @@ AttributeTest::RunTests (void) p->Set ("TestBool", "false"); NS_TEST_ASSERT_EQUAL (p->Get ("TestBool"), "false"); - Parameters::GetGlobal ()->Set ("TestBool", "true"); + Attributes::GetGlobal ()->Set ("TestBool", "true"); p = CreateObjectWith (); NS_TEST_ASSERT_EQUAL (p->Get ("TestBool"), "true"); - Parameters::GetGlobal ()->Set ("TestBool", "false"); + Attributes::GetGlobal ()->Set ("TestBool", "false"); p = CreateObjectWith (); NS_TEST_ASSERT_EQUAL (p->Get ("TestBool"), "false"); #endif diff --git a/src/core/initial-value.cc b/src/core/initial-value.cc index 1e674dcc4..3b03ee158 100644 --- a/src/core/initial-value.cc +++ b/src/core/initial-value.cc @@ -63,7 +63,7 @@ InitialValue::Bind (std::string name, Attribute value) } // since we did not find a matching InitialValue, // we attempt to configure the global parameters list. - Parameters::GetGlobal ()->Set (name, value); + Attributes::GetGlobal ()->Set (name, value); } InitialValue::Iterator InitialValue::Begin (void) diff --git a/src/core/object-factory.h b/src/core/object-factory.h index aeee43dd1..a35a22f11 100644 --- a/src/core/object-factory.h +++ b/src/core/object-factory.h @@ -22,7 +22,7 @@ public: private: TypeId m_tid; - Parameters m_parameters; + Attributes m_parameters; }; } // namespace ns3 diff --git a/src/core/object.cc b/src/core/object.cc index fde73affe..1be0a44e4 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -53,25 +53,25 @@ public: bool HasConstructor (uint16_t uid); uint32_t GetRegisteredN (void); uint16_t GetRegistered (uint32_t i); - void AddParameter (uint16_t uid, + void AddAttribute (uint16_t uid, std::string name, std::string help, uint32_t flags, ns3::Attribute initialValue, ns3::Ptr spec, ns3::Ptr 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::Attribute GetParameterInitialValue (uint16_t uid, uint32_t i) const; - ns3::Ptr GetParameterAccessor (uint16_t uid, uint32_t i) const; - ns3::Ptr GetParameterChecker (uint16_t uid, uint32_t i) const; + uint32_t GetAttributesN (uint16_t uid) const; + std::string GetAttributeName (uint16_t uid, uint32_t i) const; + uint32_t GetAttributeFlags (uint16_t uid, uint32_t i) const; + ns3::Attribute GetAttributeInitialValue (uint16_t uid, uint32_t i) const; + ns3::Ptr GetAttributeAccessor (uint16_t uid, uint32_t i) const; + ns3::Ptr GetAttributeChecker (uint16_t uid, uint32_t i) const; private: struct ConstructorInformation { ns3::CallbackBase cb; uint32_t nArguments; }; - struct ParameterInformation { + struct AttributeInformation { std::string name; std::string help; uint32_t flags; @@ -85,7 +85,7 @@ private: std::string typeName; std::string groupName; std::vector constructors; - std::vector parameters; + std::vector attributes; }; typedef std::vector::const_iterator Iterator; @@ -242,7 +242,7 @@ IidManager::GetRegistered (uint32_t i) } void -IidManager::AddParameter (uint16_t uid, +IidManager::AddAttribute (uint16_t uid, std::string name, std::string help, uint32_t flags, @@ -251,66 +251,66 @@ IidManager::AddParameter (uint16_t uid, ns3::Ptr checker) { struct IidInformation *information = LookupInformation (uid); - for (std::vector::const_iterator j = information->parameters.begin (); - j != information->parameters.end (); j++) + for (std::vector::const_iterator j = information->attributes.begin (); + j != information->attributes.end (); j++) { if (j->name == name) { - NS_FATAL_ERROR ("Registered the same parameter twice name=\""<name<<"\""); + NS_FATAL_ERROR ("Registered the same attribute twice name=\""<name<<"\""); return; } } - struct ParameterInformation param; + struct AttributeInformation param; param.name = name; param.help = help; param.flags = flags; param.initialValue = initialValue; param.param = spec; param.checker = checker; - information->parameters.push_back (param); + information->attributes.push_back (param); } uint32_t -IidManager::GetParametersN (uint16_t uid) const +IidManager::GetAttributesN (uint16_t uid) const { struct IidInformation *information = LookupInformation (uid); - return information->parameters.size (); + return information->attributes.size (); } std::string -IidManager::GetParameterName (uint16_t uid, uint32_t i) const +IidManager::GetAttributeName (uint16_t uid, uint32_t i) const { struct IidInformation *information = LookupInformation (uid); - NS_ASSERT (i < information->parameters.size ()); - return information->parameters[i].name; + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i].name; } uint32_t -IidManager::GetParameterFlags (uint16_t uid, uint32_t i) const +IidManager::GetAttributeFlags (uint16_t uid, uint32_t i) const { struct IidInformation *information = LookupInformation (uid); - NS_ASSERT (i < information->parameters.size ()); - return information->parameters[i].flags; + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i].flags; } ns3::Attribute -IidManager::GetParameterInitialValue (uint16_t uid, uint32_t i) const +IidManager::GetAttributeInitialValue (uint16_t uid, uint32_t i) const { struct IidInformation *information = LookupInformation (uid); - NS_ASSERT (i < information->parameters.size ()); - return information->parameters[i].initialValue; + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i].initialValue; } ns3::Ptr -IidManager::GetParameterAccessor (uint16_t uid, uint32_t i) const +IidManager::GetAttributeAccessor (uint16_t uid, uint32_t i) const { struct IidInformation *information = LookupInformation (uid); - NS_ASSERT (i < information->parameters.size ()); - return information->parameters[i].param; + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i].param; } ns3::Ptr -IidManager::GetParameterChecker (uint16_t uid, uint32_t i) const +IidManager::GetAttributeChecker (uint16_t uid, uint32_t i) const { struct IidInformation *information = LookupInformation (uid); - NS_ASSERT (i < information->parameters.size ()); - return information->parameters[i].checker; + NS_ASSERT (i < information->attributes.size ()); + return information->attributes[i].checker; } } // anonymous namespace @@ -411,7 +411,7 @@ TypeId::LookupByName (std::string name) return TypeId (uid); } bool -TypeId::LookupParameterByFullName (std::string fullName, struct TypeId::ParameterInfo *info) +TypeId::LookupAttributeByFullName (std::string fullName, struct TypeId::AttributeInfo *info) { std::string::size_type pos = fullName.find ("::"); if (pos == std::string::npos) @@ -421,7 +421,7 @@ TypeId::LookupParameterByFullName (std::string fullName, struct TypeId::Paramete std::string tidName = fullName.substr (0, pos); std::string paramName = fullName.substr (pos+2, fullName.size () - (pos+2)); TypeId tid = LookupByName (tidName); - return tid.LookupParameterByName (paramName, info); + return tid.LookupAttributeByName (paramName, info); } uint32_t TypeId::GetRegisteredN (void) @@ -435,21 +435,21 @@ TypeId::GetRegistered (uint32_t i) } bool -TypeId::LookupParameterByName (std::string name, struct TypeId::ParameterInfo *info) const +TypeId::LookupAttributeByName (std::string name, struct TypeId::AttributeInfo *info) const { TypeId tid = TypeId (0); TypeId nextTid = *this; do { tid = nextTid; - for (uint32_t i = 0; i < GetParametersN (); i++) + for (uint32_t i = 0; i < GetAttributesN (); i++) { - std::string paramName = GetParameterName (i); + std::string paramName = GetAttributeName (i); if (paramName == name) { - info->spec = GetParameterAccessor (i); - info->flags = GetParameterFlags (i); - info->initialValue = tid.GetParameterInitialValue (i); - info->checker = tid.GetParameterChecker (i); + info->accessor = GetAttributeAccessor (i); + info->flags = GetAttributeFlags (i); + info->initialValue = tid.GetAttributeInitialValue (i); + info->checker = tid.GetAttributeChecker (i); return true; } } @@ -458,21 +458,21 @@ TypeId::LookupParameterByName (std::string name, struct TypeId::ParameterInfo *i return false; } bool -TypeId::LookupParameterByPosition (uint32_t i, struct TypeId::ParameterInfo *info) const +TypeId::LookupAttributeByPosition (uint32_t i, struct TypeId::AttributeInfo *info) const { uint32_t cur = 0; TypeId tid = TypeId (0); TypeId nextTid = *this; do { tid = nextTid; - for (uint32_t j = 0; j < tid.GetParametersN (); j++) + for (uint32_t j = 0; j < tid.GetAttributesN (); j++) { if (cur == i) { - info->spec = tid.GetParameterAccessor (j); - info->flags = tid.GetParameterFlags (j); - info->initialValue = tid.GetParameterInitialValue (j); - info->checker = tid.GetParameterChecker (j); + info->accessor = tid.GetAttributeAccessor (j); + info->flags = tid.GetAttributeFlags (j); + info->initialValue = tid.GetAttributeInitialValue (j); + info->checker = tid.GetAttributeChecker (j); return true; } cur++; @@ -541,25 +541,25 @@ TypeId::DoAddConstructor (CallbackBase cb, uint32_t nArguments) } TypeId -TypeId::AddParameter (std::string name, +TypeId::AddAttribute (std::string name, std::string help, Attribute initialValue, Ptr param, Ptr checker) { - Singleton::Get ()->AddParameter (m_tid, name, help, ATTR_SGC, initialValue, param, checker); + Singleton::Get ()->AddAttribute (m_tid, name, help, ATTR_SGC, initialValue, param, checker); return *this; } TypeId -TypeId::AddParameter (std::string name, +TypeId::AddAttribute (std::string name, std::string help, uint32_t flags, Attribute initialValue, Ptr param, Ptr checker) { - Singleton::Get ()->AddParameter (m_tid, name, help, flags, initialValue, param, checker); + Singleton::Get ()->AddAttribute (m_tid, name, help, flags, initialValue, param, checker); return *this; } @@ -574,60 +574,60 @@ TypeId::LookupConstructor (uint32_t nArguments) const Ptr TypeId::CreateObject (void) const { - return CreateObject (Parameters ()); + return CreateObject (Attributes ()); } Ptr -TypeId::CreateObject (const Parameters ¶meters) const +TypeId::CreateObject (const Attributes &attributes) const { CallbackBase cb = LookupConstructor (0); - Callback,const Parameters &> realCb; + Callback,const Attributes &> realCb; realCb.Assign (cb); - Ptr object = realCb (parameters); + Ptr object = realCb (attributes); return object; } uint32_t -TypeId::GetParametersN (void) const +TypeId::GetAttributesN (void) const { - uint32_t n = Singleton::Get ()->GetParametersN (m_tid); + uint32_t n = Singleton::Get ()->GetAttributesN (m_tid); return n; } std::string -TypeId::GetParameterName (uint32_t i) const +TypeId::GetAttributeName (uint32_t i) const { - std::string name = Singleton::Get ()->GetParameterName (m_tid, i); + std::string name = Singleton::Get ()->GetAttributeName (m_tid, i); return name; } std::string -TypeId::GetParameterFullName (uint32_t i) const +TypeId::GetAttributeFullName (uint32_t i) const { - return GetName () + "::" + GetParameterName (i); + return GetName () + "::" + GetAttributeName (i); } Attribute -TypeId::GetParameterInitialValue (uint32_t i) const +TypeId::GetAttributeInitialValue (uint32_t i) const { - Attribute value = Singleton::Get ()->GetParameterInitialValue (m_tid, i); + Attribute value = Singleton::Get ()->GetAttributeInitialValue (m_tid, i); return value; } Ptr -TypeId::GetParameterAccessor (uint32_t i) const +TypeId::GetAttributeAccessor (uint32_t i) const { // Used exclusively by the Object class. - Ptr param = Singleton::Get ()->GetParameterAccessor (m_tid, i); + Ptr param = Singleton::Get ()->GetAttributeAccessor (m_tid, i); return param; } uint32_t -TypeId::GetParameterFlags (uint32_t i) const +TypeId::GetAttributeFlags (uint32_t i) const { // Used exclusively by the Object class. - uint32_t flags = Singleton::Get ()->GetParameterFlags (m_tid, i); + uint32_t flags = Singleton::Get ()->GetAttributeFlags (m_tid, i); return flags; } Ptr -TypeId::GetParameterChecker (uint32_t i) const +TypeId::GetAttributeChecker (uint32_t i) const { // Used exclusively by the Object class. - Ptr checker = Singleton::Get ()->GetParameterChecker (m_tid, i); + Ptr checker = Singleton::Get ()->GetAttributeChecker (m_tid, i); return checker; } @@ -643,84 +643,84 @@ bool operator != (TypeId a, TypeId b) } /********************************************************************* - * The Parameters container implementation + * The Attributes container implementation *********************************************************************/ -Parameters::Parameters () +Attributes::Attributes () {} -Parameters::Parameters (const Parameters &o) +Attributes::Attributes (const Attributes &o) { - for (Params::const_iterator i = o.m_parameters.begin (); i != o.m_parameters.end (); i++) + for (Attrs::const_iterator i = o.m_attributes.begin (); i != o.m_attributes.end (); i++) { - struct Param param; - param.checker = i->checker; - param.value = i->value.Copy (); - m_parameters.push_back (param); + struct Attr attr; + attr.checker = i->checker; + attr.value = i->value.Copy (); + m_attributes.push_back (attr); } } -Parameters & -Parameters::operator = (const Parameters &o) +Attributes & +Attributes::operator = (const Attributes &o) { Reset (); - for (Params::const_iterator i = o.m_parameters.begin (); i != o.m_parameters.end (); i++) + for (Attrs::const_iterator i = o.m_attributes.begin (); i != o.m_attributes.end (); i++) { - struct Param param; - param.checker = i->checker; - param.value = i->value.Copy (); - m_parameters.push_back (param); + struct Attr attr; + attr.checker = i->checker; + attr.value = i->value.Copy (); + m_attributes.push_back (attr); } return *this; } -Parameters::~Parameters () +Attributes::~Attributes () { Reset (); } bool -Parameters::Set (std::string name, Attribute value) +Attributes::Set (std::string name, Attribute value) { - struct TypeId::ParameterInfo info; - TypeId::LookupParameterByFullName (name, &info); + struct TypeId::AttributeInfo info; + TypeId::LookupAttributeByFullName (name, &info); bool ok = DoSet (&info, value); return ok; } void -Parameters::SetWithTid (TypeId tid, std::string name, Attribute value) +Attributes::SetWithTid (TypeId tid, std::string name, Attribute value) { - struct TypeId::ParameterInfo info; - tid.LookupParameterByName (name, &info); + struct TypeId::AttributeInfo info; + tid.LookupAttributeByName (name, &info); DoSet (&info, value); } void -Parameters::SetWithTid (TypeId tid, uint32_t position, Attribute value) +Attributes::SetWithTid (TypeId tid, uint32_t position, Attribute value) { - struct TypeId::ParameterInfo info; - tid.LookupParameterByPosition (position, &info); + struct TypeId::AttributeInfo info; + tid.LookupAttributeByPosition (position, &info); DoSet (&info, value); } void -Parameters::DoSetOne (Ptr checker, Attribute value) +Attributes::DoSetOne (Ptr checker, Attribute 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++) + for (Attrs::iterator k = m_attributes.begin (); k != m_attributes.end (); k++) { if (k->checker == checker) { - m_parameters.erase (k); + m_attributes.erase (k); break; } } // store the new value. - struct Param p; - p.checker = checker; - p.value = value.Copy (); - m_parameters.push_back (p); + struct Attr attr; + attr.checker = checker; + attr.value = value.Copy (); + m_attributes.push_back (attr); } bool -Parameters::DoSet (struct TypeId::ParameterInfo *info, Attribute value) +Attributes::DoSet (struct TypeId::AttributeInfo *info, Attribute value) { if (info->checker == 0) { @@ -753,27 +753,27 @@ Parameters::DoSet (struct TypeId::ParameterInfo *info, Attribute value) return true; } void -Parameters::Reset (void) +Attributes::Reset (void) { - m_parameters.clear (); + m_attributes.clear (); } -Parameters * -Parameters::GetGlobal (void) +Attributes * +Attributes::GetGlobal (void) { - return Singleton::Get (); + return Singleton::Get (); } std::string -Parameters::LookupParameterFullNameByChecker (Ptr checker) const +Attributes::LookupAttributeFullNameByChecker (Ptr 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++) + for (uint32_t j = 0; j < tid.GetAttributesN (); j++) { - if (checker == tid.GetParameterChecker (j)) + if (checker == tid.GetAttributeChecker (j)) { - return tid.GetParameterFullName (j); + return tid.GetAttributeFullName (j); } } } @@ -783,14 +783,14 @@ Parameters::LookupParameterFullNameByChecker (Ptr checke } std::string -Parameters::SerializeToString (void) const +Attributes::SerializeToString (void) const { std::ostringstream oss; - for (Params::const_iterator i = m_parameters.begin (); i != m_parameters.end (); i++) + for (Attrs::const_iterator i = m_attributes.begin (); i != m_attributes.end (); i++) { - std::string name = LookupParameterFullNameByChecker (i->checker); + std::string name = LookupAttributeFullNameByChecker (i->checker); oss << name << "=" << i->value.SerializeToString (i->checker); - if (i != m_parameters.end ()) + if (i != m_attributes.end ()) { oss << "|"; } @@ -798,7 +798,7 @@ Parameters::SerializeToString (void) const return oss.str (); } bool -Parameters::DeserializeFromString (std::string str) +Attributes::DeserializeFromString (std::string str) { Reset (); @@ -808,14 +808,14 @@ Parameters::DeserializeFromString (std::string str) std::string::size_type equal = str.find ("=", cur); if (equal == std::string::npos) { - // XXX: invalid parameter. + // XXX: invalid attribute. break; } else { std::string name = str.substr (cur, equal-cur); - struct TypeId::ParameterInfo info; - if (!TypeId::LookupParameterByFullName (name, &info)) + struct TypeId::AttributeInfo info; + if (!TypeId::LookupAttributeByFullName (name, &info)) { // XXX invalid name. break; @@ -887,51 +887,51 @@ Object::~Object () m_next = 0; } void -Object::Construct (const Parameters ¶meters) +Object::Construct (const Attributes &attributes) { // loop over the inheritance tree back to the Object base class. TypeId tid = m_tid; do { - // loop over all parameters in object type - NS_LOG_DEBUG ("construct tid="<checker == checker) { - // We have a matching parameter value. + // We have a matching attribute value. DoSet (paramSpec, initial, checker, j->value); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< - tid.GetParameterName (i)<<"\""); + tid.GetAttributeName (i)<<"\""); found = true; break; } } if (!found) { - // is this parameter stored in the global instance instance ? - for (Parameters::Params::const_iterator j = Parameters::GetGlobal ()->m_parameters.begin (); - j != Parameters::GetGlobal ()->m_parameters.end (); j++) + // is this attribute stored in the global instance instance ? + for (Attributes::Attrs::const_iterator j = Attributes::GetGlobal ()->m_attributes.begin (); + j != Attributes::GetGlobal ()->m_attributes.end (); j++) { if (j->checker == checker) { - // We have a matching parameter value. + // We have a matching attribute value. DoSet (paramSpec, initial, checker, j->value); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< - tid.GetParameterName (i)<<"\" from global"); + tid.GetAttributeName (i)<<"\" from global"); found = true; break; } @@ -939,10 +939,10 @@ Object::Construct (const Parameters ¶meters) } if (!found) { - // No matching parameter value so we set the default value. + // No matching attribute value so we set the default value. paramSpec->Set (this, initial); NS_LOG_DEBUG ("construct \""<< tid.GetName ()<<"::"<< - tid.GetParameterName (i)<<"\" from local"); + tid.GetAttributeName (i)<<"\" from local"); } } tid = tid.GetParent (); @@ -982,8 +982,8 @@ Object::DoSet (Ptr spec, Attribute initialValue, bool Object::Set (std::string name, Attribute value) { - struct TypeId::ParameterInfo info; - if (!m_tid.LookupParameterByName (name, &info)) + struct TypeId::AttributeInfo info; + if (!m_tid.LookupAttributeByName (name, &info)) { return false; } @@ -991,13 +991,13 @@ Object::Set (std::string name, Attribute value) { return false; } - return DoSet (info.spec, info.initialValue, info.checker, value); + return DoSet (info.accessor, info.initialValue, info.checker, value); } bool Object::Get (std::string name, std::string &value) const { - struct TypeId::ParameterInfo info; - if (!m_tid.LookupParameterByName (name, &info)) + struct TypeId::AttributeInfo info; + if (!m_tid.LookupAttributeByName (name, &info)) { return false; } @@ -1006,7 +1006,7 @@ Object::Get (std::string name, std::string &value) const return false; } Attribute v = info.initialValue.Copy (); - bool ok = info.spec->Get (this, v); + bool ok = info.accessor->Get (this, v); if (ok) { value = v.SerializeToString (info.checker); @@ -1017,8 +1017,8 @@ Object::Get (std::string name, std::string &value) const Attribute Object::Get (std::string name) const { - struct TypeId::ParameterInfo info; - if (!m_tid.LookupParameterByName (name, &info)) + struct TypeId::AttributeInfo info; + if (!m_tid.LookupAttributeByName (name, &info)) { return Attribute (); } @@ -1027,7 +1027,7 @@ Object::Get (std::string name) const return Attribute (); } Attribute value = info.initialValue.Copy (); - bool ok = info.spec->Get (this, value); + bool ok = info.accessor->Get (this, value); if (!ok) { return Attribute (); diff --git a/src/core/object.h b/src/core/object.h index d8945dfd2..5396a42e9 100644 --- a/src/core/object.h +++ b/src/core/object.h @@ -46,7 +46,7 @@ class CallbackBase; class Object; class AttributeAccessor; class AttributeValue; -class Parameters; +class Attributes; /** * \brief a unique identifier for an interface. @@ -55,7 +55,7 @@ class Parameters; * subclass of the Object base class: * - the base class of the subclass * - the set of accessible constructors in the subclass - * - the set of 'parameters' accessible in the subclass + * - the set of 'attributes' accessible in the subclass */ class TypeId { @@ -122,25 +122,25 @@ public: bool HasConstructor (void) const; /** - * \returns the number of parameters associated to this TypeId + * \returns the number of attributes associated to this TypeId */ - uint32_t GetParametersN (void) const; + uint32_t GetAttributesN (void) const; /** - * \param i index into parameter array - * \returns the name associated to the parameter whose + * \param i index into attribute array + * \returns the name associated to the attribute whose * index is \i i. */ - std::string GetParameterName (uint32_t i) const; + std::string GetAttributeName (uint32_t i) const; /** - * \param i index into parameter array - * \returns the full name associated to the parameter whose + * \param i index into attribute array + * \returns the full name associated to the attribute whose * index is \i i. */ - std::string GetParameterFullName (uint32_t i) const; + std::string GetAttributeFullName (uint32_t i) const; - Attribute GetParameterInitialValue (uint32_t i) const; + Attribute GetAttributeInitialValue (uint32_t i) const; - Ptr CreateObject (const Parameters ¶meters) const; + Ptr CreateObject (const Attributes &attributes) const; Ptr CreateObject (void) const; @@ -199,31 +199,31 @@ public: TypeId AddConstructor (void); /** - * \param name the name of the new parameter + * \param name the name of the new attribute * \param help some help text which describes the purpose of this - * parameter + * attribute * \param param an instance of the associated Accessor subclass * \returns this TypeId instance * - * Record in this TypeId the fact that a new parameter exists. + * Record in this TypeId the fact that a new attribute exists. */ - TypeId AddParameter (std::string name, + TypeId AddAttribute (std::string name, std::string help, Attribute initialValue, Ptr spec, Ptr checker); /** - * \param name the name of the new parameter + * \param name the name of the new attribute * \param help some help text which describes the purpose of this - * parameter - * \param flags flags which describe how this parameter can be read and/or written. + * attribute + * \param flags flags which describe how this attribute can be read and/or written. * \param param an instance of the associated Accessor subclass * \returns this TypeId instance * - * Record in this TypeId the fact that a new parameter exists. + * Record in this TypeId the fact that a new attribute exists. */ - TypeId AddParameter (std::string name, + TypeId AddAttribute (std::string name, std::string help, uint32_t flags, Attribute initialValue, @@ -235,63 +235,63 @@ public: ~TypeId (); private: friend class Object; - friend class Parameters; + friend class Attributes; friend bool operator == (TypeId a, TypeId b); friend bool operator != (TypeId a, TypeId b); - struct ParameterInfo { - Ptr spec; + struct AttributeInfo { + Ptr accessor; Attribute initialValue; uint32_t flags; Ptr checker; }; /** - * \param name the name of the requested parameter - * \returns the Accessor associated to the requested parameter + * \param name the name of the requested attribute + * \returns the Accessor associated to the requested attribute */ - bool LookupParameterByName (std::string name, struct ParameterInfo *info) const; + bool LookupAttributeByName (std::string name, struct AttributeInfo *info) const; /** - * \param i the position of the requested parameter - * \returns the Accessor associated to the requested parameter + * \param i the position of the requested attribute + * \returns the Accessor associated to the requested attribute */ - bool LookupParameterByPosition (uint32_t i, struct ParameterInfo *info) const; + bool LookupAttributeByPosition (uint32_t i, struct AttributeInfo *info) const; /** - * \param fullName the full name of the requested parameter - * \returns the Accessor associated to the requested parameter + * \param fullName the full name of the requested attribute + * \returns the Accessor associated to the requested attribute */ - static bool LookupParameterByFullName (std::string fullName, struct ParameterInfo *info); + static bool LookupAttributeByFullName (std::string fullName, struct AttributeInfo *info); explicit TypeId (uint16_t tid); void DoAddConstructor (CallbackBase callback, uint32_t nArguments); CallbackBase LookupConstructor (uint32_t nArguments) const; - Ptr GetParameterAccessor (uint32_t i) const; - uint32_t GetParameterFlags (uint32_t i) const; - Ptr GetParameterChecker (uint32_t i) const; + Ptr GetAttributeAccessor (uint32_t i) const; + uint32_t GetAttributeFlags (uint32_t i) const; + Ptr GetAttributeChecker (uint32_t i) const; uint16_t m_tid; }; /** - * \brief a container of parameters to be used during object's construction + * \brief a container of attributes to be used during object's construction * and in ns3::Object::Set. * */ -class Parameters +class Attributes { public: - Parameters (); - Parameters (const Parameters &o); - Parameters &operator = (const Parameters &o); - ~Parameters (); + Attributes (); + Attributes (const Attributes &o); + Attributes &operator = (const Attributes &o); + ~Attributes (); /** - * \param name the name of the parameter to set + * \param name the name of the attribute to set * \param value the value to set * - * This method checks that a parameter with the requested + * This method checks that a attribute with the requested * name exists and that the value specified is an acceptable - * value of that parameter. If any of these checks fails, + * value of that attribute. If any of these checks fails, * the program terminates with a message. */ bool Set (std::string name, Attribute value); @@ -305,36 +305,36 @@ public: void Reset (void); /** - * \returns the global parameter container + * \returns the global attribute container * - * The global parameter container can be used to specify - * a set of parameter values without having to re-specify + * The global attribute container can be used to specify + * a set of attribute values without having to re-specify * them for each object when it is created. This container * is checked only during object construction and * it is always checked last, after any per-object * container is checked. */ - static Parameters *GetGlobal (void); + static Attributes *GetGlobal (void); std::string SerializeToString (void) const; bool DeserializeFromString (std::string value); private: friend class Object; - struct Param { + struct Attr { Ptr checker; Attribute value; }; - typedef std::vector Params; - typedef Params::iterator Iterator; - typedef Params::const_iterator CIterator; + typedef std::vector Attrs; + typedef Attrs::iterator Iterator; + typedef Attrs::const_iterator CIterator; - bool DoSet (struct TypeId::ParameterInfo *info, Attribute param); + bool DoSet (struct TypeId::AttributeInfo *info, Attribute param); void DoSetOne (Ptr checker, Attribute param); - std::string LookupParameterFullNameByChecker (Ptr checker) const; + std::string LookupAttributeFullNameByChecker (Ptr checker) const; - Params m_parameters; + Attrs m_attributes; }; @@ -351,24 +351,24 @@ public: virtual ~Object (); /** - * \param name the name of the parameter to set - * \param value the name of the parameter to set + * \param name the name of the attribute to set + * \param value the name of the attribute to set * - * Set a single parameter. + * Set a single attribute. */ bool Set (std::string name, Attribute value); /** - * \param name the name of the parameter to read + * \param name the name of the attribute to read * \param value a reference to the string where the value of the - * parameter should be stored. - * \returns true if the requested parameter was found, false otherwise. + * attribute should be stored. + * \returns true if the requested attribute was found, false otherwise. */ bool Get (std::string name, std::string &value) const; /** - * \param name the name of the parameter to read + * \param name the name of the attribute to read * \param value a reference to the object where the value of the - * parameter should be stored. - * \returns true if the requested parameter was found, false otherwise. + * attribute should be stored. + * \returns true if the requested attribute was found, false otherwise. */ Attribute Get (std::string name) const; @@ -450,7 +450,7 @@ private: friend class TypeIdTraceResolver; template - friend Ptr CreateObject (const Parameters ¶meters); + friend Ptr CreateObject (const Attributes &attributes); template friend Ptr CreateObject (void); @@ -494,14 +494,14 @@ private: */ void SetTypeId (TypeId tid); /** - * \param parameters the parameter values used to initialize + * \param attributes the attribute values used to initialize * the member variables of this object's instance. * * Invoked from ns3::CreateObject only. * Initialize all the member variables which were * registered with the associated TypeId. */ - void Construct (const Parameters ¶meters); + void Construct (const Attributes &attributes); /** * The reference count for this object. Each aggregate @@ -551,8 +551,8 @@ TypeId TypeId::AddConstructor (void) { struct Maker { - static Ptr Create (const Parameters ¶meters) { - return ns3::CreateObject (parameters); + static Ptr Create (const Attributes &attributes) { + return ns3::CreateObject (attributes); } }; CallbackBase cb = MakeCallback (&Maker::Create); @@ -656,11 +656,11 @@ Object::GetObject (TypeId tid) const template -Ptr CreateObject (const Parameters ¶meters) +Ptr CreateObject (const Attributes &attributes) { Ptr p = Ptr (new T (), false); p->SetTypeId (T::GetTypeId ()); - p->Object::Construct (parameters); + p->Object::Construct (attributes); return p; } @@ -669,7 +669,7 @@ Ptr CreateObject (void) { Ptr p = Ptr (new T (), false); p->SetTypeId (T::GetTypeId ()); - p->Object::Construct (Parameters ()); + p->Object::Construct (Attributes ()); return p; } @@ -678,7 +678,7 @@ Ptr CreateObject (T1 a1) { Ptr p = Ptr (new T (a1), false); p->SetTypeId (T::GetTypeId ()); - p->Object::Construct (Parameters ()); + p->Object::Construct (Attributes ()); return p; } @@ -687,7 +687,7 @@ Ptr CreateObject (T1 a1, T2 a2) { Ptr p = Ptr (new T (a1, a2), false); p->SetTypeId (T::GetTypeId ()); - p->Object::Construct (Parameters ()); + p->Object::Construct (Attributes ()); return p; } template @@ -737,10 +737,10 @@ CreateObjectWith (std::string n1, Attribute v1, std::string n2 = "", Attribute v2 = Attribute ()) { - Parameters parameters; - parameters.SetWithTid (T::GetTypeId (), n1, v1); - parameters.SetWithTid (T::GetTypeId (), n2, v2); - return CreateObject (parameters); + Attributes attributes; + attributes.SetWithTid (T::GetTypeId (), n1, v1); + attributes.SetWithTid (T::GetTypeId (), n2, v2); + return CreateObject (attributes); } } // namespace ns3 diff --git a/src/mobility/hierarchical-mobility-model.cc b/src/mobility/hierarchical-mobility-model.cc index 666b3b12b..a282692cd 100644 --- a/src/mobility/hierarchical-mobility-model.cc +++ b/src/mobility/hierarchical-mobility-model.cc @@ -30,11 +30,11 @@ HierarchicalMobilityModel::GetTypeId (void) static TypeId tid = TypeId ("HierarchicalMobilityModel") .SetParent () .AddConstructor () - .AddParameter ("child", "The child mobility model.", + .AddAttribute ("child", "The child mobility model.", Ptr (0), MakePtrAccessor (&HierarchicalMobilityModel::SetChild), MakePtrChecker ()) - .AddParameter ("parent", "The parent mobility model.", + .AddAttribute ("parent", "The parent mobility model.", Ptr (0), MakePtrAccessor (&HierarchicalMobilityModel::SetParent), MakePtrChecker ()) diff --git a/src/mobility/mobility-model.cc b/src/mobility/mobility-model.cc index 0d8dffee9..1ec9ebe64 100644 --- a/src/mobility/mobility-model.cc +++ b/src/mobility/mobility-model.cc @@ -28,13 +28,13 @@ MobilityModel::GetTypeId (void) { static TypeId tid = TypeId ("MobilityModel") .SetParent () - .AddParameter ("position", "The current position of the mobility model.", + .AddAttribute ("position", "The current position of the mobility model.", TypeId::ATTR_SGC, Vector (0.0, 0.0, 0.0), MakeVectorAccessor (&MobilityModel::SetPosition, &MobilityModel::GetPosition), MakeVectorChecker ()) - .AddParameter ("velocity", "The current velocity of the mobility model.", + .AddAttribute ("velocity", "The current velocity of the mobility model.", TypeId::ATTR_GET, Vector (0.0, 0.0, 0.0), // ignored initial value. MakeVectorAccessor (&MobilityModel::GetVelocity), diff --git a/src/mobility/position-allocator.cc b/src/mobility/position-allocator.cc index de999c16a..a409cb7db 100644 --- a/src/mobility/position-allocator.cc +++ b/src/mobility/position-allocator.cc @@ -53,27 +53,27 @@ GridPositionAllocator::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("GridWidth", "The number of objects layed out on a line.", + .AddAttribute ("GridWidth", "The number of objects layed out on a line.", Integer (10), MakeIntegerAccessor (&GridPositionAllocator::m_n), MakeIntegerChecker ()) - .AddParameter ("MinX", "The x coordinate where the grid starts.", + .AddAttribute ("MinX", "The x coordinate where the grid starts.", Double (1.0), MakeDoubleAccessor (&GridPositionAllocator::m_xMin), MakeDoubleChecker ()) - .AddParameter ("MinY", "The y coordinate where the grid starts.", + .AddAttribute ("MinY", "The y coordinate where the grid starts.", Double (0.0), MakeDoubleAccessor (&GridPositionAllocator::m_yMin), MakeDoubleChecker ()) - .AddParameter ("DeltaX", "The x space between objects.", + .AddAttribute ("DeltaX", "The x space between objects.", Double (1.0), MakeDoubleAccessor (&GridPositionAllocator::m_deltaX), MakeDoubleChecker ()) - .AddParameter ("DeltaY", "The y space between objects.", + .AddAttribute ("DeltaY", "The y space between objects.", Double (1.0), MakeDoubleAccessor (&GridPositionAllocator::m_deltaY), MakeDoubleChecker ()) - .AddParameter ("LayoutType", "The type of layout.", + .AddAttribute ("LayoutType", "The type of layout.", Enum (ROW_FIRST), MakeEnumAccessor (&GridPositionAllocator::m_layoutType), MakeEnumChecker (ROW_FIRST, "RowFirst", @@ -113,12 +113,12 @@ RandomRectanglePositionAllocator::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("X", + .AddAttribute ("X", "A random variable which represents the x coordinate of a position in a random rectangle.", UniformVariable (0.0, 1.0), MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_x), MakeRandomVariableChecker ()) - .AddParameter ("Y", + .AddAttribute ("Y", "A random variable which represents the y coordinate of a position in a random rectangle.", UniformVariable (0.0, 1.0), MakeRandomVariableAccessor (&RandomRectanglePositionAllocator::m_y), @@ -147,22 +147,22 @@ RandomDiscPositionAllocator::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("Theta", + .AddAttribute ("Theta", "A random variable which represents the angle (gradients) of a position in a random disc.", UniformVariable (0.0, 6.2830), MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_theta), MakeRandomVariableChecker ()) - .AddParameter ("Rho", + .AddAttribute ("Rho", "A random variable which represents the radius of a position in a random disc.", UniformVariable (0.0, 200.0), MakeRandomVariableAccessor (&RandomDiscPositionAllocator::m_rho), MakeRandomVariableChecker ()) - .AddParameter ("X", + .AddAttribute ("X", "The x coordinate of the center of the random position disc.", Double (0.0), MakeDoubleAccessor (&RandomDiscPositionAllocator::m_x), MakeDoubleChecker ()) - .AddParameter ("Y", + .AddAttribute ("Y", "The y coordinate of the center of the random position disc.", Double (0.0), MakeDoubleAccessor (&RandomDiscPositionAllocator::m_y), diff --git a/src/mobility/random-direction-2d-mobility-model.cc b/src/mobility/random-direction-2d-mobility-model.cc index 024892d81..a1238fd43 100644 --- a/src/mobility/random-direction-2d-mobility-model.cc +++ b/src/mobility/random-direction-2d-mobility-model.cc @@ -41,15 +41,15 @@ RandomDirection2dMobilityModel::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("bounds", "The 2d bounding area", + .AddAttribute ("bounds", "The 2d bounding area", Rectangle (-100, 100, -100, 100), MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds), MakeRectangleChecker ()) - .AddParameter ("speed", "A random variable to control the speed (m/s).", + .AddAttribute ("speed", "A random variable to control the speed (m/s).", UniformVariable (1.0, 2.0), MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_speed), MakeRandomVariableChecker ()) - .AddParameter ("pause", "A random variable to control the pause (s).", + .AddAttribute ("pause", "A random variable to control the pause (s).", ConstantVariable (2.0), MakeRandomVariableAccessor (&RandomDirection2dMobilityModel::m_pause), MakeRandomVariableChecker ()) diff --git a/src/mobility/random-walk-2d-mobility-model.cc b/src/mobility/random-walk-2d-mobility-model.cc index 97dc88374..f74a6558b 100644 --- a/src/mobility/random-walk-2d-mobility-model.cc +++ b/src/mobility/random-walk-2d-mobility-model.cc @@ -37,34 +37,34 @@ RandomWalk2dMobilityModel::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("bounds", + .AddAttribute ("bounds", "Bounds of the area to cruise.", Rectangle (0.0, 0.0, 100.0, 100.0), MakeRectangleAccessor (&RandomWalk2dMobilityModel::m_bounds), MakeRectangleChecker ()) - .AddParameter ("time", + .AddAttribute ("time", "Change current direction and speed after moving for this delay.", Seconds (1.0), MakeTimeAccessor (&RandomWalk2dMobilityModel::m_modeTime), MakeTimeChecker ()) - .AddParameter ("distance", + .AddAttribute ("distance", "Change current direction and speed after moving for this distance.", Seconds (1.0), MakeTimeAccessor (&RandomWalk2dMobilityModel::m_modeTime), MakeTimeChecker ()) - .AddParameter ("mode", + .AddAttribute ("mode", "The mode indicates the condition used to " "change the current speed and direction", Enum (RandomWalk2dMobilityModel::MODE_DISTANCE), MakeEnumAccessor (&RandomWalk2dMobilityModel::m_mode), MakeEnumChecker (RandomWalk2dMobilityModel::MODE_DISTANCE, "Distance", RandomWalk2dMobilityModel::MODE_TIME, "Time")) - .AddParameter ("direction", + .AddAttribute ("direction", "A random variable used to pick the direction (gradients).", UniformVariable (0.0, 6.283184), MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_direction), MakeRandomVariableChecker ()) - .AddParameter ("speed", + .AddAttribute ("speed", "A random variable used to pick the speed (m/s).", UniformVariable (2.0, 4.0), MakeRandomVariableAccessor (&RandomWalk2dMobilityModel::m_speed), diff --git a/src/mobility/random-waypoint-mobility-model.cc b/src/mobility/random-waypoint-mobility-model.cc index 84043ed2a..70a21f5d1 100644 --- a/src/mobility/random-waypoint-mobility-model.cc +++ b/src/mobility/random-waypoint-mobility-model.cc @@ -36,17 +36,17 @@ RandomWaypointMobilityModel::GetTypeId (void) .SetParent () .SetGroupName ("Mobility") .AddConstructor () - .AddParameter ("speed", + .AddAttribute ("speed", "A random variable used to pick the speed of a random waypoint model.", UniformVariable (0.3, 0.7), MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_speed), MakeRandomVariableChecker ()) - .AddParameter ("pause", + .AddAttribute ("pause", "A random variable used to pick the pause of a random waypoint model.", ConstantVariable (2.0), MakeRandomVariableAccessor (&RandomWaypointMobilityModel::m_pause), MakeRandomVariableChecker ()) - .AddParameter ("position", + .AddAttribute ("position", "The position model used to pick a destination point.", Ptr (0), MakePtrAccessor (&RandomWaypointMobilityModel::m_position), diff --git a/src/node/drop-tail-queue.cc b/src/node/drop-tail-queue.cc index 803cc23d9..ef285f15a 100644 --- a/src/node/drop-tail-queue.cc +++ b/src/node/drop-tail-queue.cc @@ -32,7 +32,7 @@ TypeId DropTailQueue::GetTypeId (void) static TypeId tid = TypeId ("DropTailQueue") .SetParent () .AddConstructor () - .AddParameter ("MaxPackets", "The maximum number of packets accepted by this DropTailQueue.", + .AddAttribute ("MaxPackets", "The maximum number of packets accepted by this DropTailQueue.", Uinteger (100), MakeUintegerAccessor (&DropTailQueue::m_maxPackets), MakeUintegerChecker ())