ATLAS Offline Software
Loading...
Searching...
No Matches
DiffStruct.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <string>
8
9#include <iostream>
10#include <fstream>
11
12using namespace std;
13
14TrigConf::DiffStruct::DiffStruct(const std::string& tagname, const std::string& name) :
16 name(name)
17{}
18
20 for(DiffStruct* d : subs)
21 delete d;
22}
23
24
25void
26TrigConf::DiffStruct::check(const std::string& attname, const std::string& lval, const std::string& rval) {
27 if(lval!=rval) attdiffs.push_back(AttDiff(attname, lval, rval));
28}
29
30void
31TrigConf::DiffStruct::check(const std::string& attname, int lval, int rval) {
32 if(lval!=rval)
33 attdiffs.push_back(AttDiff(attname, std::to_string(lval), std::to_string(rval) ));
34}
35
36void
37TrigConf::DiffStruct::check(const std::string& attname, unsigned int lval, unsigned int rval) {
38 if(lval!=rval)
39 attdiffs.push_back(AttDiff(attname, std::to_string(lval), std::to_string(rval) ));
40}
41
42void
43TrigConf::DiffStruct::check(const std::string& attname, float lval, float rval) {
44 if(lval!=rval)
45 attdiffs.push_back(AttDiff(attname, std::to_string(lval), std::to_string(rval) ));
46}
47
48void
49TrigConf::DiffStruct::check(const std::string& attname, bool lval, bool rval) {
50 if(lval!=rval)
51 attdiffs.push_back(AttDiff(attname, std::to_string(lval), std::to_string(rval) ));
52}
53
54void
56 if(sub) subs.push_back(sub);
57}
58
59void
60TrigConf::DiffStruct::addRightOnlySub(const string& tagname, const string& name) {
61 rightonly.insert( std::pair<string,string>(tagname, name) );
62}
63
64void
65TrigConf::DiffStruct::addLeftOnlySub(const string& tagname, const string& name) {
66 leftonly.insert( std::pair<string,string>(tagname, name) );
67}
68
69bool
71 return attdiffs.size()==0 && subs.size()==0;
72}
73
74
75void
76TrigConf::DiffStruct::writeXML(ofstream & xmlfile, const std::string& prefix) const {
77 if(empty()) return;
78 xmlfile << prefix << "<" << tagname;
79 if(name!="")
80 xmlfile << " name=\"" << name << "\"";
81 for(const AttDiff& d : attdiffs)
82 xmlfile << " " << d.attname << "_l=\"" << d.lval << "\" " << d.attname << "_r=\"" << d.rval << "\"";
83 if(subs.size()==0 && rightonly.size()==0 && leftonly.size()==0) {
84 xmlfile << "/>" << endl;
85 } else {
86 xmlfile << ">" << endl;
87 for(DiffStruct *d : subs)
88 d->writeXML(xmlfile, prefix+" ");
89 if(leftonly.size()>0) {
90 xmlfile << prefix << " <LEFT_ONLY>" << endl;
91 for(OnlyMap_t::value_type tag_name : leftonly)
92 xmlfile << prefix << " <" << tag_name.first << " name=\"" << tag_name.second << "\"/>" << endl;
93 xmlfile << prefix << " </LEFT_ONLY>" << endl;
94 }
95 if(rightonly.size()>0) {
96 xmlfile << prefix << " <RIGHT_ONLY>" << endl;
97 for(OnlyMap_t::value_type tag_name : rightonly)
98 xmlfile << prefix << " <" << tag_name.first << " name=\"" << tag_name.second << "\"/>" << endl;
99 xmlfile << prefix << " </RIGHT_ONLY>" << endl;
100 }
101 xmlfile << prefix << "</" << tagname << ">" << endl;
102 }
103}
static const Attributes_t empty
std::string tagname
Definition DiffStruct.h:39
void check(const std::string &attname, const std::string &lval, const std::string &rval)
std::vector< AttDiff > attdiffs
Definition DiffStruct.h:41
void addLeftOnlySub(const std::string &tagname, const std::string &name)
void writeXML(std::ofstream &xmlfile, const std::string &prefix="") const
void addRightOnlySub(const std::string &tagname, const std::string &name)
DiffStruct(const std::string &tagname, const std::string &name="")
void addSub(DiffStruct *sub)
std::vector< DiffStruct * > subs
Definition DiffStruct.h:42
static std::vector< std::string > xmlfile
Definition iLumiCalc.h:29
STL namespace.