diff --git a/src/core/trace-resolver.cc b/src/core/trace-resolver.cc index 4d4e4078a..3da9a088f 100644 --- a/src/core/trace-resolver.cc +++ b/src/core/trace-resolver.cc @@ -75,4 +75,34 @@ TraceResolver::GetSubpath (std::string path) 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 diff --git a/src/core/trace-resolver.h b/src/core/trace-resolver.h index f0f61f761..0fd5720f3 100644 --- a/src/core/trace-resolver.h +++ b/src/core/trace-resolver.h @@ -71,6 +71,26 @@ public: 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 SourceVector; + SourceVector m_sources; + }; + virtual void CollectSources (std::string path, const TraceContext &context, + SourceCollection *collection) {} protected: /** * \param path a namespace path