[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/xml/scene_parser.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/xml/scene_parser.cpp |
Date: |
Tue, 22 Feb 2005 13:18:01 -0500 |
Index: usata2/src/xml/scene_parser.cpp
diff -u usata2/src/xml/scene_parser.cpp:1.2 usata2/src/xml/scene_parser.cpp:1.3
--- usata2/src/xml/scene_parser.cpp:1.2 Fri Feb 18 02:24:33 2005
+++ usata2/src/xml/scene_parser.cpp Tue Feb 22 18:17:57 2005
@@ -10,7 +10,7 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: scene_parser.cpp,v 1.2 2005/02/18 02:24:33 skunix Exp $
+// $Id: scene_parser.cpp,v 1.3 2005/02/22 18:17:57 skunix Exp $
#include <map>
#include <iostream>
@@ -52,12 +52,30 @@
}
+void
+SceneParser::add_object(ObjectDescription* aNewOD)
+{
+ boost::mutex::scoped_lock p(mObjectQueue_M);
+ mObjectQueue.push(aNewOD);
+ std::cout << "ready with object of type " << aNewOD->type << std::endl;;
+ return;
+}
+
+ObjectDescription*
+SceneParser::get_object()
+{
+ boost::mutex::scoped_lock p(mObjectQueue_M);
+ if (mObjectQueue.empty())
+ return 0;
+ ObjectDescription *obd = mObjectQueue.front();
+ mObjectQueue.pop();
+ return obd;
+}
SceneParser::~SceneParser()
{
if (mThread.get())
{
-// std::cout << "waiting " << std::endl;
mThread->join();
}
}
@@ -69,18 +87,48 @@
{
SceneElement * ns = new SceneDocument(this);
ns->start_element(name,attrib);
- mElements.push_back(ns);
+ mElements.push(ns);
return;
}
-
+
+ SceneElement *te = mElements.top();
+ SceneElement *ne = 0;
+ if (te != 0)
+ {
+ SceneElementHub * shte = dynamic_cast<SceneElementHub*>(te);
+ if (shte)
+ ne = shte->make_child(name);
+ }
+
+ if (ne == 0)
+ {
+ using namespace scene_parser_elements;
+ //create an ignore element
+ ne = new IgnoreE(te, this);
+ std::cout << "ignore '"<<name<<"'" << std::endl;
+ }
+
+ mElements.push(ne);
+ ne->start_element(name, attrib);
+
+ return;
}
void SceneParser::element_end(const char*)
{
-
+ SceneElement* te = mElements.top();
+ if (te) te->end_element();
+ mElements.pop();
+ delete te;
+ return;
}
void SceneParser::content(const char*buf, int len)
{
-
+ if (mElements.empty())
+ return;
+ SceneElement* te = mElements.top();
+ if (te)
+ te->content(buf,len);
+ return;
}
void
@@ -105,14 +153,28 @@
std::cout << get_error() << std::endl;
return;
}
-
+
+ if (mThreadAbort)
+ return;
}
return;
-}
+}
+
+void
+SceneParser::threaded_abort()
+{
+ mThreadAbort=true;
+ return;
+}
void
SceneParser::threaded_parse()
{
- mThread.reset(new
boost::thread(boost::bind(&SceneParser::thread_main,this)));
+ mThreadAbort=false;
+ mThread.reset(
+ new boost::thread(
+ boost::bind(&SceneParser::thread_main,this)
+ ));
+ return;
}
}