ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
IdDictParserNS::RangeFactory Class Reference
Inheritance diagram for IdDictParserNS::RangeFactory:
Collaboration diagram for IdDictParserNS::RangeFactory:

Public Member Functions

void idd_start (IdDictParser &parser, const XMLCoreNode &node)
 
virtual void idd_end (IdDictParser &parser, const XMLCoreNode &node)
 
void do_start (XMLCoreParser &parser, const XMLCoreNode &node)
 
void do_end (XMLCoreParser &parser, const XMLCoreNode &node)
 
void start (XMLCoreParser &parser, const XMLCoreNode &node)
 
void end (XMLCoreParser &parser, const XMLCoreNode &node)
 
void comment (XMLCoreParser &parser, const std::string &comment)
 
virtual void do_comment (XMLCoreParser &parser, const std::string &comment)
 
std::string get_name (const XMLCoreNode &node)
 
int sibling_number (const XMLCoreNode &node)
 

Static Public Member Functions

static std::string get_name (const XMLCoreNode &node, int index)
 
static int attribute_number (const XMLCoreNode &node)
 
static bool has_attribute (const XMLCoreNode &node, const std::string &name)
 
static int get_int (const XMLCoreNode &node, const std::string &name)
 
static double get_double (const XMLCoreNode &node, const std::string &name)
 
static bool get_boolean (const XMLCoreNode &node, const std::string &name)
 
static std::string get_ID (const XMLCoreNode &node, const std::string &name)
 
static std::string get_value (const XMLCoreNode &node, const std::string &name)
 
static std::string get_token (const XMLCoreNode &node, const std::string &name)
 
static bool check_int (const int n, const XMLCoreNode &node, const std::string &name)
 
static bool check_double (const int n, const XMLCoreNode &node, const std::string &name)
 

Protected Attributes

std::string m_xmlelementname
 

Detailed Description

Definition at line 88 of file IdDictParser.cxx.

Member Function Documentation

◆ attribute_number()

int XMLCoreFactory::attribute_number ( const XMLCoreNode node)
staticinherited

Definition at line 111 of file XMLCoreParser.cxx.

111  {
112  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
113  return (attrs.size ());
114 }

◆ check_double()

bool XMLCoreFactory::check_double ( const int  n,
const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 239 of file XMLCoreParser.cxx.

239  {
240  std::string checkstring = get_value (node, name);
241  int counter = 0;
242  //
243  // concatenate two times same string to
244  // check the last number of the string
245  // explicitly!
246  //
247  std::string t = checkstring + " " + checkstring;
248  std::istringstream tmpstr (t.c_str());
249  while (tmpstr.good ()) {
250  double ii{};
251  counter++;
252  tmpstr >> ii;
253  }
254  if (counter/2 != n) {
255  std::cerr << "XMLCoreFactory::check_double error: (" << counter << ") no " << n
256  << " doubles in \"" << checkstring << "\" for attribute " <<
257  name << ". exit." << std::endl;
258  std::string name1 = get_value (node, "name");
259  std::string volume = get_value (node, "volume");
260  if (name1 != "" ) std::cerr << "for name=" << name << std::endl;
261  if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
262  std::abort();
263  }
264  return true;
265 }

◆ check_int()

bool XMLCoreFactory::check_int ( const int  n,
const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 207 of file XMLCoreParser.cxx.

207  {
208  std::string checkstring = get_value (node, name);
209  int counter = 0;
210  //
211  // concatenate two times same string to
212  // check the last number of the string
213  // explicitly!
214  //
215  std::string t = checkstring + " " + checkstring;
216  std::istringstream tmpstr (t.c_str());
217  while (tmpstr.good ()) {
218  int ii;
219  counter++;
220  tmpstr >> ii;
221  }
222  if (counter/2 != n) {
223  std::cerr << "XMLCoreFactory::check_int error: no " << n
224  << " ints in \"" << checkstring << "\" for attribute " <<
225  name << ". exit." << std::endl;
226 
227  std::string nodename = get_value (node, "name");
228  std::string volume = get_value (node, "volume");
229 
230  if (nodename != "" ) std::cerr << "for name=" << nodename << std::endl;
231  if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
232 
233  std::abort();
234  }
235  return true;
236 }

◆ comment()

void XMLCoreFactory::comment ( XMLCoreParser parser,
const std::string &  comment 
)
inherited

Definition at line 82 of file XMLCoreParser.cxx.

82  {
84  std::cout << "XMLCoreFactory::comment>" << std::endl;
85  }
87 }

◆ do_comment()

void XMLCoreFactory::do_comment ( XMLCoreParser parser,
const std::string &  comment 
)
virtualinherited

Definition at line 104 of file XMLCoreParser.cxx.

104  {
106  std::cout << "XMLCoreFactory::do_comment>" << std::endl;
107  }
108 }

◆ do_end()

void IdDictBaseFactory::do_end ( XMLCoreParser parser,
const XMLCoreNode node 
)
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 152 of file IdDictParser.cxx.

152  {
153  idd_end (static_cast<IdDictParser&>(parser), node);
154  parser.down ();
155 }

◆ do_start()

void IdDictBaseFactory::do_start ( XMLCoreParser parser,
const XMLCoreNode node 
)
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 145 of file IdDictParser.cxx.

146  {
147  parser.up ();
148  idd_start (static_cast<IdDictParser&>(parser), node);
149 }

◆ end()

void XMLCoreFactory::end ( XMLCoreParser parser,
const XMLCoreNode node 
)
inherited

Definition at line 74 of file XMLCoreParser.cxx.

74  {
76  std::cout << "XMLCoreFactory::end>" << std::endl;
77  }
78  do_end (parser, node);
79 }

◆ get_boolean()

bool XMLCoreFactory::get_boolean ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 141 of file XMLCoreParser.cxx.

141  {
142  bool result = false;
143  std::string s = get_token (node, name);
144  if (s == "TRUE") result = true;
145  return (result);
146 }

◆ get_double()

double XMLCoreFactory::get_double ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 133 of file XMLCoreParser.cxx.

133  {
134  double result = 0;
135  std::string s = get_value (node, name);
136  sscanf (s.c_str (), "%80lg", &result);
137  return (result);
138 }

◆ get_ID()

std::string XMLCoreFactory::get_ID ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 148 of file XMLCoreParser.cxx.

148  {
149  std::string result = get_value (node, name);
150  return (result);
151 }

◆ get_int()

int XMLCoreFactory::get_int ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 125 of file XMLCoreParser.cxx.

125  {
126  int result = 0;
127  std::string s = get_value (node, name);
128  sscanf (s.c_str (), "%80d", &result);
129  return (result);
130 }

◆ get_name() [1/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode node)
inherited

Definition at line 169 of file XMLCoreParser.cxx.

169  {
170  return node.get_node().get_name ();
171 }

◆ get_name() [2/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode node,
int  index 
)
staticinherited

Definition at line 179 of file XMLCoreParser.cxx.

179  {
180  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
181  CoreParser::DOMNamedNodeMap::const_iterator it;
182  for (it = attrs.begin (); (index > 0) && (it != attrs.end ()); ++it){
183  --index;
184  }
185  if (it == attrs.end ()) return ("");
186  return it->first;
187 }

◆ get_token()

std::string XMLCoreFactory::get_token ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 190 of file XMLCoreParser.cxx.

190  {
191  std::string result = get_value (node, name);
192  // trim the value
193  while ((result.length () > 0) &&
194  (result.at(0) == ' ')) result.erase (0, 1);
195 
196  while ((result.length () > 0) &&
197  (result.at(result.length () - 1) == ' ')) result.erase (result.length () - 1, 1);
198  // Convert to upper case
199  for (std::string::size_type i = 0; i < result.length (); ++i){
200  result[i] = std::toupper (result[i]);
201  }
202  return (result);
203 }

◆ get_value()

std::string XMLCoreFactory::get_value ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 154 of file XMLCoreParser.cxx.

154  {
156  std::cout << "XMLCoreFactory::get_value> name=" << name << std::endl;
157  }
158  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
159  CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
160  if (it == attrs.end ()) return ("");
161  std::string result = (*it).second;
163  std::cout << "XMLCoreFactory::get_value>2 value=" << result << std::endl;
164  }
165  return (result);
166 }

◆ has_attribute()

bool XMLCoreFactory::has_attribute ( const XMLCoreNode node,
const std::string &  name 
)
staticinherited

Definition at line 117 of file XMLCoreParser.cxx.

117  {
118  const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
119  CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
120  if (it == attrs.end ()) return (false);
121  return (true);
122 }

◆ idd_end()

void RegionEntryFactory::idd_end ( IdDictParser parser,
const XMLCoreNode node 
)
virtualinherited

Reimplemented from IdDictParserNS::IdDictBaseFactory.

Definition at line 530 of file IdDictParser.cxx.

530  {
531  if (Debugger::debug ()) {
532  Debugger::tab (parser.level());
533  std::cout << "RegionEntryFactory::idd_end>" << std::endl;
534  }
535  if (parser.m_regionentry != 0){
536  if (parser.m_region != 0) parser.m_region->add_entry (parser.m_regionentry);
537  else if (parser.m_subregion != 0) parser.m_subregion->add_entry (parser.m_regionentry);
538  else delete parser.m_regionentry;
539  parser.m_regionentry = 0;
540  }
541 }

◆ idd_start()

void RangeFactory::idd_start ( IdDictParser parser,
const XMLCoreNode node 
)
virtual

Reimplemented from IdDictParserNS::RegionEntryFactory.

Definition at line 544 of file IdDictParser.cxx.

544  {
545  if (Debugger::debug ()) {
546  Debugger::tab (parser.level());
547  std::cout << "RangeFactory::idd_start>" << std::endl;
548  }
549  IdDictRange* range = new IdDictRange;
550  parser.m_regionentry = range;
551  range->m_field_name = get_value (node, "field");
552  range->m_field = 0;
553  range->m_specification = IdDictRange::unknown;
554  range->m_continuation_mode = IdDictRange::none;
555  range->m_prev_value = 0;
556  range->m_next_value = 0;
557  if (has_attribute (node, "value")){
558  range->m_specification = IdDictRange::by_label;
559  range->m_label = get_value (node, "value");
560  } else if (has_attribute (node, "values")) {
561  range->m_specification = IdDictRange::by_labels;
562  std::string labels = get_value (node, "values");
563  std::string::size_type pos = 0;
564  for (;;){
565  std::string::size_type next;
566  next = labels.find_first_not_of (" ", pos);
567  if (next == std::string::npos) break;
568  pos = next;
569  next = labels.find_first_of (" ", pos);
570  std::string label;
571  label = labels.substr (pos, next - pos);
572  range->m_labels.push_back (label);
573  if (next == std::string::npos) {
574  break;
575  } else {
576  pos = next;
577  }
578  }
579  } else {
580  const bool hasMin = has_attribute (node, "minvalue");
581  const bool hasMax = has_attribute (node, "maxvalue");
582  if (hasMin and hasMax) {
583  range->m_specification = IdDictRange::by_minmax;
584  range->m_minvalue = get_int (node, "minvalue");
585  range->m_maxvalue = get_int (node, "maxvalue");
586  }
587  //falls through to a case where there is *no* attribute value, values, minvalue, maxvalue
588  //https://its.cern.ch/jira/browse/ATLASSIM-7295
589  }
590  if (has_attribute (node, "wraparound")){
591  bool wraparound = get_boolean (node, "wraparound");
592  if (wraparound) range->m_continuation_mode = IdDictRange::wrap_around;
593  }
594  if (has_attribute (node, "prev_value")){
595  range->m_prev_value = get_int (node, "prev_value");
596  range->m_continuation_mode = IdDictRange::has_previous;
597  }
598  if (has_attribute (node, "next_value")) {
599  range->m_next_value = get_int (node, "next_value");
600  if (IdDictRange::has_previous == range->m_continuation_mode){
601  range->m_continuation_mode = IdDictRange::has_both;
602  } else {
603  range->m_continuation_mode = IdDictRange::has_next;
604  }
605  }
606 }

◆ sibling_number()

int XMLCoreFactory::sibling_number ( const XMLCoreNode node)
inherited

Definition at line 174 of file XMLCoreParser.cxx.

174  {
175  return node.get_node ().sibling_number ();
176 }

◆ start()

void XMLCoreFactory::start ( XMLCoreParser parser,
const XMLCoreNode node 
)
inherited

Definition at line 66 of file XMLCoreParser.cxx.

66  {
68  std::cout << "XMLCoreFactory::start> factory=" << this << std::endl;
69  }
70  do_start (parser, node);
71 }

Member Data Documentation

◆ m_xmlelementname

std::string XMLCoreFactory::m_xmlelementname
protectedinherited

Definition at line 94 of file XMLCoreParser.h.


The documentation for this class was generated from the following file:
XMLCoreFactory::do_comment
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:104
python.PoolAttributeHelper.attrs
list attrs
Definition: PoolAttributeHelper.py:89
ReadCellNoiseFromCool.name1
name1
Definition: ReadCellNoiseFromCool.py:233
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictRange::by_minmax
@ by_minmax
Definition: IdDictRange.h:40
index
Definition: index.py:1
IdDictParserNS::IdDictBaseFactory::idd_start
virtual void idd_start(IdDictParser &parser, const XMLCoreNode &node)
Definition: IdDictParser.cxx:157
IdDictRange::by_label
@ by_label
Definition: IdDictRange.h:38
XMLCoreFactory::has_attribute
static bool has_attribute(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:117
CoreParser::DOMNamedNodeMap
std::map< std::string, std::string > DOMNamedNodeMap
Definition: DOMNode.h:14
skel.it
it
Definition: skel.GENtoEVGEN.py:407
IdDictRange::by_labels
@ by_labels
Definition: IdDictRange.h:39
IdDictRange::none
@ none
Definition: IdDictRange.h:44
XMLCoreFactory::get_int
static int get_int(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:125
XMLCoreFactory::get_boolean
static bool get_boolean(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:141
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
IdDictParserNS::Debugger::tab
static void tab(int n)
Definition: IdDictParser.cxx:27
IdDictParserNS::IdDictBaseFactory::idd_end
virtual void idd_end(IdDictParser &parser, const XMLCoreNode &node)
Definition: IdDictParser.cxx:161
IdDictRange::has_previous
@ has_previous
Definition: IdDictRange.h:46
python.CaloAddPedShiftConfig.parser
parser
Definition: CaloAddPedShiftConfig.py:41
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1446
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictRange::has_both
@ has_both
Definition: IdDictRange.h:47
beamspotman.n
n
Definition: beamspotman.py:729
XMLCoreFactory::get_value
static std::string get_value(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:154
XMLCoreFactory::do_start
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:90
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
IdDictRange::unknown
@ unknown
Definition: IdDictRange.h:35
IdDictParser
Definition: IdDictParser.h:12
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
IdDictRange::has_next
@ has_next
Definition: IdDictRange.h:45
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
IdDictRange
Definition: IdDictRange.h:18
DeMoScan.index
string index
Definition: DeMoScan.py:362
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
XMLCoreFactory::get_token
static std::string get_token(const XMLCoreNode &node, const std::string &name)
Definition: XMLCoreParser.cxx:190
IdDictRange::wrap_around
@ wrap_around
Definition: IdDictRange.h:48
test_pyathena.counter
counter
Definition: test_pyathena.py:15
XMLCoreFactory::comment
void comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:82
node
Definition: node.h:21
IdDictParserNS::Debugger::debug
static bool debug()
Definition: IdDictParser.cxx:22
XMLCoreFactory::do_end
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:97