avoid problems with recursive use of Object::DoCollectSources
This commit is contained in:
@@ -23,8 +23,11 @@
|
||||
#include "singleton.h"
|
||||
#include "uid-manager.h"
|
||||
#include "trace-resolver.h"
|
||||
#include "debug.h"
|
||||
#include <vector>
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Object");
|
||||
|
||||
namespace {
|
||||
|
||||
class IidManager : public ns3::UidManager
|
||||
@@ -173,6 +176,7 @@ Object::Object ()
|
||||
: m_count (1),
|
||||
m_iid (Object::iid),
|
||||
m_disposed (false),
|
||||
m_collecting (false),
|
||||
m_next (this)
|
||||
{}
|
||||
Object::~Object ()
|
||||
@@ -296,15 +300,23 @@ void
|
||||
Object::DoCollectSources (std::string path, const TraceContext &context,
|
||||
TraceResolver::SourceCollection *collection)
|
||||
{
|
||||
Object *current = this->m_next;
|
||||
if (collection->IsFlagSet ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
collection->SetFlag ();
|
||||
Object *current;
|
||||
current = this;
|
||||
do {
|
||||
if (current->m_collecting)
|
||||
{
|
||||
return;
|
||||
}
|
||||
current = current->m_next;
|
||||
} while (current != this);
|
||||
|
||||
m_collecting = true;
|
||||
|
||||
current = this->m_next;
|
||||
while (current != this)
|
||||
{
|
||||
NS_ASSERT (current != 0);
|
||||
NS_DEBUG ("collect current=" << current);
|
||||
InterfaceId cur = current->m_iid;
|
||||
while (cur != Object::iid)
|
||||
{
|
||||
@@ -312,12 +324,14 @@ Object::DoCollectSources (std::string path, const TraceContext &context,
|
||||
std::string fullpath = path;
|
||||
fullpath.append ("/$");
|
||||
fullpath.append (name);
|
||||
NS_DEBUG ("collect: " << fullpath);
|
||||
current->GetTraceResolver ()->CollectSources (fullpath, context, collection);
|
||||
cur = InterfaceId::LookupParent (cur);
|
||||
}
|
||||
current = current->m_next;
|
||||
}
|
||||
collection->ClearFlag ();
|
||||
|
||||
m_collecting = false;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -170,6 +170,7 @@ private:
|
||||
mutable uint32_t m_count;
|
||||
InterfaceId m_iid;
|
||||
bool m_disposed;
|
||||
bool m_collecting;
|
||||
Object *m_next;
|
||||
};
|
||||
|
||||
|
||||
@@ -108,22 +108,4 @@ TraceResolver::SourceCollection::Print (std::ostream &os) const
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TraceResolver::SourceCollection::SetFlag (void)
|
||||
{
|
||||
m_flag = true;
|
||||
}
|
||||
|
||||
void
|
||||
TraceResolver::SourceCollection::ClearFlag (void)
|
||||
{
|
||||
m_flag = false;
|
||||
}
|
||||
bool
|
||||
TraceResolver::SourceCollection::IsFlagSet (void)
|
||||
{
|
||||
return m_flag;
|
||||
}
|
||||
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -76,9 +76,6 @@ public:
|
||||
void Print (std::ostream &os) const;
|
||||
void AddUnique (std::string path, const TraceContext &context,
|
||||
std::string help);
|
||||
void SetFlag (void);
|
||||
void ClearFlag (void);
|
||||
bool IsFlagSet (void);
|
||||
private:
|
||||
struct Source
|
||||
{
|
||||
@@ -88,7 +85,6 @@ public:
|
||||
};
|
||||
typedef std::vector<struct Source> SourceVector;
|
||||
SourceVector m_sources;
|
||||
bool m_flag;
|
||||
};
|
||||
virtual void CollectSources (std::string path, const TraceContext &context,
|
||||
SourceCollection *collection) = 0;
|
||||
|
||||
Reference in New Issue
Block a user