Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 parse (const std::string &filename, const std::string &docType=std::string(""))
virtual bool regClient (const std::string &eltName, DocClient *client)
virtual bool regClient (const std::string &eltName, DocClient *client)

Static Public Member Functions

DocMangetPointer ()
 Implements singleton.
DocMangetPointer ()
 Implements singleton.

Protected Member Functions

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

Private Types

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

Private Attributes

std::vector< ClientList * > m_lists
std::vector< ClientList * > m_lists
DocClientm_meFirst
DocClientm_meFirst
XmlParserm_parser
XmlParserm_parser

Static Private Attributes

DocManm_self
DocManm_self = 0


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


Member Typedef Documentation

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

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


Constructor & Destructor Documentation

xmlBase::DocMan::DocMan  )  [protected]
 

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

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

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

xmlBase::DocMan::DocMan  )  [protected]
 

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


Member Function Documentation

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

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

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.

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

Implements singleton.

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

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

Return false if something goes wrong with the parse

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

Return false if something goes wrong with the parse

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   }

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

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

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.

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

Register privileged client; only available to derived classes.

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]
 

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

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

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

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

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

DocMan* xmlBase::DocMan::m_self [static, private]
 

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


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:24:41 2011 for BOSS6.5.5 by  doxygen 1.3.9.1