add TraceResolver::CollectSources

This commit is contained in:
Mathieu Lacage
2007-08-27 20:46:10 +02:00
parent 403ece5588
commit 95c06276cf
2 changed files with 50 additions and 0 deletions

View File

@@ -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

View File

@@ -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<struct Source> SourceVector;
SourceVector m_sources;
};
virtual void CollectSources (std::string path, const TraceContext &context,
SourceCollection *collection) {}
protected:
/**
* \param path a namespace path