src/core/object.cc
changeset 1371 bebf690257c9
parent 1368 e75dc1a2a5fb
child 1372 5967e5b2c737
equal deleted inserted replaced
1370:d5339e1c95df 1371:bebf690257c9
    61 {
    61 {
    62 public:
    62 public:
    63   InterfaceIdTraceResolver (Ptr<Object> aggregate);
    63   InterfaceIdTraceResolver (Ptr<Object> aggregate);
    64   virtual void Connect (std::string path, CallbackBase const &cb, const TraceContext &context);
    64   virtual void Connect (std::string path, CallbackBase const &cb, const TraceContext &context);
    65   virtual void Disconnect (std::string path, CallbackBase const &cb);
    65   virtual void Disconnect (std::string path, CallbackBase const &cb);
    66   virtual void PrintAvailable (std::string path, const TraceContext &context, std::ostream &os);
    66   virtual void CollectSources (std::string path, const TraceContext &context, 
       
    67                                SourceCollection *collection);
    67 private:
    68 private:
    68   Ptr<Object> ParseForInterface (std::string path);
    69   Ptr<Object> ParseForInterface (std::string path);
    69   Ptr<Object> m_aggregate;
    70   Ptr<Object> m_aggregate;
    70 };
    71 };
    71 
    72 
   103     {
   104     {
   104       interface->TraceDisconnect (GetSubpath (path), cb);
   105       interface->TraceDisconnect (GetSubpath (path), cb);
   105     }
   106     }
   106 }
   107 }
   107 void 
   108 void 
   108 InterfaceIdTraceResolver::PrintAvailable (std::string path, const TraceContext &context, std::ostream &os)
   109 InterfaceIdTraceResolver::CollectSources (std::string path, const TraceContext &context, 
   109 {
   110                                           SourceCollection *collection)
   110   
   111 {
       
   112   m_aggregate->DoCollectSources (path, context, collection);
   111 }
   113 }
   112 
   114 
   113 
   115 
   114 InterfaceId::InterfaceId (uint16_t iid)
   116 InterfaceId::InterfaceId (uint16_t iid)
   115   : m_iid (iid)
   117   : m_iid (iid)
   125 }
   127 }
   126 InterfaceId 
   128 InterfaceId 
   127 InterfaceId::LookupParent (InterfaceId iid)
   129 InterfaceId::LookupParent (InterfaceId iid)
   128 {
   130 {
   129   return Singleton<IidTree>::Get ()->LookupParent (iid.m_iid);
   131   return Singleton<IidTree>::Get ()->LookupParent (iid.m_iid);
       
   132 }
       
   133 std::string 
       
   134 InterfaceId::GetName (void) const
       
   135 {
       
   136   std::string name = Singleton<IidManager>::Get ()->LookupByUid (m_iid);
       
   137   return name;
   130 }
   138 }
   131 
   139 
   132 bool operator == (const InterfaceId &a, const InterfaceId &b)
   140 bool operator == (const InterfaceId &a, const InterfaceId &b)
   133 {
   141 {
   134   return a.m_iid == b.m_iid;
   142   return a.m_iid == b.m_iid;
   282     delete current;
   290     delete current;
   283     current = next;
   291     current = next;
   284   } while (current != end);
   292   } while (current != end);
   285 }
   293 }
   286 
   294 
       
   295 void 
       
   296 Object::DoCollectSources (std::string path, const TraceContext &context, 
       
   297                           TraceResolver::SourceCollection *collection)
       
   298 {
       
   299   Object *current = this->m_next;
       
   300   if (collection->IsFlagSet ())
       
   301     {
       
   302       return;
       
   303     }
       
   304   collection->SetFlag ();
       
   305   while (current != this)
       
   306     {
       
   307       NS_ASSERT (current != 0);
       
   308       InterfaceId cur = current->m_iid;
       
   309       while (cur != Object::iid)
       
   310         {
       
   311           std::string name = cur.GetName ();
       
   312           std::string fullpath = path;
       
   313           fullpath.append ("/$");
       
   314           fullpath.append (name);
       
   315           current->GetTraceResolver ()->CollectSources (fullpath, context, collection);
       
   316           cur = InterfaceId::LookupParent (cur);
       
   317         }
       
   318       current = current->m_next;
       
   319     }
       
   320   collection->ClearFlag ();
       
   321 }
       
   322 
   287 } // namespace ns3
   323 } // namespace ns3
   288 
   324 
   289 
   325 
   290 #ifdef RUN_SELF_TESTS
   326 #ifdef RUN_SELF_TESTS
   291 
   327