mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
FairMQProgOptions: initialize defaults in the constructor, not in ParseAll
This commit is contained in:
parent
778c8e16bb
commit
efdec0f6ba
|
@ -30,6 +30,8 @@ FairMQProgOptions::FairMQProgOptions()
|
|||
, fChannelInfo()
|
||||
, fMQKeyMap()
|
||||
{
|
||||
InitOptionDescription();
|
||||
ParseDefaults(fCmdLineOptions);
|
||||
}
|
||||
|
||||
FairMQProgOptions::~FairMQProgOptions()
|
||||
|
@ -50,8 +52,6 @@ int FairMQProgOptions::ParseAll(const vector<string>& cmdLineArgs, bool allowUnr
|
|||
|
||||
int FairMQProgOptions::ParseAll(const int argc, char const* const* argv, bool allowUnregistered)
|
||||
{
|
||||
InitOptionDescription();
|
||||
|
||||
if (FairProgOptions::ParseCmdLine(argc, argv, fCmdLineOptions, fVarMap, allowUnregistered))
|
||||
{
|
||||
// ParseCmdLine returns 0 if no immediate switches found.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -87,6 +88,21 @@ int FairProgOptions::ParseCmdLine(const int argc, char const* const* argv, const
|
|||
return ParseCmdLine(argc, argv, desc, fVarMap, allowUnregistered);
|
||||
}
|
||||
|
||||
void FairProgOptions::ParseDefaults(const po::options_description& desc)
|
||||
{
|
||||
vector<string> emptyArgs;
|
||||
emptyArgs.push_back("dummy");
|
||||
|
||||
vector<const char*> argv(emptyArgs.size());
|
||||
|
||||
transform(emptyArgs.begin(), emptyArgs.end(), argv.begin(), [](const string& str)
|
||||
{
|
||||
return str.c_str();
|
||||
});
|
||||
|
||||
po::store(po::parse_command_line(argv.size(), const_cast<char**>(argv.data()), desc), fVarMap);
|
||||
}
|
||||
|
||||
int FairProgOptions::PrintOptions()
|
||||
{
|
||||
// Method to overload.
|
||||
|
|
|
@ -161,6 +161,7 @@ class FairProgOptions
|
|||
// boost prog options parsers
|
||||
int ParseCmdLine(const int argc, char const* const* argv, const po::options_description& desc, po::variables_map& varmap, bool allowUnregistered = false);
|
||||
int ParseCmdLine(const int argc, char const* const* argv, const po::options_description& desc, bool allowUnregistered = false);
|
||||
void ParseDefaults(const po::options_description& desc);
|
||||
|
||||
virtual int ParseAll(const int argc, char const* const* argv, bool allowUnregistered = false) = 0;// TODO change return type to bool and propagate to executable
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ auto RunPushPullWithMsgResize(string transport, string address) -> void {
|
|||
|
||||
FairMQProgOptions config;
|
||||
config.SetValue<string>("session", to_string(session));
|
||||
config.SetValue<int>("io-threads", 1);
|
||||
config.SetValue<size_t>("shm-segment-size", 20000000);
|
||||
|
||||
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ auto RunSingleThreadedMultipart(string transport, string address) -> void {
|
|||
|
||||
FairMQProgOptions config;
|
||||
config.SetValue<string>("session", std::to_string(session));
|
||||
config.SetValue<int>("io-threads", 1);
|
||||
config.SetValue<size_t>("shm-segment-size", 20000000);
|
||||
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
|
||||
auto push = FairMQChannel{"Push", "push", factory};
|
||||
ASSERT_TRUE(push.Bind(address));
|
||||
|
|
Loading…
Reference in New Issue
Block a user