00001
00002 #ifndef xmlBase_DocMan_h
00003 #define xmlBase_DocMan_h
00004
00005 #include <string>
00006 #include <vector>
00007 #include "xmlBase/XmlParser.h"
00008
00009 typedef XERCES_CPP_NAMESPACE_QUALIFIER DOMElement DomElement;
00010
00011 namespace xmlBase {
00012
00016 class DocClient;
00017
00019
00031 class DocMan {
00032 public:
00034 static DocMan* getPointer();
00035
00038
00039 virtual bool parse(const std::string& filename,
00040 const std::string& docType=std::string(""));
00041
00042 virtual bool regClient(const std::string& eltName, DocClient* client);
00043
00044 protected:
00045 DocMan();
00046 virtual ~DocMan();
00047
00049 bool regMeFirst(DocClient* client);
00050
00052 class ClientList {
00053 public:
00054 ClientList(const std::string& eltName) : m_eltName(eltName) {}
00055
00056 ~ClientList();
00058
00061 bool add(DocClient* client, bool front=false);
00062
00065 bool remove(DocClient* client);
00066
00068 const std::string& getName() {return m_eltName;}
00069
00071 void invoke(DomElement* elt);
00072 private:
00073 std::string m_eltName;
00074 std::vector<DocClient*> m_clients;
00075 typedef std::vector<DocClient*>::const_iterator ClientsIt;
00076 };
00077
00078 ClientList* findList(const std::string& eltName);
00079 private:
00080 static DocMan* m_self;
00081 std::vector<ClientList*> m_lists;
00082 typedef std::vector<ClientList*>::const_iterator ListsIt;
00083 XmlParser* m_parser;
00084 DocClient* m_meFirst;
00085 };
00086 }
00087 #endif