// -*- mode: C++; tab-width: 4; indent-tabs-mode: t; -*- vim:ts=4:sw=4 // // Copyright (C) 2004,2005 David Lau (skunix) // Chong Kai Xiong (descender) // // This file is part of The Plains of Usata. // // The Plains of Usata is licensed under the GNU General Public // License (GPL) version 2. For details, please see the COPYING file // included in the software distribution, or visit // http://www.fsf.org/licenses/gpl.html. // // $Id: scene_parser.hpp,v 1.1 2005/02/16 06:30:02 skunix Exp $ #include #include #include #include #include #include #include "parser.hpp" #include "../gproperties.hpp" namespace boost{class thread;} namespace usata { class ObjectDescription { std::string name; std::string path; std::string type; GProperties props; }; class SceneParser; class SceneElement { public: SceneElement(SceneElement* parent, SceneParser *parser); virtual void start(const char* name, const char**attrib)=0; virtual void end()=0; virtual void content(const char*buf, int len){} virtual ~SceneElement(); }; typedef boost::shared_ptr SceneElement_sp; class SceneParser : public XML::Parser { private: std::deque mElements; std::auto_ptr mThread; std::istream& mIs; std::string mStreamName; size_t mChunkSize; size_t mElementBufferSize; boost::mutex mElements_M; void init(); void thread_main(); public: SceneParser(std::istream& is, const std::string& = ""); virtual ~SceneParser(); void threaded_parse(); void threaded_abort(); protected: virtual void element_start(const char* name, const char**attrib); virtual void element_end(const char*); virtual void content(const char*buf, int len); void next(); bool done(); }; }