NTupleProjectorXML.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 "NTupleProjectorXML.h"
18 
19 #include "XmlController.h"
20 #include "XmlDocument.h"
21 #include "XmlElement.h"
22 
23 #include "datasrcs/TupleCut.h"
24 #include "pattern/string_convert.h"
26 
27 #include <cassert>
28 
29 using std::list;
30 using std::string;
31 using std::vector;
32 
33 using namespace hippodraw;
34 
36  : BaseXML ( "NTupleProjector", controller )
37 {
38 }
39 
40 void
43  const NTupleProjector & projector )
44 {
45  const vector < const TupleCut * > & cutlist = projector.getCutList ();
46  if ( cutlist.empty() ) return;
47 
48 #ifdef ITERATOR_MEMBER_DEFECT
49  std::
50 #endif
51  vector < const TupleCut * >::const_iterator first = cutlist.begin();
52  for ( ; first != cutlist.end(); ++first ) {
53  const TupleCut * cut = *first;
54  const void * addr = reinterpret_cast < const void * > ( cut );
55  int ref = m_controller -> getId ( addr );
56  XmlElement * element
57  = XmlController::m_xml_doc->createElement ( "TupleCutRef" );
58  element->setAttribute ( "ref", ref );
59  tag.appendChild ( *element );
60  delete element;
61  }
62 
63 }
64 
65 XmlElement *
67 {
68  XmlElement * tag = BaseXML::createElement (); // in base class
69  const void * addr = reinterpret_cast < const void * > ( & projector );
70  int id = m_controller -> getId ( addr );
71  setId ( *tag, id );
72 
73  const DataSource * ntuple = projector.getNTuple ();
74 
75  XmlElement * element = m_controller->addDataSource ( ntuple );
76 
77  int ref = element->getID ();
78  tag->setAttribute ( "ref", ref );
79 
80  const vector < string > & bindings = projector.getAxisBindings();
81  unsigned int size = bindings.size();
82 
83  for ( unsigned int i = 0; i < size; i++ ) {
84  string name ( "Axis" );
85  name += String::convert ( i );
86  const string & label = bindings[i];
87  tag -> setAttribute ( name, label );
88  }
89 
90  createChildren ( *tag, projector );
91 
92  return tag;
93 }
94 
96 {
97  int ref;
98  bool ok = element->attribute ( "ref", ref );
99  if ( ! ok ) return 0;
100 
101  return ref;
102 }
103 
104 void
106 getBindings ( const XmlElement * element,
107  std::vector < std::string > & bindings ) const
108 {
109  bindings.clear();
110 
111  for ( int i = 0; ; i++ ) {
112  string label;
113  string name ( "Axis" );
114  name += String::convert ( i );
115  bool ok = element -> attribute ( name, label );
116  if ( ! ok ) break;
117 
118  bindings.push_back ( label );
119  }
120 
121 }

Generated for HippoDraw Class Library by doxygen