00001
00002
00003
00004
00005
00006
00007
00008 #ifndef TRIGDBCONNECTIONCONFIG_H_
00009 #define TRIGDBCONNECTIONCONFIG_H_
00010
00011 #include <string>
00012 #include <vector>
00013 #include <utility>
00014
00015 namespace TrigConf {
00016
00017 struct TrigDBConnectionConfig
00018 {
00019 enum DBType { Oracle, MySQL, SQLite, DBLookup };
00020 typedef std::pair<unsigned int, unsigned int> LumiPSPair;
00021 typedef std::vector<LumiPSPair> PSKeys;
00022
00023 TrigDBConnectionConfig() = default;
00024
00025
00026 TrigDBConnectionConfig(const std::string& connectionStr);
00027 TrigDBConnectionConfig(DBType type,
00028 const std::string& server,
00029 unsigned int smKey,
00030 unsigned int hltPsKey);
00031 TrigDBConnectionConfig(DBType type,
00032 const std::string& server,
00033 unsigned int smKey,
00034 const PSKeys& hltPsKeyStr);
00035 TrigDBConnectionConfig(DBType type,
00036 const std::string& server,
00037 unsigned int smKey,
00038 const std::string& hltPsKeyStr);
00039
00040 void diggestStr(const std::string& str);
00041
00042
00043 void setTypeFromStr(const std::string& typeStr);
00044 void setSmKeyFromStr(const std::string& smKeyStr);
00045
00046 void setHltKeysFromStr(const std::string& hltKeyStr);
00047 void setLvl1KeyFromStr(const std::string& lvl1KeyStr);
00048 void setRetrialPeriodFromStr(const std::string& retrialPeriodStr);
00049 void setMaxRetrialsFromStr(const std::string& maxRetrialsStr);
00050 void setUseFrontierFromStr(const std::string& useFrontier);
00051
00052 std::string toString() const;
00053 std::string typeToString() const;
00054 std::string hltKeysToString() const;
00055
00056
00057 DBType m_type{DBLookup};
00058 std::string m_server;
00059 unsigned int m_smkey{0};
00060 unsigned int m_hltkey{0};
00061 PSKeys m_hltkeys;
00062 unsigned int m_lvl1key{0};
00063 std::string m_schema;
00064 std::string m_user;
00065 std::string m_password;
00066 unsigned int m_retrialPeriod{0};
00067 unsigned int m_maxRetrials{1};
00068 bool m_useFrontier{false};
00069
00070 private:
00071 TrigDBConnectionConfig(DBType type,
00072 const std::string& server,
00073 unsigned int smKey);
00074
00075 };
00076
00077 }
00078
00080 inline TrigConf::
00081 TrigDBConnectionConfig::TrigDBConnectionConfig(DBType type,
00082 const std::string& server,
00083 unsigned int smKey)
00084 : m_type(type)
00085 , m_server(server)
00086 , m_smkey(smKey)
00087 {
00088 }
00089
00091 inline TrigConf::
00092 TrigDBConnectionConfig::TrigDBConnectionConfig(DBType type,
00093 const std::string& server,
00094 unsigned int smKey,
00095 unsigned int hltPsKey)
00096 : TrigDBConnectionConfig(type, server, smKey)
00097 {
00098 m_hltkey = hltPsKey;
00099 }
00100
00102 inline TrigConf::
00103 TrigDBConnectionConfig::TrigDBConnectionConfig(DBType type,
00104 const std::string& server,
00105 unsigned int smKey,
00106 const PSKeys& hltPsKeys)
00107 : TrigDBConnectionConfig(type, server, smKey)
00108 {
00109 m_hltkeys = hltPsKeys;
00110 }
00111
00113 inline std::string TrigConf::TrigDBConnectionConfig::typeToString() const
00114 {
00115 switch(m_type)
00116 {
00117 case Oracle: return "oracle";
00118 case MySQL: return "mysql";
00119 case SQLite: return "sqlite";
00120 case DBLookup: return "dblookup";
00121 }
00122
00123 return "UnknownType!";
00124 }
00125
00126 #endif