ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuctpiXMLHelper Class Reference

#include <MuctpiXMLHelper.h>

Inheritance diagram for MuctpiXMLHelper:
Collaboration diagram for MuctpiXMLHelper:

Public Member Functions

 MuctpiXMLHelper ()
 
std::string readAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
bool hasAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
std::string getAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
std::string getAttribute (const boost::property_tree::ptree &tree, const std::string &attr, const std::string &defval)
 
int getIntAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
int getIntAttribute (const boost::property_tree::ptree &tree, const std::string &attr, int defval)
 
unsigned int getUIntAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
unsigned int getUIntAttribute (const boost::property_tree::ptree &tree, const std::string &attr, unsigned int &defval)
 
float getFloatAttribute (const boost::property_tree::ptree &tree, const std::string &attr)
 
float getFloatAttribute (const boost::property_tree::ptree &tree, const std::string &attr, float &defval)
 
void printAttributes (const boost::property_tree::ptree &tree)
 

Private Member Functions

bool msgLvl (const MSGTC::Level lvl) const
 Test the output level. More...
 
MsgStreamTC & msg () const
 The standard message stream. More...
 
MsgStreamTC & msg (const MSGTC::Level lvl) const
 The standard message stream. More...
 

Private Attributes

boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels) More...
 
std::string m_name
 

Detailed Description

Definition at line 13 of file MuctpiXMLHelper.h.

Constructor & Destructor Documentation

◆ MuctpiXMLHelper()

MuctpiXMLHelper::MuctpiXMLHelper ( )

Definition at line 12 of file MuctpiXMLHelper.cxx.

12  :
13  TrigConf::TrigConfMessaging("MuctpiXML")
14 {}

Member Function Documentation

◆ getAttribute() [1/2]

std::string MuctpiXMLHelper::getAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 67 of file MuctpiXMLHelper.cxx.

67  {
68  if( ! hasAttribute(tree, attr) ) {
69  TRG_MSG_WARNING("attribute " << attr << " does not exist");
70  return "";
71  }
72  return readAttribute(tree,attr);
73 }

◆ getAttribute() [2/2]

std::string MuctpiXMLHelper::getAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr,
const std::string &  defval 
)

Definition at line 76 of file MuctpiXMLHelper.cxx.

76  {
77  if( ! hasAttribute(tree, attr) )
78  return defval;
79  return readAttribute(tree,attr);
80 }

◆ getFloatAttribute() [1/2]

float MuctpiXMLHelper::getFloatAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 140 of file MuctpiXMLHelper.cxx.

140  {
141  if( ! hasAttribute(tree, attr) ) {
142  TRG_MSG_WARNING("attribute " << attr << " does not exist");
143  return 0;
144  }
145  float ret_value{0};
146  try {
147  ret_value = boost::lexical_cast<float, string>(readAttribute(tree,attr));
148  }
149  catch(const boost::bad_lexical_cast & bc) {
150  TRG_MSG_ERROR("attribute '" << attr << "' is not an float (it is " << readAttribute(tree,attr) << ")");
152  }
153  return ret_value;
154 }

◆ getFloatAttribute() [2/2]

float MuctpiXMLHelper::getFloatAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr,
float &  defval 
)

Definition at line 157 of file MuctpiXMLHelper.cxx.

157  {
158  if( ! hasAttribute(tree, attr) )
159  return defval;
160  return boost::lexical_cast<float, string>(readAttribute(tree,attr));
161 }

◆ getIntAttribute() [1/2]

int MuctpiXMLHelper::getIntAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 84 of file MuctpiXMLHelper.cxx.

84  {
85  if( ! hasAttribute(tree, attr) ) {
86  TRG_MSG_WARNING("attribute " << attr << " does not exist");
87  return 0;
88  }
89 
90  int ret_value{0};
91  try {
92  ret_value = boost::lexical_cast<int, string>(readAttribute(tree,attr));
93  }
94  catch(const boost::bad_lexical_cast & bc) {
95  TRG_MSG_ERROR("attribute '" << attr << "' is not an int (it is '" << readAttribute(tree,attr) << "')");
96  }
97  return ret_value;
98 }

◆ getIntAttribute() [2/2]

int MuctpiXMLHelper::getIntAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr,
int  defval 
)

Definition at line 101 of file MuctpiXMLHelper.cxx.

101  {
102  if( ! hasAttribute(tree, attr) )
103  return defval;
104  int ret_value{0};
105  try {
106  ret_value = boost::lexical_cast<int, string>(readAttribute(tree,attr));
107  }
108  catch(const boost::bad_lexical_cast & bc) {
109  TRG_MSG_ERROR("attribute '" << attr << "' is not an int (it is '" << readAttribute(tree,attr) << "')");
110  }
111  return ret_value;
112 }

◆ getUIntAttribute() [1/2]

unsigned int MuctpiXMLHelper::getUIntAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 116 of file MuctpiXMLHelper.cxx.

116  {
117  if( ! hasAttribute(tree, attr) ) {
118  TRG_MSG_WARNING("attribute " << attr << " does not exist");
119  return 0;
120  }
121  unsigned int ret_value{0};
122  try {
123  ret_value = boost::lexical_cast<unsigned int, string>(readAttribute(tree,attr));
124  }
125  catch(const boost::bad_lexical_cast & bc) {
126  TRG_MSG_ERROR("attribute '" << attr << "' is not an unsigned int (it is " << readAttribute(tree,attr) << ")");
127  }
128  return ret_value;
129 }

◆ getUIntAttribute() [2/2]

unsigned int MuctpiXMLHelper::getUIntAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr,
unsigned int &  defval 
)

Definition at line 132 of file MuctpiXMLHelper.cxx.

132  {
133  if( ! hasAttribute(tree, attr) )
134  return defval;
135  return boost::lexical_cast<unsigned int, string>(readAttribute(tree,attr));
136 }

◆ hasAttribute()

bool MuctpiXMLHelper::hasAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 32 of file MuctpiXMLHelper.cxx.

32  {
33 
34  // initialize attributes ptree
35  ptree tmp_ptree;
36  ptree attributes = tree.get_child("<xmlattr>", tmp_ptree);
37 
38  if(attributes.empty()) return false;
39 
40  for(const ptree::value_type &a: attributes) {
41  string attrName = a.first;
42  if(attrName == attr) {
43  return true;
44  }
45  }
46  return false;
47 }

◆ msg() [1/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 81 of file TrigConfMessaging.h.

82  {
83  MsgStreamTC* ms = m_msg_tls.get();
84  if (!ms) {
85  ms = new MsgStreamTC(m_name);
86  m_msg_tls.reset(ms);
87  }
88  return *ms;
89  }

◆ msg() [2/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( const MSGTC::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 91 of file TrigConfMessaging.h.

92  {
93  return msg() << lvl;
94  }

◆ msgLvl()

bool TrigConf::TrigConfMessaging::msgLvl ( const MSGTC::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 70 of file TrigConfMessaging.h.

71  {
72  if (msg().level() <= lvl) {
73  msg() << lvl;
74  return true;
75  }
76  else {
77  return false;
78  }
79  }

◆ printAttributes()

void MuctpiXMLHelper::printAttributes ( const boost::property_tree::ptree tree)

Definition at line 17 of file MuctpiXMLHelper.cxx.

17  {
18 
19  // initialize attributes ptree
20  ptree tmp_ptree;
21  ptree attributes = tree.get_child("<xmlattr>", tmp_ptree);
22 
23  // iterate through elements
24  for(const ptree::value_type & a: attributes) {
25  string attrName = a.first;
26  string attrVal = a.second.data();
27  std::cout << attrName << " : " << attrVal << std::endl;
28  }
29 }

◆ readAttribute()

string MuctpiXMLHelper::readAttribute ( const boost::property_tree::ptree tree,
const std::string &  attr 
)

Definition at line 51 of file MuctpiXMLHelper.cxx.

51  {
52 
53  // initialize attributes ptree
54  ptree tmp_ptree;
55  ptree attributes = tree.get_child("<xmlattr>", tmp_ptree);
56 
57  // iterate through children
58  for(const ptree::value_type &a : attributes) {
59  if(a.first != attr) continue;
60  return a.second.data(); //a.second.data is the value!
61  }
62  return "";
63 }

Member Data Documentation

◆ m_msg_tls

boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls
mutableprivateinherited

MsgStreamTC instance (a std::cout like with print-out levels)

Definition at line 66 of file TrigConfMessaging.h.

◆ m_name

std::string TrigConf::TrigConfMessaging::m_name
privateinherited

Definition at line 67 of file TrigConfMessaging.h.


The documentation for this class was generated from the following files:
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
TrigConf::TrigConfMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
Definition: TrigConfMessaging.h:66
MuctpiXMLHelper::printAttributes
void printAttributes(const boost::property_tree::ptree &tree)
Definition: MuctpiXMLHelper.cxx:17
tree
TChain * tree
Definition: tile_monitor.h:30
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
MuctpiXMLHelper::readAttribute
std::string readAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:51
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConf::TrigConfMessaging::m_name
std::string m_name
Definition: TrigConfMessaging.h:67
TrigConf::TrigConfMessaging::msg
MsgStreamTC & msg() const
The standard message stream.
Definition: TrigConfMessaging.h:81
MuctpiXMLHelper::hasAttribute
bool hasAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:32
TRG_MSG_WARNING
#define TRG_MSG_WARNING(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:28
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::TrigConfMessaging
Class to provide easy access to TrigConf::MsgStream for TrigConf classes.
Definition: TrigConfMessaging.h:28
python.PoolAttributeHelper.attrName
attrName
Definition: PoolAttributeHelper.py:100
a
TList * a
Definition: liststreamerinfos.cxx:10
collListGuids.attributes
attributes
Definition: collListGuids.py:46