Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

xmlUtil::IdDict Class Reference

#include <IdDict.h>

Inheritance diagram for xmlUtil::IdDict::

xmlUtil::DictObject List of all members.

Public Types

enum  Constituents { nodeHierarchy = 1, fieldManager = 2 }

Public Methods

 IdDict (DOM_Element elt)
 ~IdDict ()
bool isValid ()
 Verify that dictionary is valid. More...

bool idOk (const Identifier &id) const
 Verify that supplied identifier is valid w.r.t. the idDict. More...

bool idOk (const NamedId &id) const
 Verify that supplied named identifier is valid w.r.t. the idDict. More...

bool nameSeqOk (const NameSeq &seq) const
 Verify that the sequence of field names corresponds to at least one valid identifier. More...

NamedIdgetNamedId (const Identifier &id) const
 Given an identifier, return a full NamedIdentifier (conceptually a sequence of (name, value) pairs). More...

const std::string & getDictName () const
int getMajorVersion () const
int getMinorVersion () const
int getPatchVersion () const
DictNodegetRoot () const
bool accept (DictVisitor *vis)
bool accept (DictVisitor *vis, unsigned constituentMask)

Protected Methods

 IdDict (DictNode *root)
 Following constructor may be used by friend IdConverter to build output dictionary. More...

bool addChild (DictNode *parent, DictNode *newNode)
 Link up newNode to parent; also ask m_fieldMan to add the field if it's new. More...


Protected Attributes

DictFieldManm_fieldMan
DictNodem_root
std::string m_name
int m_major
int m_minor
int m_patch

Friends

class IdConverter
 Extra accept function to allow caller to choose among constituents of dictionary to visit. May choose all, just node hierarchy, or just field manager. More...


Member Enumeration Documentation

enum xmlUtil::IdDict::Constituents
 

Enumeration values:
nodeHierarchy 
fieldManager 

Definition at line 43 of file IdDict.h.

00043                       {nodeHierarchy = 1,
00044                        fieldManager = 2};


Constructor & Destructor Documentation

xmlUtil::IdDict::IdDict DOM_Element    elt
 

Definition at line 13 of file IdDict.cxx.

References m_fieldMan, m_major, m_minor, m_name, m_patch, and m_root.

00013                                  {
00014     // Check that element has the right tag name: idDict
00015     // Caller probably will have done this already
00016     assert(elt.getTagName().equals("idDict"));
00017 
00018     // Store information from attributes
00019     m_name = std::string(xml::Dom::getAttribute(elt, "name"));
00020 
00021     std::string intVal = xml::Dom::getAttribute(elt, "major");
00022     m_major = atoi(intVal.c_str());
00023 
00024     intVal = xml::Dom::getAttribute(elt, "minor");
00025     m_minor = atoi(intVal.c_str());
00026 
00027     intVal = xml::Dom::getAttribute(elt, "patch");
00028     m_patch = atoi(intVal.c_str());
00029 
00030     // Check number of children.  This is an upper bound
00031     // on number of fields we have to store
00032     int size = (elt.getChildNodes()).getLength();
00033     m_fieldMan = new DictFieldMan(size);
00034                 
00035     DOM_Element fieldElt = xml::Dom::getFirstChildElement(elt);
00036 
00037     // Register all the fields
00038     while ((fieldElt.getNodeName()).equals("field")) {
00039       //      DOM_Element fieldElt = static_cast<DOM_Element&>(fieldNode);
00040       DictField* field = new DictField(fieldElt);
00041       m_fieldMan->signup(field);
00042       fieldElt = xml::Dom::getSiblingElement(fieldElt);
00043     }
00044     // Finally make the hierarchy of constraints on Identifiers
00045     m_root = new DictNode(fieldElt, 0, m_fieldMan);
00046   }

xmlUtil::IdDict::~IdDict  
 

Definition at line 48 of file IdDict.cxx.

References m_fieldMan, and m_root.

00048                   {
00049     /* First get rid of hierarchy of nodes, then get rid of
00050        our DictFieldMan object. The latter will delete all the
00051        fields
00052     */
00053     delete m_root;
00054     delete m_fieldMan;
00055   }

xmlUtil::IdDict::IdDict DictNode   root [protected]
 

Following constructor may be used by friend IdConverter to build output dictionary.


Member Function Documentation

bool xmlUtil::IdDict::accept DictVisitor   vis,
unsigned    mask
 

Definition at line 62 of file IdDict.cxx.

References fieldManager, m_fieldMan, m_root, and nodeHierarchy.

00062                                                      {
00063     bool status = true;
00064 
00065     if (!vis->visitDict(this)) return false;
00066 
00067     if (mask & nodeHierarchy) 
00068       status = m_root->accept(vis);
00069 
00070     if (status && (mask & fieldManager)) {
00071       status &= m_fieldMan->accept(vis);
00072     }
00073     return status;
00074   }

bool xmlUtil::IdDict::accept DictVisitor   vis [virtual]
 

Reimplemented from xmlUtil::DictObject.

Definition at line 57 of file IdDict.cxx.

Referenced by isValid().

00057                                       {
00058     return accept(vis, 0xffffffff);
00059   }

bool xmlUtil::IdDict::addChild DictNode   parent,
DictNode   newNode
[protected]
 

Link up newNode to parent; also ask m_fieldMan to add the field if it's new.

Definition at line 103 of file IdDict.cxx.

00103                                                            {
00104     /* Started to write something to add field if not already
00105        registered, but whoever has created newNode should
00106        already have done this */
00107     return parent->addChild(newNode);
00108   }

const std::string& xmlUtil::IdDict::getDictName   const [inline]
 

Definition at line 71 of file IdDict.h.

References m_name.

Referenced by main().

00071 {return m_name;};

int xmlUtil::IdDict::getMajorVersion   const [inline]
 

Definition at line 72 of file IdDict.h.

References m_major.

00072 {return m_major;};

int xmlUtil::IdDict::getMinorVersion   const [inline]
 

Definition at line 73 of file IdDict.h.

References m_minor.

00073 {return m_minor;};

NamedId * xmlUtil::IdDict::getNamedId const Identifier   id const
 

Given an identifier, return a full NamedIdentifier (conceptually a sequence of (name, value) pairs).

Definition at line 97 of file IdDict.cxx.

References m_root.

00097                                                           {
00098     NamedId *named = new NamedId;
00099     m_root->allowIdentifier(id, named);
00100     return named;
00101   }

int xmlUtil::IdDict::getPatchVersion   const [inline]
 

Definition at line 74 of file IdDict.h.

References m_patch.

00074 {return m_patch;};

DictNode& xmlUtil::IdDict::getRoot   const [inline]
 

Definition at line 75 of file IdDict.h.

References m_root.

00075 {return *m_root;};

bool xmlUtil::IdDict::idOk const NamedId   id const
 

Verify that supplied named identifier is valid w.r.t. the idDict.

Definition at line 88 of file IdDict.cxx.

References m_root.

00088                                            {
00089     return m_root->allowNamedId(id);
00090   }

bool xmlUtil::IdDict::idOk const Identifier   id const
 

Verify that supplied identifier is valid w.r.t. the idDict.

Definition at line 84 of file IdDict.cxx.

References m_root.

00084                                               {
00085     return m_root->allowIdentifier(id);
00086   }

bool xmlUtil::IdDict::isValid  
 

Verify that dictionary is valid.

Definition at line 77 of file IdDict.cxx.

References accept().

Referenced by main().

00077                         {
00078     DictValidVisitor visitor;
00079 
00080     accept(&visitor);
00081     return visitor.wasValid();
00082   }

bool xmlUtil::IdDict::nameSeqOk const NameSeq   seq const
 

Verify that the sequence of field names corresponds to at least one valid identifier.

Definition at line 92 of file IdDict.cxx.

References m_root, and xmlUtil::NameSeq.

00092                                                  {
00093     return m_root->allowNameSeq(seq);
00094   }


Friends And Related Function Documentation

friend class IdConverter [friend]
 

Extra accept function to allow caller to choose among constituents of dictionary to visit. May choose all, just node hierarchy, or just field manager.

Definition at line 83 of file IdDict.h.


Member Data Documentation

DictFieldMan* xmlUtil::IdDict::m_fieldMan [protected]
 

Definition at line 101 of file IdDict.h.

Referenced by accept(), IdDict(), and ~IdDict().

int xmlUtil::IdDict::m_major [protected]
 

Definition at line 104 of file IdDict.h.

Referenced by getMajorVersion(), and IdDict().

int xmlUtil::IdDict::m_minor [protected]
 

Definition at line 105 of file IdDict.h.

Referenced by getMinorVersion(), and IdDict().

std::string xmlUtil::IdDict::m_name [protected]
 

Definition at line 103 of file IdDict.h.

Referenced by getDictName(), and IdDict().

int xmlUtil::IdDict::m_patch [protected]
 

Definition at line 106 of file IdDict.h.

Referenced by getPatchVersion(), and IdDict().

DictNode* xmlUtil::IdDict::m_root [protected]
 

Definition at line 102 of file IdDict.h.

Referenced by accept(), getNamedId(), getRoot(), IdDict(), idOk(), nameSeqOk(), and ~IdDict().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:02:50 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001