14 #include "msdevstudio/MSconfig.h"
33 using std::istringstream;
35 using std::istream_iterator;
40 using namespace hippodraw;
43 :
BaseXML (
"NTuple", controller ),
45 m_col_name (
"column" ),
46 m_data (
"NTupleData" ),
67 const void * addr = reinterpret_cast <
const void * > ( & ntuple );
71 const string & full_name = ntuple.
getName ();
72 tag -> setAttribute (
m_name, full_name );
75 namespace dp = hippodraw::DataPoint2DTuple;
81 unsigned int columns = ntuple.
columns ();
90 static unsigned int cols []
97 const string & label = ntuple.
getLabelAt ( cols[
i] );
98 element -> setAttribute (
m_label, label );
100 const vector < double > &
data = ntuple.
getColumn ( cols[i] );
104 for (
unsigned int j = 0; j <
size; j++ ) {
111 element -> appendChild ( *node );
114 tag -> appendChild ( *element );
127 tag -> appendChild ( *node );
137 #ifndef STRING_CLEAR_DEFECT // change to ifdef when M4 macro is implemented
138 if ( ! ok ) name.erase ( name.begin(), name.end() );
140 if ( ! ok ) name.clear();
148 list < XmlElement * > nodelist;
150 unsigned int size = nodelist.size ();
153 vector < vector < double > > columns ( size );
154 vector < string > labels ( size );
156 list < XmlElement * >::const_iterator first = nodelist.begin ();
157 while ( first != nodelist.end() ) {
163 ok = elem -> attribute (
m_label, label );
166 const string & text = elem -> getText ();
167 istringstream stream ( text );
169 copy ( istream_iterator<double> ( stream ),
170 istream_iterator<double> (), back_inserter ( columns[column] ) );
174 for (
unsigned int i = 0;
i <
size;
i++ ) {
175 ntuple -> addColumn ( labels[
i], columns[i] );
NTupleXML(const NTupleXML &)
A private copy constructor in order to avoid copying.
const DataSource * getObject(const XmlElement &tag)
Returns the DataSource corresponding to XmlElement.
XmlElement * createElement()
Creates a new element node.
std::string m_col_name
the attribute name for the column index.
virtual bool attribute(const std::string &name, bool &value) const =0
Sets value to the attribute name's value.
XmlDocument class interface.
void * data(numeric::array arr)
XmlController class interface.
column
The column indices for 2 dimension data point tuple.
A pure virtual base class of XML element wrapper.
XmlTextNode class interface.
The namespace for conversion to string.
virtual const std::vector< double > & getColumn(const std::string &name) const
Returns the data in the column with label name.
void setId(XmlElement &tag, int id)
Sets the unique identification of the object.
hippodraw::NTuple class interface.
void createChildren(XmlElement *tag, const DataSource &ntuple)
Creates the Dom text node children.
error on X or half bin width
virtual void fillNodeList(const std::string &tagName, std::list< XmlElement * > &nodeList) const =0
Fills the nodeList with elements with tag name tagName.
intp size(numeric::array arr)
std::string m_name
The tag name for the name attribute.
string convert(int i)
Converts an integer to a string.
std::string getName(const XmlElement &tag) const
Returns the name of the NTuple object.
A pure virtual base class of XML DOM Text node wrapper.
XmlController * m_controller
The singleton XML controller object.
XmlElement class interface.
A DataSource class implemented with std::vector<double> to store the column data. ...
std::string m_data
The tag name of the column data.
void setAttributes(XmlElement *tag, const DataSource &ntuple)
Sets the attributes.
static XmlDocument * m_xml_doc
The current document being generated or read.
virtual unsigned int rows() const =0
Returns the number of rows.
void createChildren2D(XmlElement *tag, const DataSource &ntuple)
Creates the Dom text node children for 1D histograms.
NTupleXML class interface.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
A base class of XML element controllers.
hippodraw::DataPointTuple namespace interface
hippodraw::NTupleController class interface
void createChildren3D(XmlElement *tag, const DataSource &ntuple)
Creates the Dom text node children for 2D histograms.
A base class that is the interface between GUI and the XML serialization and deserialization.
virtual const std::string & getLabelAt(unsigned int index) const
Returns the label for the column at index index.
const std::string & getName() const
Returns the name of the data source.
std::string m_label
The attribute name of the column label.
Base class for DataSource.