diff --git a/src/utility/settings.cpp b/src/utility/settings.cpp index 6a8baed69..d8ff685bf 100644 --- a/src/utility/settings.cpp +++ b/src/utility/settings.cpp @@ -11,6 +11,8 @@ #include "log4cplus/loggingmacros.h" extern log4cplus::Logger logger; +#include + namespace mrmc { namespace settings { @@ -50,12 +52,20 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) Settings::positional.add("trafile", 1); Settings::positional.add("labfile", 1); - //! Check module triggers + //! Check module triggers, add corresponding options + std::map< std::string, std::list< std::string > > options; + for (auto it : Settings::modules) { - std::pair< std::string, std::string > trigger = it.first; + options[it.first.first].push_back(it.first.second); + } + for (auto it : options) + { + std::stringstream str; + str << "select " << it.first << " module (" << boost::algorithm::join(it.second, ", ") << ")"; + Settings::desc->add_options() - (trigger.first.c_str(), bpo::value(), trigger.second.c_str()) + (it.first.c_str(), bpo::value(), str.str().c_str()) ; } @@ -205,8 +215,6 @@ std::ostream& help(std::ostream& os) os << *(mrmc::settings::Settings::desc) << std::endl; for (auto it : Settings::modules) { - std::pair< std::string, std::string > trigger = it.first; - os << "If --" << trigger.first << " = " << trigger.second << ":" << std::endl; os << *(it.second) << std::endl; } return os; diff --git a/src/utility/settings.h b/src/utility/settings.h index e30e9adbf..695f337d6 100644 --- a/src/utility/settings.h +++ b/src/utility/settings.h @@ -9,6 +9,7 @@ #define SETTINGS_H_ #include +#include #include #include #include @@ -101,14 +102,20 @@ namespace settings { * * This function implicitly defines the following interface for any SettingsModule: * @code - * static std::pair< std::string, std::string> getSettings(boost::program_options::options_description*); + * static std::string getModuleName(); + * static std::pair< std::string, std::string > getOptionTrigger(); + * static void putOptions(boost::program_options::options_description*); * @endcode */ template static void registerModule() { - bpo::options_description* desc = new bpo::options_description(); - Settings::modules[ T::getSettings(desc) ] = desc; + std::pair< std::string, std::string > trigger = T::getOptionTrigger(); + std::stringstream str; + str << T::getModuleName() << " (" << trigger.first << " = " << trigger.second << ")"; + bpo::options_description* desc = new bpo::options_description(str.str()); + T::putOptions(desc); + Settings::modules[ trigger ] = desc; } friend std::ostream& help(std::ostream& os);