add TraceResolver::CollectSources
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 27 Aug 2007 20:46:10 +0200
changeset 1370 d5339e1c95df
parent 1369 ca4667a61c57
child 1371 bebf690257c9
add TraceResolver::CollectSources
src/core/trace-resolver.cc
src/core/trace-resolver.h
--- a/src/core/trace-resolver.cc	Mon Aug 27 20:45:49 2007 +0200
+++ b/src/core/trace-resolver.cc	Mon Aug 27 20:46:10 2007 +0200
@@ -75,4 +75,34 @@
   return subpath;
 }
 
+void 
+TraceResolver::SourceCollection::AddUnique (std::string path, const TraceContext &context,
+                                            std::string help)
+{
+  for (SourceVector::const_iterator i = m_sources.begin (); i != m_sources.end (); i++)
+    {
+      if (i->path == path &&
+          i->help == help &&
+          context.IsSimilar (i->context))
+        {
+          return;
+        }
+    }
+  struct Source source;
+  source.path = path;
+  source.context = context;
+  source.help = help;
+  m_sources.push_back (source);
+}
+void 
+TraceResolver::SourceCollection::Print (std::ostream &os) const
+{
+  for (SourceVector::const_iterator i = m_sources.begin (); i != m_sources.end (); i++)
+    {
+      os << i->path << " [";
+      i->context.PrintAvailable (os, " ");
+      os << "] " << i->help << std::endl;
+    }
+}
+
 }//namespace ns3
--- a/src/core/trace-resolver.h	Mon Aug 27 20:45:49 2007 +0200
+++ b/src/core/trace-resolver.h	Mon Aug 27 20:46:10 2007 +0200
@@ -71,6 +71,26 @@
   virtual void Disconnect (std::string path, CallbackBase const &cb) = 0;
 
   virtual void PrintAvailable (std::string path, const TraceContext &context, std::ostream &os) = 0;
+
+
+  class SourceCollection
+  {
+  public:
+    void Print (std::ostream &os) const;
+    void AddUnique (std::string path, const TraceContext &context,
+                    std::string help);
+  private:
+    struct Source
+    {
+      std::string path;
+      TraceContext context;
+      std::string help;
+    };
+    typedef std::vector<struct Source> SourceVector;
+    SourceVector m_sources;
+  };
+  virtual void CollectSources (std::string path, const TraceContext &context, 
+                               SourceCollection *collection) {}
 protected:
   /**
    * \param path a namespace path