10#include <boost/algorithm/string.hpp>
11#include <boost/format.hpp>
13#include <Poco/DOM/Attr.h>
14#include <Poco/DOM/AutoPtr.h>
15#include <Poco/DOM/DOMParser.h>
16#include <Poco/DOM/DOMWriter.h>
17#include <Poco/DOM/Document.h>
18#include <Poco/DOM/Element.h>
19#include <Poco/DOM/Text.h>
27 AutoPtr<Document> pDoc =
new Document;
28 AutoPtr<Element> pDimensionElement = pDoc->createElement(
"Dimension");
29 pDoc->appendChild(pDimensionElement);
32 AutoPtr<Attr> idAttribute = pDoc->createAttribute(
"ID");
34 pDimensionElement->setAttributeNode(idAttribute);
37 AutoPtr<Element> nameElement = pDoc->createElement(
"Name");
38 AutoPtr<Text> nameText = pDoc->createTextNode(this->
getName());
39 nameElement->appendChild(nameText);
40 pDimensionElement->appendChild(nameElement);
43 AutoPtr<Element> unitsElement = pDoc->createElement(
"Units");
44 AutoPtr<Text> unitsText = pDoc->createTextNode(this->
getUnits());
45 unitsElement->appendChild(unitsText);
46 pDimensionElement->appendChild(unitsElement);
49 AutoPtr<Element> frameElement = pDoc->createElement(
"Frame");
50 AutoPtr<Text> frameText = pDoc->createTextNode(this->
getMDFrame().name());
51 frameElement->appendChild(frameText);
52 pDimensionElement->appendChild(frameElement);
55 AutoPtr<Element> upperBoundsElement = pDoc->createElement(
"UpperBounds");
56 AutoPtr<Text> upperBoundsText = pDoc->createTextNode(boost::str(boost::format(
"%.4f") % this->
getMaximum()));
57 upperBoundsElement->appendChild(upperBoundsText);
58 pDimensionElement->appendChild(upperBoundsElement);
61 AutoPtr<Element> lowerBoundsElement = pDoc->createElement(
"LowerBounds");
62 AutoPtr<Text> lowerBoundsText = pDoc->createTextNode(boost::str(boost::format(
"%.4f") % this->
getMinimum()));
63 lowerBoundsElement->appendChild(lowerBoundsText);
64 pDimensionElement->appendChild(lowerBoundsElement);
67 AutoPtr<Element> numberOfBinsElement = pDoc->createElement(
"NumberOfBins");
68 AutoPtr<Text> numberOfBinsText = pDoc->createTextNode(boost::str(boost::format(
"%.4d") % this->
getNBins()));
69 numberOfBinsElement->appendChild(numberOfBinsText);
70 pDimensionElement->appendChild(numberOfBinsElement);
74 AutoPtr<Element> integratedElement = pDoc->createElement(
"Integrated");
76 AutoPtr<Element> upperLimitElement = pDoc->createElement(
"UpperLimit");
77 AutoPtr<Text> upperLimitText =
78 pDoc->createTextNode(boost::str(boost::format(
"%.4f") % this->
getMaximum()));
81 upperLimitElement->appendChild(upperLimitText);
82 integratedElement->appendChild(upperLimitElement);
85 AutoPtr<Element> lowerLimitElement = pDoc->createElement(
"LowerLimit");
86 AutoPtr<Text> lowerLimitText =
87 pDoc->createTextNode(boost::str(boost::format(
"%.4f") % this->
getMinimum()));
90 lowerLimitElement->appendChild(lowerLimitText);
91 integratedElement->appendChild(lowerLimitElement);
93 pDimensionElement->appendChild(integratedElement);
97 std::stringstream xmlstream;
99 writer.writeNode(xmlstream, pDoc);
101 return xmlstream.str();
virtual bool getIsIntegrated() const
coord_t getMaximum() const override
Returns the maximum extent of this dimension.
coord_t getMinimum() const override
Returns the minimum extent of this dimension.
std::string toXMLString() const override
Dimensions must be xml serializable.
const MDFrame & getMDFrame() const override
Return the md frame.
const Kernel::UnitLabel getUnits() const override
Return the units of the dimension as a string.
std::string getName() const override
Return the name of the dimension as can be displayed along the axis.
const std::string & getDimensionId() const override
Short name which identify the dimension among other dimension.
size_t getNBins() const override
number of bins dimension have (an integrated has one).