# HG changeset patch # User Mathieu Lacage # Date 1207778332 25200 # Node ID c7983cfa2cb3d7a6ac8520118753c7ddef192e73 # Parent db96af55f46eb6805f386c2b3abc17464d2ef01e add ObjectVector::GetItemTypeId diff -r db96af55f46e -r c7983cfa2cb3 src/core/attribute-test.cc --- a/src/core/attribute-test.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/core/attribute-test.cc Wed Apr 09 14:58:52 2008 -0700 @@ -143,12 +143,12 @@ .AddAttribute ("TestVector1", "help text", ObjectVector (), MakeObjectVectorAccessor (&AttributeObjectTest::m_vector1), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("TestVector2", "help text", ObjectVector (), MakeObjectVectorAccessor (&AttributeObjectTest::DoGetVectorN, &AttributeObjectTest::DoGetVector), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("IntegerTraceSource1", "help text", Integer (-2), MakeIntegerAccessor (&AttributeObjectTest::m_intSrc1), diff -r db96af55f46e -r c7983cfa2cb3 src/core/config.cc --- a/src/core/config.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/core/config.cc Wed Apr 09 14:58:52 2008 -0700 @@ -512,11 +512,11 @@ .AddAttribute ("NodesA", "", ObjectVector (), MakeObjectVectorAccessor (&MyNode::m_nodesA), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("NodesB", "", ObjectVector (), MakeObjectVectorAccessor (&MyNode::m_nodesB), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("NodeA", "", Pointer (), MakePointerAccessor (&MyNode::m_nodeA), diff -r db96af55f46e -r c7983cfa2cb3 src/core/object-vector.cc --- a/src/core/object-vector.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/core/object-vector.cc Wed Apr 09 14:58:52 2008 -0700 @@ -102,6 +102,4 @@ return true; } -ATTRIBUTE_CHECKER_IMPLEMENT (ObjectVector); - } // name diff -r db96af55f46e -r c7983cfa2cb3 src/core/object-vector.h --- a/src/core/object-vector.h Wed Apr 09 14:28:16 2008 -0700 +++ b/src/core/object-vector.h Wed Apr 09 14:58:52 2008 -0700 @@ -5,7 +5,6 @@ #include "object.h" #include "ptr.h" #include "attribute.h" -#include "attribute-helper.h" namespace ns3 { @@ -48,8 +47,14 @@ MakeObjectVectorAccessor (INDEX (T::*getN) (void) const, Ptr (T::*get) (INDEX) const); +class ObjectVectorChecker : public AttributeChecker +{ +public: + virtual TypeId GetItemTypeId (void) const = 0; +}; -ATTRIBUTE_CHECKER_DEFINE (ObjectVector); +template +Ptr MakeObjectVectorChecker (void); } // namespace ns3 @@ -72,6 +77,36 @@ ObjectVector m_vector; }; + +namespace internal { + +template +class AnObjectVectorChecker : public ObjectVectorChecker +{ +public: + virtual TypeId GetItemTypeId (void) const { + return T::GetTypeId (); + } + virtual bool Check (Attribute value) const { + return value.DynCast () != 0; + } + virtual std::string GetType (void) const { + return "ns3::ObjectVector"; + } + virtual bool HasTypeConstraints (void) const { + return true; + } + virtual std::string GetTypeConstraints (void) const { + return T::GetTypeId ().GetName (); + } + virtual Attribute Create (void) const { + return Attribute::Create (); + } +}; + +} // namespace internal + + class ObjectVectorAccessor : public AttributeAccessor { public: @@ -156,6 +191,13 @@ return MakeObjectVectorAccessor (get, getN); } +template +Ptr MakeObjectVectorChecker (void) +{ + return Create > (); +} + + } // namespace ns3 #endif /* OBJECT_VECTOR_H */ diff -r db96af55f46e -r c7983cfa2cb3 src/internet-node/ipv4-l3-protocol.cc --- a/src/internet-node/ipv4-l3-protocol.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/internet-node/ipv4-l3-protocol.cc Wed Apr 09 14:58:52 2008 -0700 @@ -64,7 +64,7 @@ .AddAttribute ("InterfaceList", "The set of Ipv4 interfaces associated to this Ipv4 stack.", ObjectVector (), MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) ; return tid; } diff -r db96af55f46e -r c7983cfa2cb3 src/internet-node/ipv4-l4-demux.cc --- a/src/internet-node/ipv4-l4-demux.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/internet-node/ipv4-l4-demux.cc Wed Apr 09 14:58:52 2008 -0700 @@ -39,7 +39,7 @@ .AddAttribute ("Protocols", "The set of protocols registered with this demux.", ObjectVector (), MakeObjectVectorAccessor (&Ipv4L4Demux::m_protocols), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) ; return tid; } diff -r db96af55f46e -r c7983cfa2cb3 src/node/node-list.cc --- a/src/node/node-list.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/node/node-list.cc Wed Apr 09 14:58:52 2008 -0700 @@ -63,7 +63,7 @@ .AddAttribute ("NodeList", "The list of all nodes created during the simulation.", ObjectVector (), MakeObjectVectorAccessor (&NodeListPriv::m_nodes), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) ; return tid; } diff -r db96af55f46e -r c7983cfa2cb3 src/node/node.cc --- a/src/node/node.cc Wed Apr 09 14:28:16 2008 -0700 +++ b/src/node/node.cc Wed Apr 09 14:58:52 2008 -0700 @@ -39,11 +39,11 @@ .AddAttribute ("DeviceList", "The list of devices associated to this Node.", ObjectVector (), MakeObjectVectorAccessor (&Node::m_devices), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("ApplicationList", "The list of applications associated to this Node.", ObjectVector (), MakeObjectVectorAccessor (&Node::m_applications), - MakeObjectVectorChecker ()) + MakeObjectVectorChecker ()) .AddAttribute ("Id", "The id (unique integer) of this Node.", TypeId::ATTR_GET, // allow only getting it. Uinteger (0),