add TraceResolver::CollectSources
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user