ATLAS Offline Software
TrigMonConfig.icc
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef TRIGMON_CONFIG_ICC
8 #define TRIGMON_CONFIG_ICC
9 
10 // Hide template code from ROOTCINT and GCCXML
11 #ifndef __CINT__
12 #ifndef __GCCXML__
13 
14 //
15 // Template implementations and specilizations
16 //
17 
18 // Local
19 #include "TrigMonitoringEvent/TrigMonChain.h"
20 #include "TrigMonitoringEvent/TrigMonL1Item.h"
21 #include "TrigMonitoringEvent/TrigMonSeq.h"
22 #include "TrigMonitoringEvent/TrigMonTE.h"
23 
24 // C/C++
25 #include <algorithm>
26 #include <iostream>
27 
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();
31 }
32 template<> inline std::vector<TrigConfChain>::const_iterator TrigMonConfig::end<TrigConfChain>() const {
33  return m_chain.end();
34 }
35 
36 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::begin<TrigConfSeq>() const{
37  return m_seq.begin();
38 }
39 template<> inline std::vector<TrigConfSeq>::const_iterator TrigMonConfig::end <TrigConfSeq>() const {
40  return m_seq.end();
41 }
42 
43 // template specialization for non-const getVec() functions
44 template<> inline std::vector<TrigConfChain>& TrigMonConfig::getVec<TrigConfChain>() {
45  return m_chain;
46 }
47 template<> inline std::vector<TrigConfSeq>& TrigMonConfig::getVec<TrigConfSeq>() {
48  return m_seq;
49 }
50 
51 // template specialization for const getVec() functions
52 template<> inline const std::vector<TrigConfChain>& TrigMonConfig::getVec<TrigConfChain>() const {
53  return m_chain;
54 }
55 template<> inline const std::vector<TrigConfSeq>& TrigMonConfig::getVec<TrigConfSeq>() const {
56  return m_seq;
57 }
58 
59 // template specialization for Size() function
60 template<> inline unsigned int TrigMonConfig::size<TrigConfChain>() const {
61  return m_chain.size();
62 }
63 template<> inline unsigned int TrigMonConfig::size<TrigConfSeq>() const {
64  return m_seq.size();
65 }
66 template<> inline unsigned int TrigMonConfig::size<TrigConfVar>() const {
67  return m_var_id.size();
68 }
69 
70 // template specialization for at() function
71 template<> inline const TrigConfChain& TrigMonConfig::at<TrigConfChain>(unsigned int i) const {
72  return m_chain[i];
73 }
74 template<> inline const TrigConfSeq& TrigMonConfig::at<TrigConfSeq>(unsigned int i) const {
75  return m_seq[i];
76 }
77 
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);
81 }
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);
84 }
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);
87 }
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);
90 }
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);
93 }
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);
96 }
97 
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);
101 }
102 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonChain>(const TrigMonChain &key) {
103  return std::find(m_chain.begin(), m_chain.end(), key);
104 }
105 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonL1Item>(const TrigMonL1Item &key) {
106  return std::find(m_chain.begin(), m_chain.end(), key);
107 }
108 template<> inline std::vector<TrigConfChain>::iterator TrigMonConfig::findChainIter<TrigMonSeq>(const TrigMonSeq &key) {
109  return std::find(m_chain.begin(), m_chain.end(), key);
110 }
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);
113 }
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);
116 }
117 
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);
121 }
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);
124 }
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);
127 }
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);
130 }
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);
133 }
134 
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);
138 }
139 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<TrigMonSeq>(const TrigMonSeq &key) {
140  return std::find(m_seq.begin(), m_seq.end(), key);
141 }
142 template<> inline std::vector<TrigConfSeq>::iterator TrigMonConfig::findSeqIter<TrigMonTE>(const TrigMonTE &key) {
143  return std::find(m_seq.begin(), m_seq.end(), key);
144 }
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);
147 }
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);
150 }
151 
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;
156  return false;
157  }
158 
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;
164  return false;
165  }
166  }
167 
168  m_chain.push_back(obj);
169  return true;
170 }
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;
175  return false;
176  }
177  }
178 
179  m_var_id.push_back(obj.id());
180  m_var_name.push_back(obj.name());
181  return true;
182 }
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;
186  return false;
187  }
188 
189  m_seq.push_back(obj);
190  return true;
191 }
192 
193 #endif
194 #endif
195 #endif