BinningProjectorXML.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 "BinningProjectorXML.h"
18 
19 #include "BinsBaseXML.h"
20 #include "NTupleXML.h"
21 
22 #include "XmlController.h"
23 #include "XmlDocument.h"
24 #include "XmlElement.h"
25 
26 #include "axes/Range.h"
27 #include "binners/BinsBase.h"
28 #include "datasrcs/DataSource.h"
30 
31 #include <cassert>
32 
33 using std::list;
34 using std::string;
35 using std::vector;
36 
37 using namespace hippodraw;
38 
40  : BaseXML ( "BinningProjector", controller )
41 {
42  m_binsbaseXML = new BinsBaseXML ( controller );
43  m_ntupleXML = new NTupleXML ( controller );
44 }
45 
48 {
49  delete m_binsbaseXML;
50  delete m_ntupleXML;
51 }
52 
53 XmlElement *
55 createElement ( const BinningProjector & projector )
56 {
57  XmlElement * tag = BaseXML::createElement (); // in base class
58  const void * addr = reinterpret_cast < const void * > ( & projector );
59  int id = m_controller -> getId ( addr );
60  setId ( *tag, id );
61 
62  createChildren ( tag, projector );
63 
64  return tag;
65 }
66 void
68 createChildren ( XmlElement * tag, const BinningProjector & projector )
69 {
70  const BinsBase * bins = projector.getBinner ();
71  XmlElement * element = m_binsbaseXML->createElement ( *bins );
72 
73  tag->appendChild ( *element );
74  delete element;
75 
76  BinningProjector & proj = const_cast < BinningProjector & > ( projector );
77  if ( projector.hasDataSourceBindings () == false ) {
78  proj.prepareValues ();
79  const DataSource * ntuple = projector.getProjectedValues ();
80  element = m_ntupleXML -> createElement ( *ntuple );
81 
82  tag -> appendChild ( *element );
83  delete element;
84  }
85 }
86 
87 void
89 getObject ( const XmlElement * parent, ProjectorBase * pbase )
90 {
91  const XmlElement * bp_element = getNode ( parent );
92  if ( bp_element == 0 ) return;
93 
94  const XmlElement * element = m_binsbaseXML->getNode ( bp_element );
95  BinsBase * bins = m_binsbaseXML->createObject ( element );
96 
97  BinningProjector * projector = dynamic_cast < BinningProjector * > ( pbase );
98  projector->setBinner ( bins );
99 }
100 
101 void
103 setBins ( const XmlElement * parent, ProjectorBase * pbase )
104 {
105  const XmlElement * bp_element = getNode ( parent );
106  if ( bp_element == 0 ) return;
107 
108  const XmlElement * nt_element = m_ntupleXML -> getNode ( bp_element );
109  const DataSource * ntuple = m_ntupleXML -> getObject ( *nt_element );
110 
111  BinningProjector * projector = dynamic_cast < BinningProjector * > ( pbase );
112  projector -> setBinContents ( ntuple );
113 }
XmlElement * createElement()
Creates a new element node.
Definition: BaseXML.cxx:43
A singleton class that is does XML serialization and deserialization of derived classes of NTuple...
Definition: NTupleXML.h:34
The BinningProjector is an abstract class provides most of the functionality for a projector that doe...
void setBinner(BinsBase *bins)
Sets the BinsBase object to be used by this projector.
virtual bool hasDataSourceBindings() const
Returns true if projector has binding to a DataSource.
void createChildren(XmlElement *tag, const BinningProjector &projector)
Create the child element nodes.
XmlDocument class interface.
XmlController class interface.
hippodraw::BinningProjector class interface
const XmlElement * getNode(const XmlElement *element) const
Returns the single child node of element of the type that can be handled by this object.
Definition: BaseXML.cxx:53
A pure virtual base class of XML element wrapper.
Definition: XmlElement.h:30
BinsBaseXML * m_binsbaseXML
The BinsBaseXML object used by this object.
void setBins(const XmlElement *parent, ProjectorBase *projector)
Sets the contents of the bins.
const DataSource * getProjectedValues() const
Returns DataSource representation of projected values.
void setId(XmlElement &tag, int id)
Sets the unique identification of the object.
Definition: BaseXML.cxx:64
hippodraw::DataSource class interface.
BinsBaseXML class interface.
NTupleXML * m_ntupleXML
The creator of the NTuple element node.
hippodraw::BinsBase class interface
virtual void appendChild(const XmlNode &child)=0
Appends a child element to the element.
const BinsBase * getBinner() const
Returns reference to BinsBase object used by this projector.
A class XML creation and parsing of XmlElement for BinsBase class.
Definition: BinsBaseXML.h:29
XmlController * m_controller
The singleton XML controller object.
Definition: BaseXML.h:60
XmlElement class interface.
void getObject(const XmlElement *parent, ProjectorBase *projector)
Sets the binning attributes of the projector from child nodes of the parent XML element.
The base class for the Projector hierarchy.
Definition: ProjectorBase.h:56
BinningProjectorXML class interface.
virtual BinsBase * createObject(const XmlElement *element)
Creates an object derived from BinsBaseBase.
Definition: BinsBaseXML.cxx:83
virtual void prepareValues()
Prepares the projector for plotting by executing, if needed, the binning procedure.
hippodraw::Range class interface
NTupleXML class interface.
A base class of XML element controllers.
Definition: BaseXML.h:35
BinningProjectorXML(const BinningProjectorXML &)
A private copy constructor in order to avoid copying.
XmlElement * createElement(const BinsBase &bins)
Returns a newly created XmlElement with attributes set for view.
Definition: BinsBaseXML.cxx:47
A base class that is the interface between GUI and the XML serialization and deserialization.
Definition: XmlController.h:53
The base class for the binner hierarchy.
Definition: BinsBase.h:33
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen