summaryrefslogtreecommitdiff
path: root/project2/xmlObjectLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xmlObjectLoader.cpp')
-rw-r--r--project2/xmlObjectLoader.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/project2/xmlObjectLoader.cpp b/project2/xmlObjectLoader.cpp
index b33bf85..d2f25e7 100644
--- a/project2/xmlObjectLoader.cpp
+++ b/project2/xmlObjectLoader.cpp
@@ -10,6 +10,18 @@
unsigned int LoaderBase::depth = 0;
std::set<SourceObjectPtr> LoaderBase::loadedObjects;
+class DepthCounter {
+ public:
+ DepthCounter(unsigned int & c) : counter(c) {
+ counter += 1;
+ }
+ ~DepthCounter() {
+ counter -= 1;
+ }
+ private:
+ unsigned int & counter;
+};
+
typedef std::map<std::string, boost::shared_ptr<ElementLoader> > ElementLoaderMap;
typedef std::set<boost::shared_ptr<ComponentLoader> > ComponentLoaderSet;
@@ -47,7 +59,7 @@ LoaderBase::collectAll(const xmlpp::Element * node, bool childrenOnly, Unsupport
if (!node) {
return;
}
- depth += 1;
+ DepthCounter dc(depth);
unsigned int created = 0;
if (!childrenOnly && node->get_namespace_uri() == ns) {
Glib::ustring name = node->get_name();
@@ -74,7 +86,6 @@ LoaderBase::collectAll(const xmlpp::Element * node, bool childrenOnly, Unsupport
collectAll(dynamic_cast<const xmlpp::Element *>(child), false, uh);
}
}
- depth -= 1;
}
void
@@ -102,7 +113,6 @@ void
LoaderBase::onIteration()
{
// This is a fail safe in the event that something goes pearshape
- depth = 0;
loadedObjects.clear();
BOOST_FOREACH(ComponentLoaderSet::value_type l, *componentLoaders()) {