ATLAS Offline Software
TrigDBConnectionConfig.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * @file TrigDBConnectionConfig.h
7  * @brief Configuration for a Trigger DB connection, with string serialization
8  * @author Ricardo Abreu
9  * $Id: TrigDBConnectionConfig.h 569440 2013-11-08 17:32:05Z ricab $
10  */
11 
12 #ifndef TRIGDBCONNECTIONCONFIG_H_
13 #define TRIGDBCONNECTIONCONFIG_H_
14 
15 #include <string>
16 #include <vector>
17 #include <utility>
18 
19 namespace TrigConf {
20 
22 {
23 public:
25  typedef std::pair<unsigned int, unsigned int> LumiPSPair;
26  typedef std::vector<LumiPSPair> PSKeys;
27 
29  // If some parameter is repeated in the string, the last occurrence is the
30  // one taken into account
31  TrigDBConnectionConfig(const std::string& connectionStr);
33  const std::string& server,
34  unsigned int smKey,
35  unsigned int hltPsKey);
37  const std::string& server,
38  unsigned int smKey,
39  const PSKeys& hltPsKeyStr);
41  const std::string& server,
42  unsigned int smKey,
43  const std::string& hltPsKeyStr);
44 
45  void diggestStr(const std::string& str);
46 
47  // setters from strings for non string attributes
48  void setTypeFromStr(const std::string& typeStr);
49  void setSmKeyFromStr(const std::string& smKeyStr);
50  // accepts single or multiple keys
51  void setHltKeysFromStr(const std::string& hltKeyStr);
52  void setLvl1KeyFromStr(const std::string& lvl1KeyStr);
53  void setRetrialPeriodFromStr(const std::string& retrialPeriodStr);
54  void setMaxRetrialsFromStr(const std::string& maxRetrialsStr);
55  void setUseFrontierFromStr(const std::string& useFrontier);
56 
57  std::string toString() const;
58  std::string typeToString() const;
59  std::string hltKeysToString() const;
60 
61  // Attributes
63  std::string m_server;
64  unsigned int m_smkey{0};
65  unsigned int m_hltkey{0};
67  unsigned int m_lvl1key{0};
68  std::string m_schema;
69  std::string m_user;
70  std::string m_password;
71  unsigned int m_retrialPeriod{0};
72  unsigned int m_maxRetrials{1};
73  bool m_useFrontier{false};
74 
75 private:
77  const std::string& server,
78  unsigned int smKey);
79 
80 };
81 
82 }
83 
85 inline TrigConf::
87  const std::string& server,
88  unsigned int smKey)
89  : m_type(type)
90  , m_server(server)
91  , m_smkey(smKey)
92 {
93 }
94 
96 inline TrigConf::
98  const std::string& server,
99  unsigned int smKey,
100  unsigned int hltPsKey)
102 {
103  m_hltkey = hltPsKey;
104 }
105 
109  const std::string& server,
110  unsigned int smKey,
111  const PSKeys& hltPsKeys)
113 {
114  // cppcheck-suppress useInitializationList --- false positive
115  m_hltkeys = hltPsKeys;
116 }
117 
120 {
121  switch(m_type)
122  {
123  case Oracle: return "oracle";
124  case MySQL: return "mysql";
125  case SQLite: return "sqlite";
126  case DBLookup: return "dblookup";
127  }
128 
129  return "UnknownType!";
130 }
131 
132 #endif /* TRIGDBCONNECTIONCONFIG_H_ */
TrigConf::TrigDBConnectionConfig::toString
std::string toString() const
Definition: TrigDBConnectionConfig.cxx:185
TrigConf::TrigDBConnectionConfig::m_smkey
unsigned int m_smkey
Definition: TrigDBConnectionConfig.h:64
TrigConf::TrigDBConnectionConfig::m_maxRetrials
unsigned int m_maxRetrials
Definition: TrigDBConnectionConfig.h:72
TrigConf::TrigDBConnectionConfig::m_schema
std::string m_schema
Definition: TrigDBConnectionConfig.h:68
TrigConf::TrigDBConnectionConfig::m_lvl1key
unsigned int m_lvl1key
Definition: TrigDBConnectionConfig.h:67
TrigConf::TrigDBConnectionConfig::m_useFrontier
bool m_useFrontier
Definition: TrigDBConnectionConfig.h:73
TrigConf::TrigDBConnectionConfig::setHltKeysFromStr
void setHltKeysFromStr(const std::string &hltKeyStr)
Definition: TrigDBConnectionConfig.cxx:257
TrigConf::TrigDBConnectionConfig::m_server
std::string m_server
Definition: TrigDBConnectionConfig.h:63
TrigConf::TrigDBConnectionConfig::Oracle
@ Oracle
Definition: TrigDBConnectionConfig.h:24
TrigConf::TrigDBConnectionConfig::setLvl1KeyFromStr
void setLvl1KeyFromStr(const std::string &lvl1KeyStr)
Definition: TrigDBConnectionConfig.cxx:273
TrigConf::TrigDBConnectionConfig::hltKeysToString
std::string hltKeysToString() const
Definition: TrigDBConnectionConfig.cxx:300
TrigConf::TrigDBConnectionConfig::typeToString
std::string typeToString() const
Definition: TrigDBConnectionConfig.h:119
TrigConf::TrigDBConnectionConfig
Definition: TrigDBConnectionConfig.h:22
TrigConf::TrigDBConnectionConfig::setTypeFromStr
void setTypeFromStr(const std::string &typeStr)
Definition: TrigDBConnectionConfig.cxx:242
TrigConf::TrigDBConnectionConfig::TrigDBConnectionConfig
TrigDBConnectionConfig()=default
TrigConf::TrigDBConnectionConfig::DBType
DBType
Definition: TrigDBConnectionConfig.h:24
TrigConf::TrigDBConnectionConfig::m_type
DBType m_type
Definition: TrigDBConnectionConfig.h:62
TrigConf::TrigDBConnectionConfig::m_hltkey
unsigned int m_hltkey
Definition: TrigDBConnectionConfig.h:65
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
TrigConf::TrigDBConnectionConfig::m_password
std::string m_password
Definition: TrigDBConnectionConfig.h:70
TrigConf::TrigDBConnectionConfig::m_retrialPeriod
unsigned int m_retrialPeriod
Definition: TrigDBConnectionConfig.h:71
TrigConf::TrigDBConnectionConfig::setRetrialPeriodFromStr
void setRetrialPeriodFromStr(const std::string &retrialPeriodStr)
Definition: TrigDBConnectionConfig.cxx:280
TrigConf::TrigDBConnectionConfig::setMaxRetrialsFromStr
void setMaxRetrialsFromStr(const std::string &maxRetrialsStr)
Definition: TrigDBConnectionConfig.cxx:287
TrigConf::TrigDBConnectionConfig::setUseFrontierFromStr
void setUseFrontierFromStr(const std::string &useFrontier)
Definition: TrigDBConnectionConfig.cxx:294
TrigConf::TrigDBConnectionConfig::MySQL
@ MySQL
Definition: TrigDBConnectionConfig.h:24
TrigConf::TrigDBConnectionConfig::SQLite
@ SQLite
Definition: TrigDBConnectionConfig.h:24
TrigConf::TrigDBConnectionConfig::PSKeys
std::vector< LumiPSPair > PSKeys
Definition: TrigDBConnectionConfig.h:26
TrigConf::TrigDBConnectionConfig::LumiPSPair
std::pair< unsigned int, unsigned int > LumiPSPair
Definition: TrigDBConnectionConfig.h:25
TrigConf::TrigDBConnectionConfig::diggestStr
void diggestStr(const std::string &str)
Definition: TrigDBConnectionConfig.cxx:208
TrigConf::TrigDBConnectionConfig::m_hltkeys
PSKeys m_hltkeys
Definition: TrigDBConnectionConfig.h:66
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigConf::TrigDBConnectionConfig::DBLookup
@ DBLookup
Definition: TrigDBConnectionConfig.h:24
str
Definition: BTagTrackIpAccessor.cxx:11
TrigConf::TrigDBConnectionConfig::setSmKeyFromStr
void setSmKeyFromStr(const std::string &smKeyStr)
Definition: TrigDBConnectionConfig.cxx:266
TrigConf::TrigDBConnectionConfig::m_user
std::string m_user
Definition: TrigDBConnectionConfig.h:69
python.html.AtlRunQueryDQSummary.server
server
Definition: AtlRunQueryDQSummary.py:22