Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
xml
BinsBaseXML.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 "
BinsBaseXML.h
"
18
19
#include "
BinnerAxisXML.h
"
20
#include "
XmlElement.h
"
21
22
#include "
binners/BinsBase.h
"
23
#include "
binners/BinsFactory.h
"
24
25
#include <cassert>
26
27
using
std::list;
28
using
std::string;
29
30
namespace
hippodraw {
31
32
BinsBaseXML::BinsBaseXML
(
XmlController
* controller )
33
:
BaseXML
(
"BinsBase"
, controller ),
34
m_axis (
"axis"
)
35
{
36
m_binnerXML
=
new
BinnerAxisXML
( controller );
37
}
38
39
BinsBaseXML::
40
~BinsBaseXML
()
41
{
42
delete
m_binnerXML
;
43
}
44
45
XmlElement
*
46
BinsBaseXML::
47
createElement
(
const
BinsBase
& bins )
48
{
49
XmlElement
* tag =
BaseXML::createElement
();
50
const
string
&
type
= bins.
name
();
51
tag->
setAttribute
(
m_type
, type );
52
53
createChildren
( *tag, bins );
54
55
return
tag;
56
}
57
58
59
void
60
BinsBaseXML::
61
createChildren
(
XmlElement
& tag,
const
BinsBase
& bins )
62
{
63
const
BinnerAxis
* binner = bins.
getBinnerOn
(
Axes::X
);
64
XmlElement
* element =
m_binnerXML
->
createElement
( *binner );
65
string
axis (
"X"
);
66
element->
setAttribute
(
m_axis
, axis );
67
tag.
appendChild
( *element );
68
delete
element;
69
70
int
number = bins.
getNumberOfAxes
();
71
if
( number < 2 )
return
;
72
73
binner = bins.
getBinnerOn
(
Axes::Y
);
74
element =
m_binnerXML
->
createElement
( *binner );
75
axis =
"Y"
;
76
element->
setAttribute
(
m_axis
, axis );
77
tag.
appendChild
( *element );
78
delete
element;
79
}
80
81
BinsBase
*
82
BinsBaseXML::
83
createObject
(
const
XmlElement
* binsbase )
84
{
85
string
type
;
86
bool
ok = binsbase->
attribute
(
m_type
, type );
87
assert ( ok );
88
89
BinsFactory
* factory =
BinsFactory::instance
();
90
BinsBase
* bins = factory->
create
( type );
91
92
list < XmlElement * > nodelist;
93
m_binnerXML
->
fillNodeList
( binsbase, nodelist );
94
95
list < XmlElement * > :: const_iterator first = nodelist.begin();
96
while
( first != nodelist.end() ) {
97
XmlElement
* element = *first++;
98
BinnerAxis
* binner =
m_binnerXML
->
createObject
( element );
99
string
axis;
100
bool
ok = element->
attribute
(
m_axis
, axis );
101
assert ( ok );
102
103
Axes::Type
type = axis ==
"X"
?
Axes::X
:
Axes::Y
;
104
bins->
setBinnerOn
( binner, type );
105
}
106
107
return
bins;
108
}
109
110
}
// namespace hippodraw
111
Generated for HippoDraw Class Library by