ATLAS Offline Software
Loading...
Searching...
No Matches
L1TopoConfigAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include <iostream>
9#include <iomanip>
10#include <algorithm>
11
12using namespace std;
13using namespace TXC;
14
15namespace {
16 struct ios_state_guard {
17 std::ostream& os;
18 std::ios::fmtflags flags;
19 char fill;
20 std::streamsize width;
21
22 explicit ios_state_guard(std::ostream& o)
23 : os(o), flags(o.flags()), fill(o.fill()), width(o.width()) {}
24
25 ~ios_state_guard() {
26 os.flags(flags);
27 os.fill(fill);
28 os.width(width);
29 }
30 };
31}
32
33
34namespace TXC {
35
36ostream&
37operator<<(ostream& o, const InputElement& ie) {
38 o << "name: " << ie.name << ", value: " << ie.value << ", pos: " << ie.position;
39 return o;
40}
41
42ostream& operator<<(ostream& o, const OutputElement& oe) {
43 o << "name: " << oe.name << ", value: " << oe.value << ", nbits: " << oe.nbits << ", outname: " << oe.outname << ", position: " << oe.position;
44 return o;
45}
46
47ostream&
48operator<<(ostream& o, const FixedParameter& ge) {
49 o << "name: " << ge.name << ", value: " << ge.value;
50 return o;
51}
52
53ostream&
54operator<<(ostream& o, const RegisterParameter& pe) {
55 o << "name: " << pe.name << ", value: " << pe.value << ", pos: " << pe.position << ", sel: " << pe.selection;
56 return o;
57}
58
59
60} // namespace TXC
61
62
66
67TXC::L1TopoConfigAlg::L1TopoConfigAlg(const string & name, const string & type) :
68 m_name(name),
70{}
71
72
74
75string
77 return type() + "/" + name();
78}
79
80
81vector<string>
83 vector<string> names;
84 for(auto & x : m_inputElements)
85 names.push_back(x.value);
86 return names;
87}
88
89vector<string>
91 vector<string> names;
92 for(auto & x : m_outputElements)
93 names.push_back( isSortAlg() ? x.value : x.outname );
94 return names;
95}
96
97
98
99void
100TXC::L1TopoConfigAlg::addInput(const string &name, const string &value, unsigned int position) {
101 m_inputElements.push_back( InputElement( name, value, position) );
102 std::sort( m_inputElements.begin(), m_inputElements.end(),[](const TXC::InputElement& i, const TXC::InputElement& i2){ return (i.position < i2.position);});
103}
104
105
106void TXC::L1TopoConfigAlg::addOutput(const string &name, const string &value, unsigned int bits, const string & outname, unsigned int position) {
107 m_outputElements.push_back(OutputElement( name, value, bits, outname, position));
108 std::sort( m_outputElements.begin(), m_outputElements.end(),[](const TXC::OutputElement& o, const TXC::OutputElement& o2){ return (o.position < o2.position);});
109}
110
111void TXC::L1TopoConfigAlg::addFixedParameter(const std::string &name, const std::string &value) {
112 m_fixedParameters.push_back(FixedParameter( name, value));
113}
114
115void TXC::L1TopoConfigAlg::addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection) {
116 m_variableParameters.push_back( RegisterParameter( name, value, position, selection));
117 std::sort(m_variableParameters.begin(),m_variableParameters.end(),[](const TXC::RegisterParameter& r, const TXC::RegisterParameter& r2){ return (r.position < r2.position);});
118}
119
120
121namespace TXC {
122
123std::ostream & operator<<(std::ostream &o, const L1TopoConfigAlg &alg) {
124 ios_state_guard guard{o};
125 if(alg.isSortAlg()) {
126 o << "Sorting algorithm " << alg.algoID() << " : " << alg.type() << "/" << alg.name() << endl;
127 o << " Input : " << alg.m_inputElements[0].value << endl;
128 o << " Output : " << alg.m_outputElements[0].value << endl;
129 } else {
130 o << "Decision algorithm " << alg.algoID() << " : " << alg.type() << "/" << alg.name() << endl;
131 for(const TXC::InputElement& ie: alg.m_inputElements)
132 o << " Input " << ie.position << " : " << ie.value << endl;
133 for(const TXC::OutputElement& oe: alg.m_outputElements)
134 o << " Output " << oe.position << " : " << oe.outname << endl;
135 }
136 o << " Fixed paramters: " << alg.getFixedParameters().size() << endl;
137 for(const TXC::FixedParameter& ge: alg.m_fixedParameters)
138 o << " " << setw(15) << left << ge.name << " : " << ge.value << endl;
139 o << " Parameters: " << alg.getParameters().size() << endl;
140 for(const TXC::RegisterParameter& pe: alg.m_variableParameters)
141 o << " " << setw(15) << left << pe.name << " : " << pe.value << endl;
142 return o;
143}
144
145
146} // namespace TXC
#define x
void addFixedParameter(const std::string &name, const std::string &value)
const std::string & name() const
std::vector< TXC::FixedParameter > m_fixedParameters
std::vector< std::string > getOutputNames() const
void addOutput(const std::string &name, const std::string &value, unsigned int bits, const std::string &outname, unsigned int position)
void addInput(const std::string &name, const std::string &value, unsigned int position)
std::vector< TXC::InputElement > m_inputElements
std::string fullname() const
std::vector< TXC::RegisterParameter > m_variableParameters
std::vector< std::string > getInputNames() const
const std::string & type() const
L1TopoConfigAlg(const std::string &name, const std::string &type)
class L1TopoConfigAlg
std::vector< TXC::OutputElement > m_outputElements
void addParameter(const std::string &name, const std::string &value, unsigned int position, unsigned int selection)
const std::string selection
int r
Definition globals.cxx:22
std::ostream & operator<<(std::ostream &, const TXC::L1TopoConfigAlg &)
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
unsigned int position