#include <Constants.h>
Public Methods | |
| Constants (DOM_Document doc) | |
| void | normalizePrimary () |
| Fix up and length units that need fixing in <prim> elements. More... | |
| void | pruneConstants (const bool keepNotes=false) |
| After constants have been evaluated, remove child elements (except <notes> when argument says to keep them). More... | |
| void | evalConstants () |
| For each derCategory, evaluate each const child and save in "value" attribute. More... | |
Private Attributes | |
| DOM_Document | m_doc |
| DOM_Element | m_constants |
Definition at line 13 of file Constants.h.
|
|
Definition at line 125 of file Constants.cxx. References m_constants, and m_doc.
00125 : m_doc(doc) { 00126 DOM_NodeList list = m_doc.getElementsByTagName("constants"); 00127 00128 m_constants = (list.getLength() > 0) ? 00129 static_cast<const DOM_Element &> (list.item(0)) : DOM_Element(); 00130 } |
|
|
For each derCategory, evaluate each const child and save in "value" attribute. For each derCategory, evaluate each const child, writing value back to "value" attribute in the DOM Definition at line 207 of file Constants.cxx. References m_constants, and m_doc. Referenced by main().
00207 {
00208 if (m_constants == DOM_Node()) return;
00209 DOM_Element derived =
00210 xml::Dom::findFirstChildByName(m_constants, "derived");
00211 if (derived == DOM_Element()) return;
00212 if ((derived.getAttribute("evaluated")).equals(DOMString("true"))) return;
00213
00214 DOM_Element curConst;
00215
00216 DOM_NodeList cats = m_doc.getElementsByTagName("derCategory");
00217 int nCats = cats.getLength();
00218 int iCat;
00219
00220 for (iCat = 0; iCat < nCats; iCat++) {
00221 DOM_Node catNode = cats.item(iCat);
00222 DOM_Element& curCat = static_cast<DOM_Element&> (catNode);
00223 curConst = xml::Dom::findFirstChildByName(curCat, "const" );
00224
00225 while (curConst != DOM_Element()) {
00226 Arith curArith(curConst);
00227 double evalValue = curArith.evaluate();
00228 curArith.saveValue();
00229
00230 curConst = xml::Dom::getSiblingElement(curConst);
00231 }
00232 }
00233 derived.setAttribute("evaluated", "true");
00234 }
|
|
|
Fix up and length units that need fixing in <prim> elements.
Definition at line 132 of file Constants.cxx. References m_constants, and m_doc. Referenced by main().
00133 {
00134 // find <primary>
00135 if (m_constants == DOM_Node()) return;
00136
00137 DOM_NodeList primarys = m_constants.getElementsByTagName("primary");
00138
00139 // must be precisely one <primary> element
00140 DOM_Node curNode = primarys.item(0);
00141 DOM_Element primary = static_cast<DOM_Element &>(curNode);
00142 if (primary.getAttribute("normalized").equals(DOMString("true"))) return;
00143
00144 // Make a DOMTreeWalker which returns only elements
00145 unsigned long whatToShow = 1 << (DOM_Node::ELEMENT_NODE -1);
00146
00147 DOM_TreeWalker walker =
00148 m_doc.createTreeWalker(curNode, whatToShow, 0, 0);
00149
00150 // Diagnostic -- number of <prim>s seen
00151 int count = 0;
00152 std::vector<DOM_Element> energyElts;
00153 while (curNode != DOM_Node() ) {
00154 count += normPrim(static_cast<DOM_Element &> (curNode), energyElts);
00155 curNode = walker.nextNode();
00156 }
00157 handleEnergies(energyElts);
00158
00159 primary.setAttribute("normalized", "true");
00160 // std::cout << "Results of normalizePrim: " << count << std::endl;
00161 // return (count < 100000);
00162 }
|
|
|
After constants have been evaluated, remove child elements (except <notes> when argument says to keep them).
Definition at line 165 of file Constants.cxx. References m_constants. Referenced by main().
00165 {
00166
00167 if (m_constants == DOM_Node()) return;
00168
00169 DOM_Element curConst;
00170
00171 // For each derCategory, prune each const child
00172 DOM_NodeList cats = m_constants.getElementsByTagName("derCategory");
00173 int nCats = cats.getLength();
00174 int iCat;
00175
00176 for (iCat = 0; iCat < nCats; iCat++) {
00177 DOM_Node catNode = cats.item(iCat);
00178 DOM_Element& curCat = static_cast<DOM_Element&> (catNode);
00179 curConst = xml::Dom::findFirstChildByName(curCat, "const" );
00180
00181 while (curConst != DOM_Element()) {
00182 if (keepNotes) { // tread more carefully
00183 DOM_Element child = xml::Dom::getFirstChildElement(curConst);
00184 if (child != DOM_Element() ) {
00185 if ((child.getTagName()).equals(DOMString("notes"))) {
00186 child = xml::Dom::getSiblingElement(child);
00187 if (child != DOM_Element()) {
00188 xml::Dom::prune(child);
00189 (child.getParentNode()).removeChild(child);
00190 }
00191 }
00192 else {
00193 xml::Dom::prune(curConst); // remove all its children
00194 }
00195 }
00196 }
00197 else { // remove all its children
00198 xml::Dom::prune(curConst);
00199 }
00200 curConst = xml::Dom::getSiblingElement(curConst);
00201 }
00202 }
00203 }
|
|
|
Definition at line 27 of file Constants.h. Referenced by Constants(), evalConstants(), normalizePrimary(), and pruneConstants(). |
|
|
Definition at line 26 of file Constants.h. Referenced by Constants(), evalConstants(), and normalizePrimary(). |
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001