Skip to content

Commit f16756b

Browse files
awegrzynBarthelemy
authored andcommitted
Use getRecurisve to pass database configuration
1 parent 7451724 commit f16756b

6 files changed

Lines changed: 13 additions & 15 deletions

File tree

Framework/include/QualityControl/CcdbDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class CcdbDatabase : public DatabaseInterface
5858
virtual ~CcdbDatabase();
5959

6060
void connect(std::string host, std::string database, std::string username, std::string password) override;
61-
void connect(std::unique_ptr<ConfigurationInterface>& config) override;
61+
void connect(const std::unordered_map<std::string, std::string>& config) override;
6262
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
6363
core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
6464
void disconnect() override;

Framework/include/QualityControl/DatabaseInterface.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define QC_REPOSITORY_DATABASEINTERFACE_H
88

99
#include "QualityControl/MonitorObject.h"
10-
#include <Configuration/ConfigurationInterface.h>
1110
#include <memory>
11+
#include <unordered_map>
1212
//#include <bits/unique_ptr.h>
1313

1414
namespace o2
@@ -18,8 +18,6 @@ namespace quality_control
1818
namespace repository
1919
{
2020

21-
using namespace o2::configuration;
22-
2321
/// \brief The interface to the MonitorObject's repository.
2422
///
2523
/// \author Barthélémy von Haller
@@ -44,9 +42,9 @@ class DatabaseInterface
4442
/**
4543
* Connects to the database.
4644
* For some implementations, this is a noop.
47-
* @param config Configuration where the connection parameters are stored.
45+
* @param config map of values coming from configuration library.
4846
*/
49-
virtual void connect(std::unique_ptr<ConfigurationInterface>& config) = 0;
47+
virtual void connect(const std::unordered_map<std::string, std::string>& config) = 0;
5048

5149
/**
5250
* Stores the serialized MonitorObject in the database.

Framework/include/QualityControl/MySqlDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class MySqlDatabase : public DatabaseInterface
3131
~MySqlDatabase() override;
3232

3333
void connect(std::string host, std::string database, std::string username, std::string password) override;
34-
void connect(std::unique_ptr<ConfigurationInterface>& config) override;
34+
void connect(const std::unordered_map& config) override;
3535
void store(std::shared_ptr<o2::quality_control::core::MonitorObject> mo) override;
3636
o2::quality_control::core::MonitorObject* retrieve(std::string taskName, std::string objectName) override;
3737
void disconnect() override;

Framework/src/CcdbDatabase.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ void CcdbDatabase::connect(std::string host, std::string database, std::string u
4141
ccdbApi.init(mUrl);
4242
}
4343

44-
void CcdbDatabase::connect(std::unique_ptr<ConfigurationInterface>& config)
44+
void CcdbDatabase::connect(const std::unordered_map<std::string, std::string>& config)
4545
{
46-
mUrl = config->get<string>("qc.config.database.host");
46+
mUrl = config.at("host");
4747
ccdbApi.init(mUrl);
4848
}
4949

Framework/src/Checker.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void Checker::init(framework::InitContext&)
6868
std::unique_ptr<ConfigurationInterface> config = ConfigurationFactory::getConfiguration(mConfigurationSource);
6969
// configuration of the database
7070
mDatabase = DatabaseFactory::create(config->get<std::string>("qc.config.database.implementation"));
71-
mDatabase->connect(config);
71+
mDatabase->connect(config->getRecursiveMap("qc.config.database"));
7272
} catch (
7373
std::string const& e) { // we have to catch here to print the exception because the device will make it disappear
7474
LOG(ERROR) << "exception : " << e;

Framework/src/MySqlDatabase.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ void MySqlDatabase::connect(std::string host, std::string database, std::string
5757
}
5858
}
5959

60-
void MySqlDatabase::connect(std::unique_ptr<ConfigurationInterface>& config)
60+
void MySqlDatabase::connect(const std::unordered_map<std::string, std::string>& config)
6161
{
62-
this->connect(config->get<string>("qc.config.database.host"),
63-
config->get<string>("qc.config.database.name"),
64-
config->get<string>("qc.config.database.username"),
65-
config->get<string>("qc.config.database.password"));
62+
this->connect(config.at("host"),
63+
config.at("name"),
64+
config.at("username"),
65+
config.at("password"));
6666
}
6767

6868
void MySqlDatabase::prepareTaskDataContainer(std::string taskName)

0 commit comments

Comments
 (0)