xmlBase::DocMan Class Reference

DocMan allows different clients to share a single xml document. More...

#include <DocMan.h>

List of all members.

Public Member Functions

virtual bool parse (const std::string &filename, const std::string &docType=std::string(""))
virtual bool regClient (const std::string &eltName, DocClient *client)

Static Public Member Functions

static DocMangetPointer ()
 Implements singleton.

Protected Member Functions

 DocMan ()
virtual ~DocMan ()
bool regMeFirst (DocClient *client)
 Register privileged client; only available to derived classes.
ClientListfindList (const std::string &eltName)

Private Types

typedef std::vector< ClientList
* >::const_iterator 
ListsIt

Private Attributes

std::vector< ClientList * > m_lists
XmlParserm_parser
DocClientm_meFirst

Static Private Attributes

static DocManm_self = 0

Classes

class  ClientList
 Nested class to keep track of clients for one element type. More...


Detailed Description

DocMan allows different clients to share a single xml document.

Clients may sign up to handle particular child elements (direct children only of the root element). Then when the DocMan object (there is only one: it's a singleton) is asked to parse a file it

Definition at line 31 of file DocMan.h.


Member Typedef Documentation

typedef std::vector<ClientList*>::const_iterator xmlBase::DocMan::ListsIt [private]

Definition at line 82 of file DocMan.h.


Constructor & Destructor Documentation

xmlBase::DocMan::DocMan (  )  [protected]

Definition at line 16 of file DocMan.cxx.

References m_meFirst, m_parser, and m_self.

Referenced by getPointer().

00016                  {
00017     m_self = this;
00018     m_meFirst = 0;
00019     m_parser = new xmlBase::XmlParser();
00020   }

xmlBase::DocMan::~DocMan (  )  [protected, virtual]

Definition at line 119 of file DocMan.cxx.

References m_lists, and m_parser.

00119                   {
00120     ListsIt it = m_lists.begin();
00121     while (it != m_lists.end()) {
00122       delete (*it);
00123       ++it;
00124     }
00125     delete m_parser;
00126   }


Member Function Documentation

DocMan::ClientList * xmlBase::DocMan::findList ( const std::string eltName  )  [protected]

Definition at line 75 of file DocMan.cxx.

References m_lists.

Referenced by parse(), and regClient().

00075                                                              {
00076     unsigned int ix;
00077 
00078     for (ix = 0; ix < m_lists.size(); ix++) {
00079       ClientList* cur = m_lists[ix];
00080       if (eltName.compare(cur->getName()) == 0) return cur;
00081     }
00082     return 0;
00083   }

DocMan * xmlBase::DocMan::getPointer (  )  [static]

Implements singleton.

Definition at line 22 of file DocMan.cxx.

References DocMan(), and m_self.

00022                              {
00023     if (m_self == 0) {
00024       m_self = new DocMan();
00025     }
00026     return m_self;
00027   }

bool xmlBase::DocMan::parse ( const std::string filename,
const std::string docType = std::string("") 
) [virtual]

Return false if something goes wrong with the parse

Definition at line 29 of file DocMan.cxx.

References findList(), xmlBase::Dom::getFirstChildElement(), xmlBase::Dom::getSiblingElement(), xmlBase::Dom::getTagName(), xmlBase::DocClient::handleChild(), xmlBase::DocMan::ClientList::invoke(), m_meFirst, m_parser, xmlBase::XmlParser::parse(), xmlBase::XmlParser::reset(), root, and deljobs::string.

00029                                                                         {
00030     //    using xercesc::DOMDocument;
00031     //    using xercesc::DOMElement;
00032 
00033     DOMDocument* doc = m_parser->parse(filename.c_str(), docType);
00034     if (doc == 0) return false;
00035 
00036     if (m_meFirst != 0) m_meFirst->handleChild(doc);
00037 
00038     DOMElement* root = doc->getDocumentElement();
00039 
00040     DOMElement* child = xmlBase::Dom::getFirstChildElement(root);
00041 
00042     while (child != 0) {
00043       std::string eltName = Dom::getTagName(child);
00044       if (m_meFirst != 0) m_meFirst->handleChild(child);
00045 
00046       ClientList* list = findList(eltName);
00047       if (list) list->invoke(child);
00048 
00049       child = xmlBase::Dom::getSiblingElement(child);
00050     }
00051 
00052     // Clean up call for privileged client
00053     if (m_meFirst != 0) m_meFirst->handleChild(0);
00054 
00055     m_parser->reset();
00056     return true;
00057   }

bool xmlBase::DocMan::regClient ( const std::string eltName,
DocClient client 
) [virtual]

Definition at line 59 of file DocMan.cxx.

References xmlBase::DocMan::ClientList::add(), findList(), and m_lists.

00059                                                                     {
00060     ClientList* curList = findList(eltName);
00061     if (curList == 0) {
00062       curList = new ClientList(eltName);
00063       m_lists.push_back(curList);
00064     }
00065     return curList->add(client);
00066   }

bool xmlBase::DocMan::regMeFirst ( DocClient client  )  [protected]

Register privileged client; only available to derived classes.

Definition at line 68 of file DocMan.cxx.

References m_meFirst.

00068                                            {
00069     if (m_meFirst != 0)       return false;
00070 
00071     m_meFirst = client;
00072     return true;
00073   }


Member Data Documentation

std::vector<ClientList*> xmlBase::DocMan::m_lists [private]

Definition at line 81 of file DocMan.h.

Referenced by findList(), regClient(), and ~DocMan().

DocClient* xmlBase::DocMan::m_meFirst [private]

Definition at line 84 of file DocMan.h.

Referenced by DocMan(), parse(), and regMeFirst().

XmlParser* xmlBase::DocMan::m_parser [private]

Definition at line 83 of file DocMan.h.

Referenced by DocMan(), parse(), and ~DocMan().

XERCES_CPP_NAMESPACE_USE DocMan * xmlBase::DocMan::m_self = 0 [static, private]

Definition at line 80 of file DocMan.h.

Referenced by DocMan(), and getPointer().


Generated on Tue Nov 29 23:36:38 2016 for BOSS_7.0.2 by  doxygen 1.4.7