From 6de5685111f34a59216ffb46a3c3b2ce55cbf34a Mon Sep 17 00:00:00 2001 From: Jaume Nin Date: Mon, 24 Oct 2011 18:08:24 +0200 Subject: [PATCH] fixed problems with ns-3-dev ObjectMap implementation --- .../model/attribute-default-iterator.cc | 13 +- src/config-store/model/attribute-iterator.cc | 391 +++++++++++------- src/config-store/model/attribute-iterator.h | 20 +- src/config-store/model/model-node-creator.cc | 139 ++++--- src/config-store/model/model-node-creator.h | 52 ++- src/core/model/config.cc | 51 ++- src/core/model/object-map.h | 38 +- src/core/model/object-ptr-map.cc | 121 ++++++ src/core/model/object-ptr-map.h | 192 +++++++++ src/core/model/object-ptr-vector.cc | 114 +++++ src/core/model/object-ptr-vector.h | 192 +++++++++ src/core/model/object-vector.h | 12 +- src/core/wscript | 6 +- src/lte/examples/lena-rlc-calculator.cc | 2 +- utils/print-introspected-doxygen.cc | 2 +- 15 files changed, 1083 insertions(+), 262 deletions(-) create mode 100644 src/core/model/object-ptr-map.cc create mode 100644 src/core/model/object-ptr-map.h create mode 100644 src/core/model/object-ptr-vector.cc create mode 100644 src/core/model/object-ptr-vector.h diff --git a/src/config-store/model/attribute-default-iterator.cc b/src/config-store/model/attribute-default-iterator.cc index d31024605..e406de716 100644 --- a/src/config-store/model/attribute-default-iterator.cc +++ b/src/config-store/model/attribute-default-iterator.cc @@ -22,7 +22,8 @@ #include "ns3/pointer.h" #include "ns3/global-value.h" #include "ns3/string.h" -#include "ns3/object-ptr-container.h" +#include "ns3/object-ptr-vector.h" +#include "ns3/object-ptr-map.h" namespace ns3 { @@ -70,19 +71,25 @@ AttributeDefaultIterator::Iterate (void) //No value, check next attribute continue; } - Ptr vector = DynamicCast (info.initialValue); + Ptr vector = DynamicCast (info.initialValue); if (vector != 0) { //a vector value, won't take it continue; } + Ptr map = DynamicCast (info.initialValue); + if (map != 0) + { + //a map value, won't take it + continue; + } Ptr pointer = DynamicCast (info.initialValue); if (pointer != 0) { //pointer value, won't take it continue; } - //We take only values, no pointers or vectors + //We take only values, no pointers or vectors or maps if (!calledStart) { StartVisitTypeId (tid.GetName ()); diff --git a/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index f0559c5f3..2d9c25d93 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -15,20 +15,18 @@ * * Author: Mathieu Lacage */ - + #include "attribute-iterator.h" #include "ns3/config.h" #include "ns3/log.h" #include "ns3/pointer.h" -#include "ns3/object-ptr-container.h" #include "ns3/string.h" #include - NS_LOG_COMPONENT_DEFINE ("AttributeIterator"); -namespace ns3 { - +namespace ns3 +{ AttributeIterator::AttributeIterator () { @@ -38,246 +36,331 @@ AttributeIterator::~AttributeIterator () { } -void +void AttributeIterator::Iterate (void) { - for (uint32_t i = 0; i < Config::GetRootNamespaceObjectN (); ++i) - { - Ptr object = Config::GetRootNamespaceObject (i); - StartVisitObject (object); - DoIterate (object); - EndVisitObject (); - } - NS_ASSERT (m_currentPath.empty ()); - NS_ASSERT (m_examined.empty ()); + for (uint32_t i = 0; i < Config::GetRootNamespaceObjectN(); ++i) + { + Ptr < Object > object = Config::GetRootNamespaceObject(i); + StartVisitObject ( object); + DoIterate(object); + EndVisitObject(); + } + NS_ASSERT(m_currentPath.empty()); + NS_ASSERT(m_examined.empty()); } bool AttributeIterator::IsExamined (Ptr object) { - for (uint32_t i = 0; i < m_examined.size (); ++i) + for (uint32_t i = 0; i < m_examined.size(); ++i) + { + if (object == m_examined[i]) { - if (object == m_examined[i]) - { - return true; - } + return true; } + } return false; } - std::string AttributeIterator::GetCurrentPath (std::string attr) const { std::ostringstream oss; - for (uint32_t i = 0; i < m_currentPath.size (); ++i) - { - oss << "/" << m_currentPath[i]; - } + for (uint32_t i = 0; i < m_currentPath.size(); ++i) + { + oss << "/" << m_currentPath[i]; + } if (attr != "") - { - oss << "/" << attr; - } - return oss.str (); + { + oss << "/" << attr; + } + return oss.str(); } std::string AttributeIterator::GetCurrentPath (void) const { std::ostringstream oss; - for (uint32_t i = 0; i < m_currentPath.size (); ++i) - { - oss << "/" << m_currentPath[i]; - } - return oss.str (); + for (uint32_t i = 0; i < m_currentPath.size(); ++i) + { + oss << "/" << m_currentPath[i]; + } + return oss.str(); } -void +void AttributeIterator::DoStartVisitObject (Ptr object) { } -void +void AttributeIterator::DoEndVisitObject (void) { } -void -AttributeIterator::DoStartVisitPointerAttribute (Ptr object, std::string name, Ptr item) +void +AttributeIterator::DoStartVisitPointerAttribute (Ptr object, + std::string name, Ptr item) { } -void +void AttributeIterator::DoEndVisitPointerAttribute (void) { } -void -AttributeIterator::DoStartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrContainerValue &vector) +void +AttributeIterator::DoStartVisitArrayAttribute (Ptr object, + std::string name, const ObjectPtrVectorValue &vector) { } -void +void AttributeIterator::DoEndVisitArrayAttribute (void) { } -void -AttributeIterator::DoStartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr item) +void +AttributeIterator::DoStartVisitArrayItem (const ObjectPtrVectorValue &vector, + uint32_t index, Ptr item) { } -void +void AttributeIterator::DoEndVisitArrayItem (void) { } -void +void +AttributeIterator::DoStartVisitMapAttribute (Ptr object, + std::string name, const ObjectPtrMapValue &map) +{ + +} +void +AttributeIterator::DoEndVisitMapAttribute (void) +{ + +} + +void +AttributeIterator::DoStartVisitMapItem (const ObjectPtrMapValue &vector, + uint32_t index, Ptr item) +{ + +} + +void +AttributeIterator::DoEndVisitMapItem (void) +{ + +} + +void AttributeIterator::VisitAttribute (Ptr object, std::string name) { - m_currentPath.push_back (name); - DoVisitAttribute (object, name); - m_currentPath.pop_back (); + m_currentPath.push_back(name); + DoVisitAttribute(object, name); + m_currentPath.pop_back(); } -void +void AttributeIterator::StartVisitObject (Ptr object) { - m_currentPath.push_back ("$" + object->GetInstanceTypeId ().GetName ()); - DoStartVisitObject (object); + m_currentPath.push_back("$" + object->GetInstanceTypeId().GetName()); + DoStartVisitObject(object); } -void +void AttributeIterator::EndVisitObject (void) { - m_currentPath.pop_back (); - DoEndVisitObject (); + m_currentPath.pop_back(); + DoEndVisitObject(); } -void -AttributeIterator::StartVisitPointerAttribute (Ptr object, std::string name, Ptr value) +void +AttributeIterator::StartVisitPointerAttribute (Ptr object, + std::string name, Ptr value) { - m_currentPath.push_back (name); - m_currentPath.push_back ("$" + value->GetInstanceTypeId ().GetName ()); - DoStartVisitPointerAttribute (object, name, value); + m_currentPath.push_back(name); + m_currentPath.push_back("$" + value->GetInstanceTypeId().GetName()); + DoStartVisitPointerAttribute(object, name, value); } -void +void AttributeIterator::EndVisitPointerAttribute (void) { - m_currentPath.pop_back (); - m_currentPath.pop_back (); - DoEndVisitPointerAttribute (); + m_currentPath.pop_back(); + m_currentPath.pop_back(); + DoEndVisitPointerAttribute(); } -void -AttributeIterator::StartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrContainerValue &vector) +void +AttributeIterator::StartVisitArrayAttribute (Ptr object, + std::string name, const ObjectPtrVectorValue &vector) { - m_currentPath.push_back (name); - DoStartVisitArrayAttribute (object, name, vector); + m_currentPath.push_back(name); + DoStartVisitArrayAttribute(object, name, vector); } -void +void AttributeIterator::EndVisitArrayAttribute (void) { - m_currentPath.pop_back (); - DoEndVisitArrayAttribute (); + m_currentPath.pop_back(); + DoEndVisitArrayAttribute(); } -void -AttributeIterator::StartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr item) +void +AttributeIterator::StartVisitArrayItem (const ObjectPtrVectorValue &vector, + uint32_t index, Ptr item) { std::ostringstream oss; oss << index; - m_currentPath.push_back (oss.str ()); - m_currentPath.push_back ("$" + item->GetInstanceTypeId ().GetName ()); - DoStartVisitArrayItem (vector, index, item); + m_currentPath.push_back(oss.str()); + m_currentPath.push_back("$" + item->GetInstanceTypeId().GetName()); + DoStartVisitArrayItem(vector, index, item); } -void +void AttributeIterator::EndVisitArrayItem (void) { - m_currentPath.pop_back (); - m_currentPath.pop_back (); - DoEndVisitArrayItem (); + m_currentPath.pop_back(); + m_currentPath.pop_back(); + DoEndVisitArrayItem(); } +void +AttributeIterator::StartVisitMapAttribute (Ptr object, + std::string name, const ObjectPtrMapValue &map) +{ + m_currentPath.push_back(name); + DoStartVisitMapAttribute(object, name, map); + NS_LOG_INFO(this << GetCurrentPath()); +} + +void +AttributeIterator::EndVisitMapAttribute (void) +{ + m_currentPath.pop_back(); + DoEndVisitMapAttribute(); +} + +void +AttributeIterator::StartVisitMapItem (const ObjectPtrMapValue &map, + uint32_t index, Ptr item) +{ + std::ostringstream oss; + oss << index; + m_currentPath.push_back(oss.str()); + m_currentPath.push_back("$" + item->GetInstanceTypeId().GetName()); + DoStartVisitMapItem(map, index, item); + NS_LOG_INFO(this << GetCurrentPath()); +} + +void +AttributeIterator::EndVisitMapItem (void) +{ + m_currentPath.pop_back(); + m_currentPath.pop_back(); + DoEndVisitMapItem(); +} void AttributeIterator::DoIterate (Ptr object) { - if (IsExamined (object)) - { - return; - } + if (IsExamined(object)) + { + return; + } TypeId tid; - for (tid = object->GetInstanceTypeId (); tid.HasParent (); tid = tid.GetParent ()) + for (tid = object->GetInstanceTypeId(); tid.HasParent(); tid + = tid.GetParent()) + { + NS_LOG_DEBUG("store " << tid.GetName()); + for (uint32_t i = 0; i < tid.GetAttributeN(); ++i) { - NS_LOG_DEBUG ("store " << tid.GetName ()); - for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) + struct TypeId::AttributeInformation info = tid.GetAttribute(i); + const PointerChecker *ptrChecker = + dynamic_cast (PeekPointer(info.checker)); + if (ptrChecker != 0) + { + NS_LOG_DEBUG("pointer attribute " << info.name); + PointerValue ptr; + object->GetAttribute(info.name, ptr); + Ptr < Object > tmp = ptr.Get (); + if (tmp != 0) { - struct TypeId::AttributeInformation info = tid.GetAttribute(i); - const PointerChecker *ptrChecker = dynamic_cast (PeekPointer (info.checker)); - if (ptrChecker != 0) - { - NS_LOG_DEBUG ("pointer attribute " << info.name); - PointerValue ptr; - object->GetAttribute (info.name, ptr); - Ptr tmp = ptr.Get (); - if (tmp != 0) - { - StartVisitPointerAttribute (object, info.name, - tmp); - m_examined.push_back (object); - DoIterate (tmp); - m_examined.pop_back (); - EndVisitPointerAttribute (); - } - continue; - } - // attempt to cast to an object vector. - const ObjectPtrContainerChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); - if (vectorChecker != 0) - { - NS_LOG_DEBUG ("vector attribute " << info.name); - ObjectPtrContainerValue vector; - object->GetAttribute (info.name, vector); - StartVisitArrayAttribute (object, info.name, vector); - for (uint32_t j = 0; j < vector.GetN (); ++j) - { - NS_LOG_DEBUG ("vector attribute item " << j); - Ptr tmp = vector.Get (j); - StartVisitArrayItem (vector, j, tmp); - m_examined.push_back (object); - DoIterate (tmp); - m_examined.pop_back (); - EndVisitArrayItem (); - } - EndVisitArrayAttribute (); - continue; - } - if ((info.flags & TypeId::ATTR_GET) && info.accessor->HasGetter () && - (info.flags & TypeId::ATTR_SET) && info.accessor->HasSetter ()) - { - VisitAttribute (object, info.name); - } - else - { - NS_LOG_DEBUG ("could not store " << info.name); - } + StartVisitPointerAttribute(object, info.name, tmp); + m_examined.push_back(object); + DoIterate ( tmp); + m_examined.pop_back(); + EndVisitPointerAttribute(); } + continue; + } + // attempt to cast to an object vector. + const ObjectPtrVectorChecker *vectorChecker =dynamic_cast (PeekPointer( + info.checker)); + if (vectorChecker != 0) + { + NS_LOG_DEBUG("vector attribute " << info.name); + ObjectPtrVectorValue vector; + object->GetAttribute(info.name, vector); + StartVisitArrayAttribute(object, info.name, vector); + for (uint32_t j = 0; j < vector.GetN(); ++j) + { + NS_LOG_DEBUG("vector attribute item " << j); + Ptr < Object > tmp = vector.Get(j); + StartVisitArrayItem(vector, j, tmp); + m_examined.push_back(object); + DoIterate ( tmp); + m_examined.pop_back(); + EndVisitArrayItem(); + } + EndVisitArrayAttribute(); + continue; + } + // attempt to cast to an object map. + const ObjectPtrMapChecker *mapChecker = dynamic_cast (PeekPointer(info.checker)); + if (mapChecker != 0) + { + ObjectPtrMapValue map; + object->GetAttribute(info.name, map); + StartVisitMapAttribute(object, info.name, map); + for (ObjectPtrMapValue::Iterator it = map.Begin(); it != map.End(); it++) + { + NS_LOG_DEBUG("map attribute index " << (*it).first << " item " << (*it).second); + StartVisitMapItem(map, (*it).first, (*it).second); + m_examined.push_back(object); + DoIterate((*it).second); + m_examined.pop_back(); + EndVisitMapItem(); + } + EndVisitMapAttribute(); + continue; + } + if ((info.flags & TypeId::ATTR_GET) && info.accessor->HasGetter() + && (info.flags & TypeId::ATTR_SET) && info.accessor->HasSetter()) + { + VisitAttribute(object, info.name); + } + else + { + NS_LOG_DEBUG("could not store " << info.name); + } } - Object::AggregateIterator iter = object->GetAggregateIterator (); + } + Object::AggregateIterator iter = object->GetAggregateIterator(); bool recursiveAggregate = false; - while (iter.HasNext ()) + while (iter.HasNext()) + { + Ptr tmp = iter.Next(); + if (IsExamined(tmp)) { - Ptr tmp = iter.Next (); - if (IsExamined (tmp)) - { - recursiveAggregate = true; - } + recursiveAggregate = true; } + } if (!recursiveAggregate) + { + iter = object->GetAggregateIterator(); + while (iter.HasNext()) { - iter = object->GetAggregateIterator (); - while (iter.HasNext ()) - { - Ptr tmp = const_cast (PeekPointer (iter.Next ())); - StartVisitObject (tmp); - m_examined.push_back (object); - DoIterate (tmp); - m_examined.pop_back (); - EndVisitObject (); - } + Ptr < Object > tmp = const_cast (PeekPointer(iter.Next())); + StartVisitObject ( tmp); + m_examined.push_back(object); + DoIterate(tmp); + m_examined.pop_back(); + EndVisitObject(); } + } } - } // namespace ns3 diff --git a/src/config-store/model/attribute-iterator.h b/src/config-store/model/attribute-iterator.h index 5821651a8..3fb35c7bc 100644 --- a/src/config-store/model/attribute-iterator.h +++ b/src/config-store/model/attribute-iterator.h @@ -21,7 +21,8 @@ #include "ns3/ptr.h" #include "ns3/object.h" -#include "ns3/object-ptr-container.h" +#include "ns3/object-ptr-vector.h" +#include "ns3/object-ptr-map.h" #include namespace ns3 { @@ -46,10 +47,14 @@ private: virtual void DoEndVisitObject (void); virtual void DoStartVisitPointerAttribute (Ptr object, std::string name, Ptr value); virtual void DoEndVisitPointerAttribute (void); - virtual void DoStartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrContainerValue &vector); + virtual void DoStartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrVectorValue &vector); virtual void DoEndVisitArrayAttribute (void); - virtual void DoStartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr item); + virtual void DoStartVisitArrayItem (const ObjectPtrVectorValue &vector, uint32_t index, Ptr item); virtual void DoEndVisitArrayItem (void); + virtual void DoStartVisitMapAttribute (Ptr object, std::string name, const ObjectPtrMapValue &map); + virtual void DoEndVisitMapAttribute (void); + virtual void DoStartVisitMapItem (const ObjectPtrMapValue &vector, uint32_t index, Ptr item); + virtual void DoEndVisitMapItem (void); void DoIterate (Ptr object); bool IsExamined (Ptr object); @@ -60,11 +65,14 @@ private: void EndVisitObject (void); void StartVisitPointerAttribute (Ptr object, std::string name, Ptr value); void EndVisitPointerAttribute (void); - void StartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrContainerValue &vector); + void StartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrVectorValue &vector); void EndVisitArrayAttribute (void); - void StartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr item); + void StartVisitArrayItem (const ObjectPtrVectorValue &vector, uint32_t index, Ptr item); void EndVisitArrayItem (void); - + void StartVisitMapAttribute (Ptr object, std::string name, const ObjectPtrMapValue &map); + void EndVisitMapAttribute (void); + void StartVisitMapItem (const ObjectPtrMapValue &vector, uint32_t index, Ptr item); + void EndVisitMapItem (void); std::vector > m_examined; std::vector m_currentPath; diff --git a/src/config-store/model/model-node-creator.cc b/src/config-store/model/model-node-creator.cc index ebb56e45c..f602bde33 100644 --- a/src/config-store/model/model-node-creator.cc +++ b/src/config-store/model/model-node-creator.cc @@ -16,9 +16,10 @@ * Authors: Faker Moatamri * Mathieu Lacage */ - + #include "model-node-creator.h" -namespace ns3 { +namespace ns3 +{ ModelCreator::ModelCreator () { @@ -28,103 +29,141 @@ void ModelCreator::Build (GtkTreeStore *treestore) { m_treestore = treestore; - m_iters.push_back (0); + m_iters.push_back(0); //this function will go through all the objects and call on them //DoStartVisitObject, DoIterate and DoEndVisitObject - Iterate (); - NS_ASSERT (m_iters.size () == 1); + Iterate(); + NS_ASSERT(m_iters.size() == 1); } - void ModelCreator::Add (ModelNode *node) { - GtkTreeIter *parent = m_iters.back (); - GtkTreeIter *current = g_new (GtkTreeIter, 1); - gtk_tree_store_append (m_treestore, current, parent); - gtk_tree_store_set (m_treestore, current, - COL_NODE, node, -1); - m_iters.push_back (current); + GtkTreeIter *parent = m_iters.back(); + GtkTreeIter *current = g_new(GtkTreeIter, 1); + gtk_tree_store_append(m_treestore, current, parent); + gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1); + m_iters.push_back(current); } void ModelCreator::Remove (void) { - GtkTreeIter *iter = m_iters.back (); - g_free (iter); - m_iters.pop_back (); + GtkTreeIter *iter = m_iters.back(); + g_free(iter); + m_iters.pop_back(); } -void +void ModelCreator::DoVisitAttribute (Ptr object, std::string name) { - ModelNode *node = new ModelNode (); + ModelNode *node = new ModelNode(); node->type = ModelNode::NODE_ATTRIBUTE; node->object = object; node->name = name; - Add (node); - Remove (); + Add(node); + Remove(); } -void +void ModelCreator::DoStartVisitObject (Ptr object) { - ModelNode *node = new ModelNode (); + ModelNode *node = new ModelNode(); node->type = ModelNode::NODE_OBJECT; node->object = object; - Add (node); + Add(node); } -void +void ModelCreator::DoEndVisitObject (void) { - Remove (); + Remove(); } -void -ModelCreator::DoStartVisitPointerAttribute (Ptr object, std::string name, Ptr value) +void +ModelCreator::DoStartVisitPointerAttribute (Ptr object, + std::string name, Ptr value) { - ModelNode *node = new ModelNode (); + ModelNode *node = new ModelNode(); node->type = ModelNode::NODE_POINTER; node->object = object; node->name = name; - Add (node); + Add(node); } -void +void ModelCreator::DoEndVisitPointerAttribute (void) { - Remove (); + Remove(); } -void -ModelCreator::DoStartVisitArrayAttribute (Ptr object, std::string name, const ObjectPtrContainerValue &vector) +void +ModelCreator::DoStartVisitArrayAttribute (Ptr object, std::string name, + const ObjectPtrVectorValue &vector) { - ModelNode *node = new ModelNode (); + ModelNode *node = new ModelNode(); node->type = ModelNode::NODE_VECTOR; node->object = object; node->name = name; - Add (node); + Add(node); } -void +void ModelCreator::DoEndVisitArrayAttribute (void) { - Remove (); + Remove(); } -void -ModelCreator::DoStartVisitArrayItem (const ObjectPtrContainerValue &vector, uint32_t index, Ptr item) +void +ModelCreator::DoStartVisitArrayItem (const ObjectPtrVectorValue &vector, + uint32_t index, Ptr item) { - GtkTreeIter *parent = m_iters.back (); - GtkTreeIter *current = g_new (GtkTreeIter, 1); - ModelNode *node = new ModelNode (); + GtkTreeIter *parent = m_iters.back(); + GtkTreeIter *current = g_new(GtkTreeIter, 1); + ModelNode *node = new ModelNode(); node->type = ModelNode::NODE_VECTOR_ITEM; node->object = item; node->index = index; - gtk_tree_store_append (m_treestore, current, parent); - gtk_tree_store_set (m_treestore, current, - COL_NODE, node, - -1); - m_iters.push_back (current); + gtk_tree_store_append(m_treestore, current, parent); + gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1); + m_iters.push_back(current); } -void +void ModelCreator::DoEndVisitArrayItem (void) { - GtkTreeIter *iter = m_iters.back (); - g_free (iter); - m_iters.pop_back (); + GtkTreeIter *iter = m_iters.back(); + g_free(iter); + m_iters.pop_back(); } + +void +ModelCreator::DoStartVisitMapAttribute (Ptr object, std::string name, + const ObjectPtrMapValue &map) +{ + ModelNode *node = new ModelNode(); + node->type = ModelNode::NODE_VECTOR; + node->object = object; + node->name = name; + Add(node); +} +void +ModelCreator::DoEndVisitMapAttribute (void) +{ + Remove(); +} +void +ModelCreator::DoStartVisitMapItem (const ObjectPtrMapValue &map, uint32_t index, + Ptr item) +{ + GtkTreeIter *parent = m_iters.back(); + GtkTreeIter *current = g_new(GtkTreeIter, 1); + ModelNode *node = new ModelNode(); + node->type = ModelNode::NODE_VECTOR_ITEM; + node->object = item; + node->index = index; + gtk_tree_store_append(m_treestore, current, parent); + gtk_tree_store_set(m_treestore, current, COL_NODE, node, -1); + m_iters.push_back(current); +} + +void +ModelCreator::DoEndVisitMapItem (void) +{ + GtkTreeIter *iter = m_iters.back(); + g_free(iter); + m_iters.pop_back(); +} + } //end namespace ns3 diff --git a/src/config-store/model/model-node-creator.h b/src/config-store/model/model-node-creator.h index 822983b40..cc58df0e2 100644 --- a/src/config-store/model/model-node-creator.h +++ b/src/config-store/model/model-node-creator.h @@ -56,21 +56,45 @@ class ModelCreator : public AttributeIterator public: ModelCreator (); - void Build (GtkTreeStore *treestore); + void + Build (GtkTreeStore *treestore); private: - virtual void DoVisitAttribute (Ptr object, std::string name); - virtual void DoStartVisitObject (Ptr object); - virtual void DoEndVisitObject (void); - virtual void DoStartVisitPointerAttribute (Ptr object, std::string name, Ptr value); - virtual void DoEndVisitPointerAttribute (void); - virtual void DoStartVisitArrayAttribute (Ptr object, std::string name, - const ObjectPtrContainerValue &vector); - virtual void DoEndVisitArrayAttribute (void); - virtual void DoStartVisitArrayItem (const ObjectPtrContainerValue &vector, - uint32_t index, Ptr item); - virtual void DoEndVisitArrayItem (void); - void Add (ModelNode *node); - void Remove (void); + virtual void + DoVisitAttribute (Ptr object, std::string name); + virtual void + DoStartVisitObject (Ptr object); + virtual void + DoEndVisitObject (void); + virtual void + DoStartVisitPointerAttribute (Ptr object, std::string name, + Ptr value); + virtual void + DoEndVisitPointerAttribute (void); + virtual void + DoStartVisitArrayAttribute (Ptr object, std::string name, + const ObjectPtrVectorValue &vector); + virtual void + DoEndVisitArrayAttribute (void); + virtual void + DoStartVisitArrayItem (const ObjectPtrVectorValue &vector, uint32_t index, + Ptr item); + virtual void + DoEndVisitArrayItem (void); + virtual void + DoStartVisitMapAttribute (Ptr object, std::string name, + const ObjectPtrMapValue &map); + virtual void + DoEndVisitMapAttribute (void); + virtual void + DoStartVisitMapItem (const ObjectPtrMapValue &vector, uint32_t index, + Ptr item); + virtual void + DoEndVisitMapItem (void); + + void + Add (ModelNode *node); + void + Remove (void); GtkTreeStore *m_treestore; std::vector m_iters; diff --git a/src/core/model/config.cc b/src/core/model/config.cc index 89ba1d364..166474005 100644 --- a/src/core/model/config.cc +++ b/src/core/model/config.cc @@ -21,7 +21,8 @@ #include "singleton.h" #include "object.h" #include "global-value.h" -#include "object-ptr-container.h" +#include "object-ptr-vector.h" +#include "object-ptr-map.h" #include "names.h" #include "pointer.h" #include "log.h" @@ -226,7 +227,8 @@ public: private: void Canonicalize (void); void DoResolve (std::string path, Ptr root); - void DoArrayResolve (std::string path, const ObjectPtrContainerValue &vector); + void DoArrayResolve (std::string path, const ObjectPtrVectorValue &vector); + void DoMapResolve (std::string path, const ObjectPtrMapValue &map); void DoResolveOne (Ptr object); std::string GetResolvedPath (void) const; virtual void DoOne (Ptr object, std::string path) = 0; @@ -403,23 +405,34 @@ Resolver::DoResolve (std::string path, Ptr root) m_workStack.pop_back (); } // attempt to cast to an object vector. - const ObjectPtrContainerChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); + const ObjectPtrVectorChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); if (vectorChecker != 0) { NS_LOG_DEBUG ("GetAttribute(vector)="< +#include #include "object.h" #include "ptr.h" #include "attribute.h" -#include "object-ptr-container.h" +#include "object-ptr-map.h" namespace ns3 { -typedef ObjectPtrContainerValue ObjectMapValue; +typedef ObjectPtrMapValue ObjectMapValue; template Ptr @@ -39,23 +39,19 @@ Ptr MakeObjectMapChecker (void); template Ptr -MakeObjectVectorAccessor (Ptr (T::*get)(INDEX) const, +MakeObjectMapAccessor (Ptr (T::*get)(INDEX) const, INDEX (T::*getN)(void) const); template Ptr -MakeObjectVectorAccessor (INDEX (T::*getN)(void) const, +MakeObjectMapAccessor (INDEX (T::*getN)(void) const, Ptr (T::*get)(INDEX) const); -} // namespace ns3 - -namespace ns3 { - template Ptr -MakeObjectMapAccessor (U T::*memberVector) +MakeObjectMapAccessor (U T::*memberMap) { - struct MemberStdContainer : public ObjectPtrContainerAccessor + struct MemberStdContainer : public ObjectPtrMapAccessor { virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { const T *obj = dynamic_cast (object); @@ -63,18 +59,20 @@ MakeObjectMapAccessor (U T::*memberVector) { return false; } - *n = (obj->*m_memberVector).size (); + + *n = (obj->*m_memberMap).size (); return true; } - virtual Ptr DoGet (const ObjectBase *object, uint32_t i) const { + virtual Ptr DoGet (const ObjectBase *object, uint32_t i, uint32_t *index) const { const T *obj = static_cast (object); - typename U::const_iterator begin = (obj->*m_memberVector).begin (); - typename U::const_iterator end = (obj->*m_memberVector).end (); + typename U::const_iterator begin = (obj->*m_memberMap).begin (); + typename U::const_iterator end = (obj->*m_memberMap).end (); uint32_t k = 0; for (typename U::const_iterator j = begin; j != end; j++, k++) { if (k == i) { + *index = (*j).first; return (*j).second; break; } @@ -83,16 +81,16 @@ MakeObjectMapAccessor (U T::*memberVector) // quiet compiler. return 0; } - U T::*m_memberVector; + U T::*m_memberMap; } *spec = new MemberStdContainer (); - spec->m_memberVector = memberVector; + spec->m_memberMap = memberMap; return Ptr (spec, false); } template Ptr MakeObjectMapChecker (void) { - return MakeObjectPtrContainerChecker (); + return MakeObjectPtrMapChecker (); } template @@ -100,7 +98,7 @@ Ptr MakeObjectMapAccessor (Ptr (T::*get)(INDEX) const, INDEX (T::*getN)(void) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrMapAccessor(get, getN); } template @@ -108,7 +106,7 @@ Ptr MakeObjectMapAccessor (INDEX (T::*getN)(void) const, Ptr (T::*get)(INDEX) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrMapAccessor(get, getN); } diff --git a/src/core/model/object-ptr-map.cc b/src/core/model/object-ptr-map.cc new file mode 100644 index 000000000..532ffd0f9 --- /dev/null +++ b/src/core/model/object-ptr-map.cc @@ -0,0 +1,121 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA, Mathieu Lacage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Jaume Nin , Mathieu Lacage + */ +#include "object-ptr-map.h" + +namespace ns3 +{ + +ObjectPtrMapValue::ObjectPtrMapValue () +{ +} + +ObjectPtrMapValue::Iterator +ObjectPtrMapValue::Begin (void) const +{ + return m_objects.begin(); +} +ObjectPtrMapValue::Iterator +ObjectPtrMapValue::End (void) const +{ + return m_objects.end(); +} +uint32_t +ObjectPtrMapValue::GetN (void) const +{ + return m_objects.size(); +} +Ptr +ObjectPtrMapValue::Get (uint32_t i) const +{ + return m_objects.find(i)->second; +} + +Ptr +ObjectPtrMapValue::Copy (void) const +{ + return ns3::Create(*this); +} +std::string +ObjectPtrMapValue::SerializeToString (Ptr checker) const +{ + std::ostringstream oss; + Iterator it; + for (it = m_objects.begin(); it != m_objects.end(); ++it) + { + oss << (*it).second; + if (it != m_objects.end()) + { + oss << " "; + } + } + return oss.str(); +} + +bool +ObjectPtrMapValue::DeserializeFromString (std::string value, + Ptr checker) +{ + NS_FATAL_ERROR("cannot deserialize a map of object pointers."); + return true; +} + +bool +ObjectPtrMapAccessor::Set (ObjectBase * object, const AttributeValue & value) const +{ + // not allowed. + return false; +} +bool +ObjectPtrMapAccessor::Get (const ObjectBase * object, AttributeValue &value) const +{ + ObjectPtrMapValue *v = dynamic_cast (&value); + if (v == 0) + { + return false; + } + v->m_objects.clear(); + uint32_t n; + bool ok = DoGetN(object, &n); + if (!ok) + { + return false; + } + for (uint32_t i = 0; i < n; i++) + { + + uint32_t k; + Ptr < Object > element = DoGet(object, i, &k); + v->m_objects.insert(std::pair >(k, element)); + } + return true; +} + +bool +ObjectPtrMapAccessor::HasGetter (void) const +{ + return true; +} +bool +ObjectPtrMapAccessor::HasSetter (void) const +{ + return false; +} + +} // name diff --git a/src/core/model/object-ptr-map.h b/src/core/model/object-ptr-map.h new file mode 100644 index 000000000..2acad8786 --- /dev/null +++ b/src/core/model/object-ptr-map.h @@ -0,0 +1,192 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA, Mathieu Lacage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathieu Lacage + */ +#ifndef OBJECT_PTR_MAP_H +#define OBJECT_PTR_MAP_H + +#include +#include "object.h" +#include "ptr.h" +#include "attribute.h" + +namespace ns3 { + +/** + * \ingroup object + * + * \brief contain a map of ns3::Object pointers. + * + * This class it used to get attribute access to an array of + * ns3::Object pointers. + */ +class ObjectPtrMapValue : public AttributeValue +{ +public: + typedef std::map >::const_iterator Iterator; + + ObjectPtrMapValue (); + + /** + * \returns an iterator to the first object contained in this map + */ + Iterator Begin (void) const; + /** + * \returns an iterator to the last object contained in this map + */ + Iterator End (void) const; + /** + * \returns the number of objects contained in this map. + */ + uint32_t GetN (void) const; + /** + * \param i the index of the requested object. + * \returns the requested object + */ + Ptr Get (uint32_t i) const; + + virtual Ptr Copy (void) const; + virtual std::string SerializeToString (Ptr checker) const; + virtual bool DeserializeFromString (std::string value, Ptr checker); + +private: + friend class ObjectPtrMapAccessor; + std::map > m_objects; +}; + + +template +Ptr +MakeObjectPtrMapAccessor (Ptr (T::*get)(INDEX) const, + INDEX (T::*getN)(void) const); + +template +Ptr +MakeObjectPtrMapAccessor (INDEX (T::*getN)(void) const, + Ptr (T::*get)(INDEX) const); + +class ObjectPtrMapChecker : public AttributeChecker +{ +public: + virtual TypeId GetItemTypeId (void) const = 0; +}; + +template +Ptr MakeObjectPtrMapChecker (void); + +} // namespace ns3 + +namespace ns3 { + +namespace internal { + +template +class AnObjectPtrMapChecker : public ObjectPtrMapChecker +{ +public: + virtual TypeId GetItemTypeId (void) const { + return T::GetTypeId (); + } + virtual bool Check (const AttributeValue &value) const { + return dynamic_cast (&value) != 0; + } + virtual std::string GetValueTypeName (void) const { + return "ns3::ObjectPtrMapValue"; + } + virtual bool HasUnderlyingTypeInformation (void) const { + return true; + } + virtual std::string GetUnderlyingTypeInformation (void) const { + return "ns3::Ptr< " + T::GetTypeId ().GetName () + " >"; + } + virtual Ptr Create (void) const { + return ns3::Create (); + } + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + const ObjectPtrMapValue *src = dynamic_cast (&source); + ObjectPtrMapValue *dst = dynamic_cast (&destination); + if (src == 0 || dst == 0) + { + return false; + } + *dst = *src; + return true; + } +}; + +} // namespace internal + + +class ObjectPtrMapAccessor : public AttributeAccessor +{ +public: + virtual bool Set (ObjectBase * object, const AttributeValue &value) const; + virtual bool Get (const ObjectBase * object, AttributeValue &value) const; + virtual bool HasGetter (void) const; + virtual bool HasSetter (void) const; +private: + virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const = 0; + virtual Ptr DoGet (const ObjectBase *object, uint32_t i, uint32_t *index) const = 0; +}; + +template +Ptr +MakeObjectPtrMapAccessor (Ptr (T::*get)(INDEX) const, + INDEX (T::*getN)(void) const) +{ + struct MemberGetters : public ObjectPtrMapAccessor + { + virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { + const T *obj = dynamic_cast (object); + if (obj == 0) + { + return false; + } + *n = (obj->*m_getN)(); + return true; + } + virtual Ptr DoGet (const ObjectBase *object, uint32_t i, uint32_t *index) const { + const T *obj = static_cast (object); + return (obj->*m_get)(i); + } + Ptr (T::*m_get)(INDEX) const; + INDEX (T::*m_getN)(void) const; + } *spec = new MemberGetters (); + spec->m_get = get; + spec->m_getN = getN; + return Ptr (spec, false); +} + +template +Ptr +MakeObjectPtrMapAccessor (INDEX (T::*getN)(void) const, + Ptr (T::*get)(INDEX) const) +{ + return MakeObjectPtrMapAccessor (get, getN); +} + +template +Ptr MakeObjectPtrMapChecker (void) +{ + return Create > (); +} + + +} // namespace ns3 + +#endif /* OBJECT_PTR_MAP_H */ diff --git a/src/core/model/object-ptr-vector.cc b/src/core/model/object-ptr-vector.cc new file mode 100644 index 000000000..dbc4802aa --- /dev/null +++ b/src/core/model/object-ptr-vector.cc @@ -0,0 +1,114 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA, Mathieu Lacage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathieu Lacage + */ +#include "object-ptr-vector.h" + +namespace ns3 { + +ObjectPtrVectorValue::ObjectPtrVectorValue () +{ +} + +ObjectPtrVectorValue::Iterator +ObjectPtrVectorValue::Begin (void) const +{ + return m_objects.begin (); +} +ObjectPtrVectorValue::Iterator +ObjectPtrVectorValue::End (void) const +{ + return m_objects.end (); +} +uint32_t +ObjectPtrVectorValue::GetN (void) const +{ + return m_objects.size (); +} +Ptr +ObjectPtrVectorValue::Get (uint32_t i) const +{ + return m_objects[i]; +} + +Ptr +ObjectPtrVectorValue::Copy (void) const +{ + return ns3::Create (*this); +} +std::string +ObjectPtrVectorValue::SerializeToString (Ptr checker) const +{ + std::ostringstream oss; + for (uint32_t i = 0; i < m_objects.size (); ++i) + { + oss << m_objects[i]; + if (i != m_objects.size () - 1) + { + oss << " "; + } + } + return oss.str (); +} +bool +ObjectPtrVectorValue::DeserializeFromString (std::string value, Ptr checker) +{ + NS_FATAL_ERROR ("cannot deserialize a vector of object pointers."); + return true; +} + +bool +ObjectPtrVectorAccessor::Set (ObjectBase * object, const AttributeValue & value) const +{ + // not allowed. + return false; +} +bool +ObjectPtrVectorAccessor::Get (const ObjectBase * object, AttributeValue &value) const +{ + ObjectPtrVectorValue *v = dynamic_cast (&value); + if (v == 0) + { + return false; + } + v->m_objects.clear (); + uint32_t n; + bool ok = DoGetN (object, &n); + if (!ok) + { + return false; + } + for (uint32_t i = 0; i < n; i++) + { + Ptr o = DoGet (object, i); + v->m_objects.push_back (o); + } + return true; +} +bool +ObjectPtrVectorAccessor::HasGetter (void) const +{ + return true; +} +bool +ObjectPtrVectorAccessor::HasSetter (void) const +{ + return false; +} + +} // name diff --git a/src/core/model/object-ptr-vector.h b/src/core/model/object-ptr-vector.h new file mode 100644 index 000000000..bc0a536ca --- /dev/null +++ b/src/core/model/object-ptr-vector.h @@ -0,0 +1,192 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2007 INRIA, Mathieu Lacage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: Mathieu Lacage + */ +#ifndef OBJECT_PTR_VECTOR_H +#define OBJECT_PTR_VECTOR_H + +#include +#include "object.h" +#include "ptr.h" +#include "attribute.h" + +namespace ns3 { + +/** + * \ingroup object + * + * \brief contain a vector of ns3::Object pointers. + * + * This class it used to get attribute access to an array of + * ns3::Object pointers. + */ +class ObjectPtrVectorValue : public AttributeValue +{ +public: + typedef std::vector >::const_iterator Iterator; + + ObjectPtrVectorValue (); + + /** + * \returns an iterator to the first object contained in this vector + */ + Iterator Begin (void) const; + /** + * \returns an iterator to the last object contained in this vector + */ + Iterator End (void) const; + /** + * \returns the number of objects contained in this vector. + */ + uint32_t GetN (void) const; + /** + * \param i the index of the requested object. + * \returns the requested object + */ + Ptr Get (uint32_t i) const; + + virtual Ptr Copy (void) const; + virtual std::string SerializeToString (Ptr checker) const; + virtual bool DeserializeFromString (std::string value, Ptr checker); + +private: + friend class ObjectPtrVectorAccessor; + std::vector > m_objects; +}; + + +template +Ptr +MakeObjectPtrVectorAccessor (Ptr (T::*get)(INDEX) const, + INDEX (T::*getN)(void) const); + +template +Ptr +MakeObjectPtrVectorAccessor (INDEX (T::*getN)(void) const, + Ptr (T::*get)(INDEX) const); + +class ObjectPtrVectorChecker : public AttributeChecker +{ +public: + virtual TypeId GetItemTypeId (void) const = 0; +}; + +template +Ptr MakeObjectPtrVectorChecker (void); + +} // namespace ns3 + +namespace ns3 { + +namespace internal { + +template +class AnObjectPtrVectorChecker : public ObjectPtrVectorChecker +{ +public: + virtual TypeId GetItemTypeId (void) const { + return T::GetTypeId (); + } + virtual bool Check (const AttributeValue &value) const { + return dynamic_cast (&value) != 0; + } + virtual std::string GetValueTypeName (void) const { + return "ns3::ObjectPtrVectorValue"; + } + virtual bool HasUnderlyingTypeInformation (void) const { + return true; + } + virtual std::string GetUnderlyingTypeInformation (void) const { + return "ns3::Ptr< " + T::GetTypeId ().GetName () + " >"; + } + virtual Ptr Create (void) const { + return ns3::Create (); + } + virtual bool Copy (const AttributeValue &source, AttributeValue &destination) const { + const ObjectPtrVectorValue *src = dynamic_cast (&source); + ObjectPtrVectorValue *dst = dynamic_cast (&destination); + if (src == 0 || dst == 0) + { + return false; + } + *dst = *src; + return true; + } +}; + +} // namespace internal + + +class ObjectPtrVectorAccessor : public AttributeAccessor +{ +public: + virtual bool Set (ObjectBase * object, const AttributeValue &value) const; + virtual bool Get (const ObjectBase * object, AttributeValue &value) const; + virtual bool HasGetter (void) const; + virtual bool HasSetter (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; +}; + +template +Ptr +MakeObjectPtrVectorAccessor (Ptr (T::*get)(INDEX) const, + INDEX (T::*getN)(void) const) +{ + struct MemberGetters : public ObjectPtrVectorAccessor + { + virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { + const T *obj = dynamic_cast (object); + if (obj == 0) + { + return false; + } + *n = (obj->*m_getN)(); + return true; + } + virtual Ptr DoGet (const ObjectBase *object, uint32_t i) const { + const T *obj = static_cast (object); + return (obj->*m_get)(i); + } + Ptr (T::*m_get)(INDEX) const; + INDEX (T::*m_getN)(void) const; + } *spec = new MemberGetters (); + spec->m_get = get; + spec->m_getN = getN; + return Ptr (spec, false); +} + +template +Ptr +MakeObjectPtrVectorAccessor (INDEX (T::*getN)(void) const, + Ptr (T::*get)(INDEX) const) +{ + return MakeObjectPtrVectorAccessor (get, getN); +} + +template +Ptr MakeObjectPtrVectorChecker (void) +{ + return Create > (); +} + + +} // namespace ns3 + +#endif /* OBJECT_PTR_VECTOR_H */ diff --git a/src/core/model/object-vector.h b/src/core/model/object-vector.h index 953c21545..79f43ecd0 100644 --- a/src/core/model/object-vector.h +++ b/src/core/model/object-vector.h @@ -24,11 +24,11 @@ #include "object.h" #include "ptr.h" #include "attribute.h" -#include "object-ptr-container.h" +#include "object-ptr-vector.h" namespace ns3 { -typedef ObjectPtrContainerValue ObjectVectorValue; +typedef ObjectPtrVectorValue ObjectVectorValue; template Ptr @@ -55,7 +55,7 @@ template Ptr MakeObjectVectorAccessor (U T::*memberVector) { - struct MemberStdContainer : public ObjectPtrContainerAccessor + struct MemberStdContainer : public ObjectPtrVectorAccessor { virtual bool DoGetN (const ObjectBase *object, uint32_t *n) const { const T *obj = dynamic_cast (object); @@ -92,7 +92,7 @@ MakeObjectVectorAccessor (U T::*memberVector) template Ptr MakeObjectVectorChecker (void) { - return MakeObjectPtrContainerChecker (); + return MakeObjectPtrVectorChecker (); } template @@ -100,7 +100,7 @@ Ptr MakeObjectVectorAccessor (Ptr (T::*get)(INDEX) const, INDEX (T::*getN)(void) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrVectorAccessor(get, getN); } template @@ -108,7 +108,7 @@ Ptr MakeObjectVectorAccessor (INDEX (T::*getN)(void) const, Ptr (T::*get)(INDEX) const) { - return MakeObjectPtrContainerAccessor(get, getN); + return MakeObjectPtrVectorAccessor(get, getN); } diff --git a/src/core/wscript b/src/core/wscript index a2d3cfd35..ef5eb9091 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -135,7 +135,8 @@ def build(bld): 'model/int64x64.cc', 'model/string.cc', 'model/pointer.cc', - 'model/object-ptr-container.cc', + 'model/object-ptr-vector.cc', + 'model/object-ptr-map.cc', 'model/object-factory.cc', 'model/global-value.cc', 'model/trace-source-accessor.cc', @@ -229,7 +230,8 @@ def build(bld): 'model/traced-value.h', 'model/trace-source-accessor.h', 'model/config.h', - 'model/object-ptr-container.h', + 'model/object-ptr-vector.h', + 'model/object-ptr-map.h', 'model/object-vector.h', 'model/object-map.h', 'model/deprecated.h', diff --git a/src/lte/examples/lena-rlc-calculator.cc b/src/lte/examples/lena-rlc-calculator.cc index a83492352..4bb25d980 100644 --- a/src/lte/examples/lena-rlc-calculator.cc +++ b/src/lte/examples/lena-rlc-calculator.cc @@ -24,7 +24,7 @@ #include "ns3/mobility-module.h" #include "ns3/lte-module.h" #include "ns3/config-store.h" -//#include "ns3/gtk-config-store.h" +#include "ns3/gtk-config-store.h" using namespace ns3; diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index 1f548a7c1..b46a07822 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -214,7 +214,7 @@ StaticInformation::DoGather (TypeId tid) continue; } // attempt to cast to an object vector. - const ObjectPtrContainerChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); + const ObjectPtrVectorChecker *vectorChecker = dynamic_cast (PeekPointer (info.checker)); if (vectorChecker != 0) { TypeId item = vectorChecker->GetItemTypeId ();