15 #include <Parsers/Parsers.h>
31 std::string str_replace(
const std::string& str,
const std::string& pattern,
const std::string& replacement) {
32 std::string res = str;
33 for(
size_t id=res.find(pattern);
id != std::string::npos;
id = res.find(pattern) )
34 res.replace(
id,pattern.length(),replacement);
66 virtual void operator()(
const cond::AbstractMap::Params::value_type& obj)
const;
72 : m_parent(printer), printLevel(lvl)
78 const std::type_info& type = obj.second.typeInfo();
80 if ( type ==
typeid(std::string) ) {
81 std::string value = obj.second.get<std::string>().c_str();
82 std::size_t len = value.length();
83 if ( len > m_parent->lineLength ) {
84 value.erase(m_parent->lineLength);
87 printout(m_parent->printLevel,m_parent->name,
"++ %s\t-> Param: %-16s %-8s -> %s",
90 obj.second.dataType().c_str(),
95 printout(m_parent->printLevel,m_parent->name,
"++ %s\t-> [%s] CL:%d %-8s -> %s",
98 obj.second.dataType().c_str(),
99 obj.second.str().c_str());
102 std::string value = obj.second.str();
103 std::size_t len = value.length();
104 if ( len > m_parent->lineLength ) {
105 value.erase(m_parent->lineLength);
108 printout(m_parent->printLevel,m_parent->name,
"++ %s\t-> [%s] %-8s -> %s",
111 obj.second.dataType().c_str(),
117 ConditionsPrinter::ConditionsPrinter(
ConditionsMap* cond_map,
const std::string& pref,
int flg)
118 :
mapping(cond_map), m_flag(flg), name(
"Condition"), prefix(pref)
126 printout(INFO,
name,
"++ %s +++++++++++++ Printout summary:",
prefix.c_str());
127 printout(INFO,
name,
"++ %s Number of conditions: %8ld [ dto. empty:%ld]",
129 printout(INFO,
name,
"++ %s Total Number of parameters: %8ld [%7.3f Parameters/Condition]",
138 if (
cond.isValid() ) {
145 std::string new_prefix =
prefix;
146 new_prefix.assign(
prefix.length(),
' ');
147 if ( !
cond.is_bound() ) {
148 printout(this->
printLevel,
name,
"++ %s \tPath:%s Key:%16llX Type:%s (%s)",
149 new_prefix.c_str(),
cond.name(),
cond.key(),
"<Unbound-Condition>",
150 typeName(
typeid(*ptr)).c_str());
153 const std::type_info& type =
cond.typeInfo();
155 printout(this->
printLevel,
name,
"++ %s \tPath:%s Key:%16llX Type:%s",
166 cond.data().dataType().c_str());
168 if ( !data.
params.empty() ) {
177 else if ( type ==
typeid(
Delta) ) {
179 std::stringstream str_tr, str_rot, str_piv;
191 piv = str_replace(str_piv.str(),
"\n",
"");
192 piv = str_replace(piv,
" ",
" , ");
196 typeName(
typeid(*ptr)).c_str());
197 printout(
printLevel,
name,
"++ %s \tData(%11s-%8s-%5s): [%s [cm], %s [rad], %s [cm]]",
202 str_replace(str_tr.str(),
"\n",
"").c_str(),
203 str_replace(str_rot.str(),
"\n",
"").c_str(),
209 std::stringstream str_tr, str_rot, str_piv;
215 piv = str_replace(str_piv.str(),
"\n",
"");
216 piv = str_replace(piv,
" ",
" , ");
221 typeName(
typeid(*ptr)).c_str());
222 printout(
printLevel,
name,
"++ %s \tData(%11s-%8s-%5s): [%s, %s, %s]",
227 str_replace(str_tr.str(),
"\n",
"").c_str(),
228 str_replace(str_rot.str(),
"\n",
"").c_str(),
232 else if ( type ==
typeid(std::string) ) {
233 std::string value =
cond.get<std::string>().c_str();
234 std::size_t len = value.length();
238 value = str_replace(value,
"\n",
"");
242 cond.data().dataType().c_str(),
246 std::string value =
cond.str();
247 std::size_t len = value.length();
251 value = str_replace(value,
"\n",
"");
255 cond.data().dataType().c_str(),
266 std::vector<Condition> conditions;
268 printout(this->
printLevel,
name,
"++ %s %-3ld Conditions for DE %s",
269 prefix.c_str(), conditions.size(), de.
path().c_str());
270 for(
auto cond : conditions )
272 return int(conditions.size());
274 except(
name,
"Failed to dump conditions for DetElement:%s [No slice availible]",