Skip to content

Commit

Permalink
Make ModuleConfiguartion a friend of ConfigurationManager so that Con…
Browse files Browse the repository at this point in the history
…figurationManager does not have to expose Configuration pointer publicly
  • Loading branch information
gcrone committed Nov 30, 2023
1 parent 7b1f132 commit f7d7ed1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions include/appfwk/ConfigurationManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ namespace coredal {
namespace appfwk {

class ConfigurationManager {
friend class ModuleConfiguration;

std::shared_ptr<oksdbinterfaces::Configuration> m_confdb;
std::string m_appName;
std::string m_sessionName;
std::string m_oksConfigSpec;
const coredal::Session* m_session;
const coredal::Application* m_application;
static std::shared_ptr<ConfigurationManager> s_instance;

static std::shared_ptr<ConfigurationManager> s_instance;
ConfigurationManager();
public:
static std::shared_ptr<ConfigurationManager> get() {
if (!s_instance) {
Expand All @@ -45,11 +48,10 @@ namespace appfwk {
void initialise(std::string& configSpec,
std::string& appName,
std::string& sessionName) ;
std::shared_ptr<oksdbinterfaces::Configuration> confdb() {return m_confdb;}

const coredal::Session* session() {return m_session;}
const coredal::Application* application() {return m_application;}
template<typename T> const T* get_dal(const std::string& name) {return m_confdb->get<T>(name);}
std::string oks_config_spec() {return m_oksConfigSpec;}
};

} // namespace appfwk
Expand Down
5 changes: 2 additions & 3 deletions src/ModuleConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ModuleConfiguration::initialise()
auto cfMgr = ConfigurationManager::get();
auto session = cfMgr->session();
auto application = cfMgr->application();
std::shared_ptr<oksdbinterfaces::Configuration> confdb = cfMgr->confdb();
std::shared_ptr<oksdbinterfaces::Configuration> confdb = cfMgr->m_confdb;


TLOG_DBG(5) << "getting modules";
Expand All @@ -37,8 +37,7 @@ ModuleConfiguration::initialise()
}
auto smartDaqApp = application->cast<appdal::SmartDaqApplication>();
if (smartDaqApp) {
auto configSpec = cfMgr->oks_config_spec();
std::string oksFile = configSpec.substr(9); // Strip off "oksconfig:"
std::string oksFile = cfMgr->m_oksConfigSpec.substr(9); // Strip off "oksconfig:"
m_modules = smartDaqApp->generate_modules(confdb.get(), oksFile, session);
}
auto resSet = application->cast<coredal::ResourceSet>();
Expand Down

0 comments on commit f7d7ed1

Please sign in to comment.