4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
7 #ifndef TRIGMON_CONFIG_ICC
8 #define TRIGMON_CONFIG_ICC
10 // Hide template code from ROOTCINT and GCCXML
15 // Template implementations and specilizations
19 #include "TrigMonitoringEvent/TrigMonChain.h"
20 #include "TrigMonitoringEvent/TrigMonL1Item.h"
21 #include "TrigMonitoringEvent/TrigMonSeq.h"
22 #include "TrigMonitoringEvent/TrigMonTE.h"
28 // template specialization for const begin() and end() functions
29 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::begin<TrigConfChain>() const {
30 return m_chain.begin();
32 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::end<TrigConfChain>() const {
36 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::begin<TrigConfSeq>() const{
39 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::end <TrigConfSeq>() const {
43 // template specialization for non-const getVec() functions
44 template<> inline std::vector<TrigConfChain>& TrigMonConfig::getVec<TrigConfChain>() {
47 template<> inline std::vector<TrigConfSeq>& TrigMonConfig::getVec<TrigConfSeq>() {
51 // template specialization for const getVec() functions
52 template<> inline const std::vector<TrigConfChain>& TrigMonConfig::getVec<TrigConfChain>() const {
55 template<> inline const std::vector<TrigConfSeq>& TrigMonConfig::getVec<TrigConfSeq>() const {
59 // template specialization for Size() function
60 template<> inline unsigned int TrigMonConfig::size<TrigConfChain>() const {
61 return m_chain.size();
63 template<> inline unsigned int TrigMonConfig::size<TrigConfSeq>() const {
66 template<> inline unsigned int TrigMonConfig::size<TrigConfVar>() const {
67 return m_var_id.size();
70 // template specialization for at() function
71 template<> inline const TrigConfChain& TrigMonConfig::at<TrigConfChain>(unsigned int i) const {
74 template<> inline const TrigConfSeq& TrigMonConfig::at<TrigConfSeq>(unsigned int i) const {
78 // template specialization for std::vector<TrigConfChain>::const_iterator findChain(T &key) function
79 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<TrigConfChain>(const TrigConfChain &key) const {
80 return std::find(m_chain.begin(), m_chain.end(), key);
82 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<TrigMonChain>(const TrigMonChain &key) const {
83 return std::find(m_chain.begin(), m_chain.end(), key);
85 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<TrigMonL1Item>(const TrigMonL1Item &key) const {
86 return std::find(m_chain.begin(), m_chain.end(), key);
88 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<TrigMonSeq>(const TrigMonSeq &key) const {
89 return std::find(m_chain.begin(), m_chain.end(), key);
91 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<std::string>(const std::string &key) const {
92 return std::find(m_chain.begin(), m_chain.end(), key);
94 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::findChain<uint32_t>(const uint32_t &key) const {
95 return std::find(m_chain.begin(), m_chain.end(), key);
98 // template specialization for std::vector<TrigConfChain>::iterator findChainIter(T &key) function
99 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigConfChain>(const TrigConfChain &key) {
100 return std::find(m_chain.begin(), m_chain.end(), key);
102 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonChain>(const TrigMonChain &key) {
103 return std::find(m_chain.begin(), m_chain.end(), key);
105 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonL1Item>(const TrigMonL1Item &key) {
106 return std::find(m_chain.begin(), m_chain.end(), key);
108 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonSeq>(const TrigMonSeq &key) {
109 return std::find(m_chain.begin(), m_chain.end(), key);
111 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<std::string>(const std::string &key) {
112 return std::find(m_chain.begin(), m_chain.end(), key);
114 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<uint32_t>(const uint32_t &key) {
115 return std::find(m_chain.begin(), m_chain.end(), key);
118 // template specialization for std::vector<TrigConfSeq>::const_iterator findSeq(T &key) function
119 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::findSeq<TrigConfSeq>(const TrigConfSeq &key) const {
120 return std::find(m_seq.begin(), m_seq.end(), key);
122 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::findSeq<TrigMonSeq>(const TrigMonSeq &key) const {
123 return std::find(m_seq.begin(), m_seq.end(), key);
125 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::findSeq<TrigMonTE>(const TrigMonTE &key) const {
126 return std::find(m_seq.begin(), m_seq.end(), key);
128 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::findSeq<std::string>(const std::string &key) const {
129 return std::find(m_seq.begin(), m_seq.end(), key);
131 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::findSeq<uint32_t>(const uint32_t &key) const {
132 return std::find(m_seq.begin(), m_seq.end(), key);
135 // template specialization for std::vector<TrigConfSeq>::iterator find(T &key) function
136 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<TrigConfSeq>(const TrigConfSeq &key) {
137 return std::find(m_seq.begin(), m_seq.end(), key);
139 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<TrigMonSeq>(const TrigMonSeq &key) {
140 return std::find(m_seq.begin(), m_seq.end(), key);
142 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<TrigMonTE>(const TrigMonTE &key) {
143 return std::find(m_seq.begin(), m_seq.end(), key);
145 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<std::string>(const std::string &key) {
146 return std::find(m_seq.begin(), m_seq.end(), key);
148 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<uint32_t>(const uint32_t &key) {
149 return std::find(m_seq.begin(), m_seq.end(), key);
152 // template specialization for Add() function
153 template<> inline bool TrigMonConfig::add<TrigConfChain>(const TrigConfChain &obj) {
154 if(findChain<TrigConfChain>(obj) != m_chain.end()) {
155 std::cerr << "TrigMonConfig::add<TrigConfChain> - chain already exists: " << obj.getName() << std::endl;
159 for(unsigned int i = 0; i < m_chain.size(); ++i) {
160 const TrigConfChain &chn = m_chain[i];
161 if(obj.getLevel() == chn.getLevel() && obj.getCounter() == chn.getCounter()) {
162 std::cerr << "TrigMonConfig::add<TrigConfChain> - duplicate chain counter: "
163 << obj.getCounter() << " for " << obj.getLevel() << std::endl;
168 m_chain.push_back(obj);
171 template<> inline bool TrigMonConfig::add<TrigConfVar>(const TrigConfVar &obj) {
172 for(unsigned int i = 0; i < m_var_name.size(); ++i) {
173 if(obj.name() == m_var_name[i]) {
174 std::cerr << "TrigMonConfig::add<TrigConfVar> error! Duplicate name: " << obj.name() << std::endl;
179 m_var_id.push_back(obj.id());
180 m_var_name.push_back(obj.name());
183 template<> inline bool TrigMonConfig::add<TrigConfSeq>(const TrigConfSeq &obj) {
184 if(findSeq<TrigConfSeq>(obj) != m_seq.end()) {
185 std::cerr << "TrigMonConfig::add<TrigConfSeq> - sequence already exists: " << obj.getName() << std::endl;
189 m_seq.push_back(obj);