From 294c558d577cd4acb2ee8e94e0dfd6acdb946c6c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 7 Dec 2018 23:12:05 +0300 Subject: Add support for build configuration class inheritance --- mod/database-module.cxx | 66 +++++++------------------------------------------ 1 file changed, 9 insertions(+), 57 deletions(-) (limited to 'mod/database-module.cxx') diff --git a/mod/database-module.cxx b/mod/database-module.cxx index 137d7ef..07037cd 100644 --- a/mod/database-module.cxx +++ b/mod/database-module.cxx @@ -4,24 +4,13 @@ #include -#include // EIO - -#include - #include -#include // throw_generic_error() - #include #include -#include namespace brep { - using namespace std; - using namespace butl; - using namespace bbot; - // While currently the user-defined copy constructor is not required (we // don't need to deep copy nullptr's), it is a good idea to keep the // placeholder ready for less trivial cases. @@ -31,11 +20,7 @@ namespace brep : handler (r), retry_ (r.retry_), package_db_ (r.initialized_ ? r.package_db_ : nullptr), - build_db_ (r.initialized_ ? r.build_db_ : nullptr), - build_conf_ (r.initialized_ ? r.build_conf_ : nullptr), - build_conf_names_ (r.initialized_ ? r.build_conf_names_ : nullptr), - build_conf_map_ (r.initialized_ ? r.build_conf_map_ : nullptr), - bot_agent_keys_ (r.initialized_ ? r.bot_agent_keys_ : nullptr) + build_db_ (r.initialized_ ? r.build_db_ : nullptr) { } @@ -54,48 +39,15 @@ namespace brep } void database_module:: - init (const options::build& bo, const options::build_db& dbo, size_t retry) + init (const options::build_db& o, size_t retry) { - try - { - build_conf_ = shared_build_config (bo.build_config ()); - } - catch (const io_error& e) - { - ostringstream os; - os << "unable to read build configuration '" << bo.build_config () - << "': " << e; - - throw_generic_error (EIO, os.str ().c_str ()); - } - - if (bo.build_bot_agent_keys_specified ()) - bot_agent_keys_ = shared_bot_agent_keys (bo, bo.build_bot_agent_keys ()); - - cstrings conf_names; - - using conf_map_type = map; - conf_map_type conf_map; - - for (const auto& c: *build_conf_) - { - const char* cn (c.name.c_str ()); - conf_map[cn] = &c; - conf_names.push_back (cn); - } - - build_conf_names_ = make_shared (move (conf_names)); - build_conf_map_ = make_shared (move (conf_map)); - - build_db_ = shared_database (dbo.build_db_user (), - dbo.build_db_role (), - dbo.build_db_password (), - dbo.build_db_name (), - dbo.build_db_host (), - dbo.build_db_port (), - dbo.build_db_max_connections ()); + build_db_ = shared_database (o.build_db_user (), + o.build_db_role (), + o.build_db_password (), + o.build_db_name (), + o.build_db_host (), + o.build_db_port (), + o.build_db_max_connections ()); retry_ = retry_ < retry ? retry : retry_; } -- cgit v1.1