BinnerAxisXML.cxx
Go to the documentation of this file.
1 
12 // for truncation warning
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "BinnerAxisXML.h"
18 
19 #include "XmlElement.h"
20 
21 #include "binners/BinnerAxis.h"
23 
24 #include <cassert>
25 
26 using std::string;
27 
28 namespace hippodraw {
29 
31  : BaseXML ( "BinnerBase", controller ),
32  m_width ( "width" ),
33  m_high ( "high" ),
34  m_low ( "low" )
35 {
36 }
37 
38 XmlElement *
40 createElement ( const BinnerAxis & binner )
41 {
43  setAttributes ( tag, binner );
44 
45  return tag;
46 }
47 
48 void
50 setAttributes ( XmlElement * tag, const BinnerAxis & binner )
51 {
52  const string & type = binner.name();
53  tag->setAttribute ( m_type, type );
54 
55  const Range & range = binner.getRange ();
56  double high = range.high();
57  double low = range.low ();
58 
59  tag->setAttribute ( m_high, high );
60  tag->setAttribute ( m_low, low );
61 
62  double width = binner.getBinWidth ();
63  tag->setAttribute ( m_width, width );
64 }
65 
66 BinnerAxis *
68 createObject ( const XmlElement * element )
69 {
70  string type;
71  bool ok = element->attribute ( m_type, type );
72  assert ( ok );
73 
75  BinnerAxis * binner = factory->create ( type );
76 
77  double high = 1.0;
78  double low = 0.0;
79  ok = element->attribute ( m_high, high );
80  ok &= element->attribute ( m_low, low );
81  assert ( ok );
82  Range range ( low, high );
83  binner->setRange ( range, false );
84 
85  double width = -1.0;
86  ok = element->attribute ( m_width, width );
87  assert ( ok );
88  binner->setBinWidth ( width );
89 
90  return binner;
91 }
92 
93 } // namespace hippodraw
94 

Generated for HippoDraw Class Library by doxygen