15 |
#ifndef USATA_SCENE_PARSER_HPP |
#ifndef USATA_SCENE_PARSER_HPP |
16 |
#define USATA_SCENE_PARSER_HPP |
#define USATA_SCENE_PARSER_HPP |
17 |
|
|
18 |
#include <deque> |
#include <stack> |
19 |
|
#include <queue> |
20 |
|
|
21 |
#include <string> |
#include <string> |
22 |
#include <memory> |
#include <memory> |
23 |
#include <istream> |
#include <istream> |
28 |
#include "parser.hpp" |
#include "parser.hpp" |
29 |
#include "../gproperties.hpp" |
#include "../gproperties.hpp" |
30 |
|
|
31 |
namespace boost{class thread;} |
namespace boost {class thread;} |
32 |
namespace usata |
namespace usata |
33 |
{ |
{ |
34 |
struct ObjectDescription |
struct ObjectDescription |
35 |
{ |
{ |
|
std::string name; |
|
|
std::string path; |
|
36 |
std::string type; |
std::string type; |
37 |
GProperties<std::string> props; |
GProperties<std::string> props; |
38 |
}; |
}; |
56 |
}; |
}; |
57 |
|
|
58 |
typedef boost::shared_ptr<SceneElement> SceneElement_sp; |
typedef boost::shared_ptr<SceneElement> SceneElement_sp; |
59 |
class SceneParser : public XML::Parser |
class SceneParser |
60 |
|
: public XML::Parser |
61 |
{ |
{ |
62 |
private: |
private: |
63 |
std::deque<SceneElement*> mElements; |
typedef std::queue<ObjectDescription*> ODQueue; |
64 |
|
|
65 |
|
std::stack<SceneElement*> mElements; |
66 |
|
ODQueue mObjectQueue; |
67 |
std::auto_ptr<boost::thread> mThread; |
std::auto_ptr<boost::thread> mThread; |
68 |
|
|
69 |
std::istream& mIs; |
std::istream& mIs; |
70 |
std::string mStreamName; |
std::string mStreamName; |
71 |
|
|
72 |
size_t mChunkSize; |
size_t mChunkSize; |
73 |
size_t mElementBufferSize; |
size_t mElementBufferSize; |
74 |
|
|
75 |
boost::mutex mElements_M; |
boost::mutex mElements_M; |
76 |
|
boost::mutex mObjectQueue_M; |
77 |
|
|
78 |
|
bool mThreadAbort; |
79 |
|
|
80 |
void init(); |
void init(); |
81 |
void thread_main(); |
void thread_main(); |
82 |
|
|
83 |
public: |
public: |
84 |
|
void add_object(ObjectDescription*); |
85 |
|
ObjectDescription* get_object(); |
86 |
|
|
87 |
SceneParser(std::istream& is, const std::string& = "<unnamed>"); |
SceneParser(std::istream& is, const std::string& = "<unnamed>"); |
88 |
|
const std::string &get_stream_name()const{return mStreamName;} |
89 |
virtual ~SceneParser(); |
virtual ~SceneParser(); |
90 |
void threaded_parse(); |
void threaded_parse(); |
91 |
void threaded_abort(); |
void threaded_abort(); |