/[usata]/usata2/src/xml/scene_parser.cpp
ViewVC logotype

Diff of /usata2/src/xml/scene_parser.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by skunix, Fri Feb 18 02:24:33 2005 UTC revision 1.3 by skunix, Tue Feb 22 18:17:57 2005 UTC
# Line 52  SceneParser::init() Line 52  SceneParser::init()
52    
53  }  }
54    
55    void
56    SceneParser::add_object(ObjectDescription* aNewOD)
57    {
58            boost::mutex::scoped_lock p(mObjectQueue_M);
59            mObjectQueue.push(aNewOD);
60            std::cout << "ready with object of type " << aNewOD->type << std::endl;;
61            return;
62    }
63    
64    ObjectDescription*
65    SceneParser::get_object()
66    {
67            boost::mutex::scoped_lock p(mObjectQueue_M);
68            if (mObjectQueue.empty())
69                    return 0;
70            ObjectDescription *obd = mObjectQueue.front();
71            mObjectQueue.pop();
72            return obd;
73    }
74    
75  SceneParser::~SceneParser()  SceneParser::~SceneParser()
76  {  {
77          if (mThread.get())          if (mThread.get())
78          {          {
 //              std::cout << "waiting " << std::endl;  
79                  mThread->join();                  mThread->join();
80          }          }
81  }  }
# Line 69  SceneParser::element_start(const char* n Line 87  SceneParser::element_start(const char* n
87          {          {
88                  SceneElement * ns = new SceneDocument(this);                  SceneElement * ns = new SceneDocument(this);
89                  ns->start_element(name,attrib);                  ns->start_element(name,attrib);
90                  mElements.push_back(ns);                  mElements.push(ns);
91                  return;                  return;
92          }          }
93            
94            SceneElement *te = mElements.top();
95            SceneElement *ne = 0;
96            if (te != 0)
97            {
98                    SceneElementHub * shte = dynamic_cast<SceneElementHub*>(te);
99                    if (shte)
100                            ne = shte->make_child(name);
101            }
102    
103            if (ne == 0)
104            {
105                    using namespace scene_parser_elements;
106                    //create an ignore element
107                    ne = new IgnoreE(te, this);
108                    std::cout << "ignore '"<<name<<"'"  << std::endl;
109            }
110                    
111            mElements.push(ne);
112            ne->start_element(name, attrib);        
113    
114            return;
115  }  }
116  void SceneParser::element_end(const char*)  void SceneParser::element_end(const char*)
117  {  {
118            SceneElement* te = mElements.top();
119            if (te) te->end_element();
120            mElements.pop();
121            delete te;
122            return;
123  }  }
124  void SceneParser::content(const char*buf, int len)  void SceneParser::content(const char*buf, int len)
125  {  {
126            if (mElements.empty())
127                    return;
128            SceneElement* te = mElements.top();
129            if (te)
130                    te->content(buf,len);
131            return;
132  }  }
133    
134  void  void
# Line 105  SceneParser::thread_main() Line 153  SceneParser::thread_main()
153                                  std::cout << get_error() << std::endl;                                  std::cout << get_error() << std::endl;
154                                  return;                                  return;
155                          }                          }
156                            
157                            if (mThreadAbort)
158                                    return;
159          }          }
160          return;          return;
161  }        }
162            
163    void
164    SceneParser::threaded_abort()
165    {
166            mThreadAbort=true;
167            return;
168    }
169  void  void
170  SceneParser::threaded_parse()  SceneParser::threaded_parse()
171  {  {
172          mThread.reset(new boost::thread(boost::bind(&SceneParser::thread_main,this)));          mThreadAbort=false;
173            mThread.reset(
174                    new boost::thread(
175                            boost::bind(&SceneParser::thread_main,this)
176            ));
177            return;
178  }  }
179    
180  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26