Simplify ProgramInfo
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 28 Dec 2013 06:35:26 +0000 (08:35 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 27 Jan 2014 11:58:23 +0000 (12:58 +0100)
Remove realBinaryName() and invariantBinaryName() from ProgramInfo, as
they were only necessary for the command line module manager.  Instead,
pass the binary name to CommandLineModuleManager constructor and move
the invariant name logic into the manager.  This removes unnecessary
functionality from ProgramInfo, allowing to simplify it further.

Change-Id: I2f18dffcb5dde8e2101376444435bb13daf8c236

12 files changed:
src/gromacs/commandline/cmdlinehelpmodule.cpp
src/gromacs/commandline/cmdlinehelpmodule.h
src/gromacs/commandline/cmdlinemodulemanager.cpp
src/gromacs/commandline/cmdlinemodulemanager.h
src/gromacs/commandline/tests/cmdlinemodulemanager.cpp
src/gromacs/trajectoryanalysis/tests/test_selection.cpp
src/gromacs/utility/init.cpp
src/gromacs/utility/init.h
src/gromacs/utility/programinfo.cpp
src/gromacs/utility/programinfo.h
src/gromacs/utility/tests/programinfo.cpp
src/programs/gmx/gmx.cpp

index ba23dcc4a138e969128bc85ad82cd95299287816..d4746133a685431b1b966cc477510c8f5e5c3f2d 100644 (file)
@@ -79,6 +79,7 @@ class CommandLineHelpModuleImpl
 {
     public:
         CommandLineHelpModuleImpl(const ProgramInfo                &programInfo,
+                                  const std::string                &binaryName,
                                   const CommandLineModuleMap       &modules,
                                   const CommandLineModuleGroupList &groups);
 
@@ -86,6 +87,7 @@ class CommandLineHelpModuleImpl
 
         boost::scoped_ptr<RootHelpTopic>  rootTopic_;
         const ProgramInfo                &programInfo_;
+        std::string                       binaryName_;
         const CommandLineModuleMap       &modules_;
         const CommandLineModuleGroupList &groups_;
 
@@ -252,8 +254,7 @@ class ModuleHelpTopic : public HelpTopicInterface
 void ModuleHelpTopic::writeHelp(const HelpWriterContext & /*context*/) const
 {
     CommandLineHelpContext context(*helpModule_.context_);
-    const char *const      program =
-        helpModule_.programInfo_.realBinaryName().c_str();
+    const char *const      program = helpModule_.binaryName_.c_str();
     context.setModuleDisplayName(formatString("%s %s", program, module_.name()));
     module_.writeHelp(context);
 }
@@ -339,8 +340,7 @@ class HelpExportInterface
  */
 void initProgramLinks(HelpLinks *links, const CommandLineHelpModuleImpl &helpModule)
 {
-    const char *const                    program =
-        helpModule.programInfo_.realBinaryName().c_str();
+    const char *const                    program = helpModule.binaryName_.c_str();
     CommandLineModuleMap::const_iterator module;
     for (module = helpModule.modules_.begin();
          module != helpModule.modules_.end();
@@ -604,10 +604,11 @@ void HelpExportHtml::writeHtmlFooter(File *file) const
  */
 CommandLineHelpModuleImpl::CommandLineHelpModuleImpl(
         const ProgramInfo                &programInfo,
+        const std::string                &binaryName,
         const CommandLineModuleMap       &modules,
         const CommandLineModuleGroupList &groups)
     : rootTopic_(new RootHelpTopic(modules)), programInfo_(programInfo),
-      modules_(modules), groups_(groups),
+      binaryName_(binaryName), modules_(modules), groups_(groups),
       context_(NULL), moduleOverride_(NULL), bHidden_(false)
 {
 }
@@ -616,7 +617,7 @@ void CommandLineHelpModuleImpl::exportHelp(HelpExportInterface *exporter) const
 {
     // TODO: Would be nicer to have the file names supplied by the build system
     // and/or export a list of files from here.
-    const char *const program = programInfo_.realBinaryName().c_str();
+    const char *const program = binaryName_.c_str();
 
     exporter->startModuleExport();
     CommandLineModuleMap::const_iterator module;
@@ -648,9 +649,10 @@ void CommandLineHelpModuleImpl::exportHelp(HelpExportInterface *exporter) const
 
 CommandLineHelpModule::CommandLineHelpModule(
         const ProgramInfo                &programInfo,
+        const std::string                &binaryName,
         const CommandLineModuleMap       &modules,
         const CommandLineModuleGroupList &groups)
-    : impl_(new Impl(programInfo, modules, groups))
+    : impl_(new Impl(programInfo, binaryName, modules, groups))
 {
 }
 
index ce309164385b5d7af4da13e4be24109c15ad4029..860255cffd9fb2239f0963187d709e1fe2f31b89 100644 (file)
@@ -72,11 +72,14 @@ class CommandLineHelpModule : public CommandLineModuleInterface
          * Creates a command-line help module.
          *
          * \param[in] programInfo Information about the running binary.
+         * \param[in] binaryName  Name of the running binary
+         *     (without Gromacs binary suffix or .exe on Windows).
          * \param[in] modules  List of modules for to use for module listings.
          * \param[in] groups   List of module groups.
          * \throws    std::bad_alloc if out of memory.
          */
         CommandLineHelpModule(const ProgramInfo                &programInfo,
+                              const std::string                &binaryName,
                               const CommandLineModuleMap       &modules,
                               const CommandLineModuleGroupList &groups);
         ~CommandLineHelpModule();
index 3536199592fb7de04866dd7a3a1737ee0c32d8e8..25b78d5d1544f656fab5744006a5861bfb7d99e8 100644 (file)
@@ -62,6 +62,9 @@
 #include "gromacs/utility/programinfo.h"
 #include "gromacs/utility/stringutil.h"
 
+// For GMX_BINARY_SUFFIX
+#include "config.h"
+
 namespace gmx
 {
 
@@ -149,9 +152,11 @@ class CommandLineModuleManager::Impl
         /*! \brief
          * Initializes the implementation class.
          *
+         * \param[in] binaryName   Name of the running binary
+         *     (without Gromacs binary suffix or .exe on Windows).
          * \param     programInfo  Program information for the running binary.
          */
-        explicit Impl(ProgramInfo *programInfo);
+        Impl(const char *binaryName, ProgramInfo *programInfo);
 
         /*! \brief
          * Helper method that adds a given module to the module manager.
@@ -188,7 +193,7 @@ class CommandLineModuleManager::Impl
          *      \c modules_.end() if not found.
          *
          * Checks whether the program is invoked through a symlink whose name
-         * is different from ProgramInfo::realBinaryName(), and if so, checks
+         * is different from \a binaryName_, and if so, checks
          * if a module name matches the name of the symlink.
          *
          * Note that the \p programInfo parameter is currently not necessary
@@ -232,6 +237,8 @@ class CommandLineModuleManager::Impl
         CommandLineModuleGroupList   moduleGroups_;
         //! Information about the currently running program.
         ProgramInfo                 &programInfo_;
+        //! Name of the binary.
+        std::string                  binaryName_;
         /*! \brief
          * Module that implements help for the binary.
          *
@@ -251,8 +258,11 @@ class CommandLineModuleManager::Impl
         GMX_DISALLOW_COPY_AND_ASSIGN(Impl);
 };
 
-CommandLineModuleManager::Impl::Impl(ProgramInfo *programInfo)
-    : programInfo_(*programInfo), helpModule_(NULL), singleModule_(NULL),
+CommandLineModuleManager::Impl::Impl(const char  *binaryName,
+                                     ProgramInfo *programInfo)
+    : programInfo_(*programInfo),
+      binaryName_(binaryName != NULL ? binaryName : ""),
+      helpModule_(NULL), singleModule_(NULL),
       bQuiet_(false), bStdOutInfo_(false)
 {
     binaryInfoSettings_.copyright(true);
@@ -273,8 +283,8 @@ void CommandLineModuleManager::Impl::ensureHelpModuleExists()
 {
     if (helpModule_ == NULL)
     {
-        helpModule_ = new CommandLineHelpModule(programInfo_, modules_,
-                                                moduleGroups_);
+        helpModule_ = new CommandLineHelpModule(programInfo_, binaryName_,
+                                                modules_, moduleGroups_);
         addModule(CommandLineModulePointer(helpModule_));
     }
 }
@@ -290,20 +300,23 @@ CommandLineModuleMap::const_iterator
 CommandLineModuleManager::Impl::findModuleFromBinaryName(
         const ProgramInfo &programInfo) const
 {
-    std::string binaryName = programInfo.invariantProgramName();
-    if (binaryName == programInfo.realBinaryName())
+    std::string moduleName = programInfo.programName();
+#ifdef GMX_BINARY_SUFFIX
+    moduleName = stripSuffixIfPresent(moduleName, GMX_BINARY_SUFFIX);
+#endif
+    if (moduleName == binaryName_)
     {
         return modules_.end();
     }
-    if (binaryName.compare(0, 2, "g_") == 0)
+    if (startsWith(moduleName, "g_"))
     {
-        binaryName.erase(0, 2);
+        moduleName.erase(0, 2);
     }
-    if (binaryName.compare(0, 3, "gmx") == 0)
+    if (startsWith(moduleName, "gmx"))
     {
-        binaryName.erase(0, 3);
+        moduleName.erase(0, 3);
     }
-    return findModuleByName(binaryName);
+    return findModuleByName(moduleName);
 }
 
 CommandLineModuleInterface *
@@ -372,8 +385,7 @@ CommandLineModuleManager::Impl::processCommonOptions(int *argc, char ***argv)
     {
         if (singleModule_ == NULL)
         {
-            programInfo_.setDisplayName(
-                    programInfo_.realBinaryName() + " " + module->name());
+            programInfo_.setDisplayName(binaryName_ + " " + module->name());
         }
         // Recognize the common options also after the module name.
         // TODO: It could be nicer to only recognize -h/-hidden if module is not
@@ -412,8 +424,9 @@ CommandLineModuleManager::Impl::processCommonOptions(int *argc, char ***argv)
  * CommandLineModuleManager
  */
 
-CommandLineModuleManager::CommandLineModuleManager(ProgramInfo *programInfo)
-    : impl_(new Impl(programInfo))
+CommandLineModuleManager::CommandLineModuleManager(const char  *binaryName,
+                                                   ProgramInfo *programInfo)
+    : impl_(new Impl(binaryName, programInfo))
 {
 }
 
@@ -448,8 +461,7 @@ void CommandLineModuleManager::addModuleCMain(
 CommandLineModuleGroup CommandLineModuleManager::addModuleGroup(
         const char *title)
 {
-    const char *const                 binaryName =
-        impl_->programInfo_.invariantProgramName().c_str();
+    const char *const                 binaryName = impl_->binaryName_.c_str();
     CommandLineModuleGroupDataPointer group(
             new CommandLineModuleGroupData(impl_->modules_, binaryName, title));
     impl_->moduleGroups_.push_back(move(group));
@@ -509,7 +521,7 @@ int CommandLineModuleManager::runAsMainSingleModule(
     ProgramInfo &programInfo = gmx::init(&argc, &argv);
     try
     {
-        CommandLineModuleManager manager(&programInfo);
+        CommandLineModuleManager manager(NULL, &programInfo);
         manager.setSingleModule(module);
         int rc = manager.run(argc, argv);
         gmx::finalize();
index 3704a02a76793703e1d6e96c99236dd4aba06033..3582f65a852320d65464eb7373d945d905e8d683 100644 (file)
@@ -66,10 +66,10 @@ typedef gmx_unique_ptr<CommandLineModuleInterface>::type
  * \code
    int main(int argc, char *argv[])
    {
-       gmx::ProgramInfo &programInfo = gmx::init("gmx", &argc, &argv);
+       gmx::ProgramInfo &programInfo = gmx::init(&argc, &argv);
        try
        {
-           gmx::CommandLineModuleManager manager(&programInfo);
+           gmx::CommandLineModuleManager manager("gmx", &programInfo);
            // <register all necessary modules>
            int rc = manager.run(argc, argv);
            gmx::finalize();
@@ -159,16 +159,19 @@ class CommandLineModuleManager
         /*! \brief
          * Initializes a command-line module manager.
          *
+         * \param[in] binaryName   Name of the running binary
+         *     (without Gromacs binary suffix or .exe on Windows).
          * \param     programInfo  Program information for the running binary.
          * \throws    std::bad_alloc if out of memory.
          *
-         * The binary name is used to detect when the binary is run through a
+         * \p binaryName is used to detect when the binary is run through a
          * symlink, and automatically invoke a matching module in such a case.
          *
          * \p programInfo is non-const to allow the manager to amend it based
          * on the actual module that is getting executed.
          */
-        explicit CommandLineModuleManager(ProgramInfo *programInfo);
+        CommandLineModuleManager(const char  *binaryName,
+                                 ProgramInfo *programInfo);
         ~CommandLineModuleManager();
 
         /*! \brief
index bf11607f5faa5f4cf626f41a9325f37e62926ebf..85764af5f03f4d1dcf606ea401ee4ad255900f46 100644 (file)
@@ -142,8 +142,8 @@ void CommandLineModuleManagerTest::initManager(
         const CommandLine &args, const char *realBinaryName)
 {
     manager_.reset();
-    programInfo_.reset(new gmx::ProgramInfo(realBinaryName, args.argc(), args.argv()));
-    manager_.reset(new gmx::CommandLineModuleManager(programInfo_.get()));
+    programInfo_.reset(new gmx::ProgramInfo(args.argc(), args.argv()));
+    manager_.reset(new gmx::CommandLineModuleManager(realBinaryName, programInfo_.get()));
     manager_->setQuiet(true);
 }
 
index e13c4a0ec907cc928b0f0940f8875ea267260e78..664816b6055616409cd9367588a322cb55503a63 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -187,17 +187,5 @@ SelectionTester::writeOutput()
 int
 main(int argc, char *argv[])
 {
-    gmx::ProgramInfo::init(argc, argv);
-    try
-    {
-        gmx::SelectionTester                     module;
-        gmx::TrajectoryAnalysisCommandLineRunner runner(&module);
-        runner.setSelectionDebugLevel(1);
-        return runner.run(argc, argv);
-    }
-    catch (const std::exception &ex)
-    {
-        gmx::printFatalErrorMessage(stderr, ex);
-        return 1;
-    }
+    return gmx::TrajectoryAnalysisCommandLineRunner::runAsMain<gmx::SelectionTester>(argc, argv);
 }
index 54bde83be975fd3b034fe4cf7353316903cf2308..03569a6d99282813f1fe6d862187c3f8726bcc9d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -99,7 +99,7 @@ void broadcastArguments(const t_commrec *cr, int *argc, char ***argv)
 }   // namespace
 #endif
 
-ProgramInfo &init(const char *realBinaryName, int *argc, char ***argv)
+ProgramInfo &init(int *argc, char ***argv)
 {
 #ifdef GMX_LIB_MPI
     int isInitialized = 0, isFinalized = 0;
@@ -139,12 +139,7 @@ ProgramInfo &init(const char *realBinaryName, int *argc, char ***argv)
         broadcastArguments(&cr, argc, argv);
     }
 #endif
-    return ProgramInfo::init(realBinaryName, *argc, *argv);
-}
-
-ProgramInfo &init(int *argc, char ***argv)
-{
-    return init(NULL, argc, argv);
+    return ProgramInfo::init(*argc, *argv);
 }
 
 void finalize()
index 43d0d7d385024309f909aa7c39e76cdf1246e8d5..73e1b5bdb3d2a4ae08b06b4abbdc6d8fc1667c02 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -69,18 +69,12 @@ namespace gmx
 {
 
 /*! \brief
- * Initializes the \Gromacs library with explicit binary name.
+ * Initializes the \Gromacs library.
  *
- * \param[in] realBinaryName  Name of the binary
- *     (without Gromacs binary suffix or .exe on Windows).
  * \param[in] argc  argc value passed to main().
  * \param[in] argv  argv array passed to main().
  * \returns   Reference to initialized program information object.
  *
- * This overload is provided for cases where the program may be invoked
- * through a symlink, and it is necessary to know the real name of the
- * binary.
- *
  * Currently, this is tailored for use in command-line/standalone applications.
  * Some additional thought may be required to make it generally usable.
  *
@@ -93,18 +87,6 @@ namespace gmx
  *
  * \ingroup module_utility
  */
-ProgramInfo &init(const char *realBinaryName, int *argc, char ***argv);
-/*! \brief
- * Initializes the \Gromacs library.
- *
- * \param[in] argc  argc value passed to main().
- * \param[in] argv  argv array passed to main().
- * \returns   Reference to initialized program information object.
- *
- * Does not throw. Terminates the program on out-of-memory error.
- *
- * \ingroup module_utility
- */
 ProgramInfo &init(int *argc, char ***argv);
 /*! \brief
  * Deinitializes the \Gromacs library.
index 4c0f850769312824f8cd1c2d87eda9ad2e934c30..133144de964d312e832206f2ba5b5e828afa944d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -181,14 +181,12 @@ class ProgramInfo::Impl
 {
     public:
         Impl();
-        Impl(const char *realBinaryName, int argc, const char *const argv[],
+        Impl(int argc, const char *const argv[],
              ExecutableEnvironmentPointer env);
 
         ExecutableEnvironmentPointer  executableEnv_;
-        std::string                   realBinaryName_;
         std::string                   invokedName_;
         std::string                   programName_;
-        std::string                   invariantProgramName_;
         std::string                   displayName_;
         std::string                   commandLine_;
         mutable std::string           fullBinaryPath_;
@@ -197,29 +195,17 @@ class ProgramInfo::Impl
 };
 
 ProgramInfo::Impl::Impl()
-    : realBinaryName_("GROMACS"),
-      programName_("GROMACS"), invariantProgramName_("GROMACS")
+    : programName_("GROMACS")
 {
 }
 
-ProgramInfo::Impl::Impl(const char *realBinaryName,
-                        int argc, const char *const argv[],
+ProgramInfo::Impl::Impl(int argc, const char *const argv[],
                         ExecutableEnvironmentPointer env)
-    : executableEnv_(move(env)),
-      realBinaryName_(realBinaryName != NULL ? realBinaryName : "")
+    : executableEnv_(move(env))
 {
     invokedName_          = (argc != 0 ? argv[0] : "");
     programName_          = Path::splitToPathAndFilename(invokedName_).second;
     programName_          = stripSuffixIfPresent(programName_, ".exe");
-    invariantProgramName_ = programName_;
-#ifdef GMX_BINARY_SUFFIX
-    invariantProgramName_ =
-        stripSuffixIfPresent(invariantProgramName_, GMX_BINARY_SUFFIX);
-#endif
-    if (realBinaryName == NULL)
-    {
-        realBinaryName_ = invariantProgramName_;
-    }
 
     commandLine_ = quoteIfNecessary(programName_.c_str());
     for (int i = 1; i < argc; ++i)
@@ -247,20 +233,13 @@ const ProgramInfo &ProgramInfo::getInstance()
 
 // static
 ProgramInfo &ProgramInfo::init(int argc, const char *const argv[])
-{
-    return init(NULL, argc, argv);
-}
-
-// static
-ProgramInfo &ProgramInfo::init(const char *realBinaryName,
-                               int argc, const char *const argv[])
 {
     try
     {
         tMPI::lock_guard<tMPI::mutex> lock(g_programInfoMutex);
         if (g_programInfo.get() == NULL)
         {
-            g_programInfo.reset(new ProgramInfo(realBinaryName, argc, argv));
+            g_programInfo.reset(new ProgramInfo(argc, argv));
         }
         return *g_programInfo;
     }
@@ -276,29 +255,21 @@ ProgramInfo::ProgramInfo()
 {
 }
 
-ProgramInfo::ProgramInfo(const char *realBinaryName)
-    : impl_(new Impl(realBinaryName, 1, &realBinaryName,
+ProgramInfo::ProgramInfo(const char *binaryName)
+    : impl_(new Impl(1, &binaryName,
                      DefaultExecutableEnvironment::create()))
 {
 }
 
 ProgramInfo::ProgramInfo(int argc, const char *const argv[])
-    : impl_(new Impl(NULL, argc, argv,
+    : impl_(new Impl(argc, argv,
                      DefaultExecutableEnvironment::create()))
 {
 }
 
-ProgramInfo::ProgramInfo(const char *realBinaryName,
-                         int argc, const char *const argv[])
-    : impl_(new Impl(realBinaryName, argc, argv,
-                     DefaultExecutableEnvironment::create()))
-{
-}
-
-ProgramInfo::ProgramInfo(const char *realBinaryName,
-                         int argc, const char *const argv[],
+ProgramInfo::ProgramInfo(int argc, const char *const argv[],
                          ExecutableEnvironmentPointer env)
-    : impl_(new Impl(realBinaryName, argc, argv, move(env)))
+    : impl_(new Impl(argc, argv, move(env)))
 {
 }
 
@@ -314,21 +285,11 @@ void ProgramInfo::setDisplayName(const std::string &name)
     impl_->displayName_ = name;
 }
 
-const std::string &ProgramInfo::realBinaryName() const
-{
-    return impl_->realBinaryName_;
-}
-
 const std::string &ProgramInfo::programName() const
 {
     return impl_->programName_;
 }
 
-const std::string &ProgramInfo::invariantProgramName() const
-{
-    return impl_->invariantProgramName_;
-}
-
 const std::string &ProgramInfo::displayName() const
 {
     tMPI::lock_guard<tMPI::mutex> lock(impl_->displayNameMutex_);
index 0467e1bbc0d6111f3f3b63d11a8804dc22337054..3382f1a3da3dae9eb5ae0bba19a796bb573d2c16 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -132,29 +132,9 @@ class ProgramInfo
          * \param[in] argv  argv array passed to main().
          * \returns   Reference to initialized program information object.
          *
-         * The return value of realBinaryName() is the same as
-         * invariantProgramName().
-         *
          * Does not throw. Terminates the program on out-of-memory error.
          */
         static ProgramInfo &init(int argc, const char *const argv[]);
-        /*! \brief
-         * Initializes global program information with explicit binary name.
-         *
-         * \param[in] realBinaryName  Name of the binary
-         *     (without Gromacs binary suffix or .exe on Windows).
-         * \param[in] argc  argc value passed to main().
-         * \param[in] argv  argv array passed to main().
-         * \returns   Reference to initialized program information object.
-         *
-         * This overload is provided for cases where the program may be invoked
-         * through a symlink, and it is necessary to know the real name of the
-         * binary.
-         *
-         * Does not throw. Terminates the program on out-of-memory error.
-         */
-        static ProgramInfo &init(const char *realBinaryName,
-                                 int argc, const char *const argv[]);
 
         /*! \brief
          * Constructs an empty program info objects.
@@ -165,14 +145,13 @@ class ProgramInfo
         /*! \brief
          * Initializes a program information object with binary name only.
          *
-         * \param[in] realBinaryName  Name of the binary
-         *     (without Gromacs binary suffix or .exe on Windows).
+         * \param[in] binaryName  Name of the binary.
          *
          * This is needed for unit testing purposes.
          * The constructed object works as if the command line consisted of
          * only of the binary name.
          */
-        explicit ProgramInfo(const char *realBinaryName);
+        explicit ProgramInfo(const char *binaryName);
         /*! \brief
          * Initializes a program information object based on command line.
          *
@@ -184,19 +163,6 @@ class ProgramInfo
          * Initializes a program information object based on binary name and
          * command line.
          *
-         * \param[in] realBinaryName  Name of the binary
-         *     (without Gromacs binary suffix or .exe on Windows).
-         * \param[in] argc  argc value passed to main().
-         * \param[in] argv  argv array passed to main().
-         */
-        ProgramInfo(const char *realBinaryName,
-                    int argc, const char *const argv[]);
-        /*! \brief
-         * Initializes a program information object based on binary name and
-         * command line.
-         *
-         * \param[in] realBinaryName  Name of the binary
-         *     (without Gromacs binary suffix or .exe on Windows).
          * \param[in] argc  argc value passed to main().
          * \param[in] argv  argv array passed to main().
          * \param[in] env   Customizes the way the binary name is handled.
@@ -210,8 +176,7 @@ class ProgramInfo
          * into a non-Gromacs executable (with possible extensions in
          * ExecutableEnvironmentInterface).
          */
-        ProgramInfo(const char *realBinaryName,
-                    int argc, const char *const argv[],
+        ProgramInfo(int argc, const char *const argv[],
                     ExecutableEnvironmentPointer env);
         ~ProgramInfo();
 
@@ -226,30 +191,12 @@ class ProgramInfo
          */
         void setDisplayName(const std::string &name);
 
-        /*! \brief
-         * Returns the real name of the binary.
-         *
-         * The returned value is comparable to invariantProgramName(), i.e., it
-         * has suffixes and OS-specific extensions removed.
-         *
-         * Does not throw.
-         */
-        const std::string &realBinaryName() const;
         /*! \brief
          * Returns the name of the binary as it was invoked without any path.
          *
          * Does not throw.
          */
         const std::string &programName() const;
-        /*! \brief
-         * Returns an invariant name of the binary.
-         *
-         * The returned value has OS-specific extensions (.exe on Windows)
-         * removed, as well as any binary suffix that was configured.
-         *
-         * Does not throw.
-         */
-        const std::string &invariantProgramName() const;
         /*! \brief
          * Returns a display name of the current module.
          *
index 16dbf43c4346c51b5e03381fb8552bd5f191ae2f..4c8f0016760f771d79531debdc0ec9e2d1c5f130 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -111,7 +111,7 @@ class ProgramInfoTest : public ::testing::Test
         void testBinaryPathSearch(const char *argv0)
         {
             ASSERT_TRUE(env_.get() != NULL);
-            gmx::ProgramInfo  info(NULL, 1, &argv0, move(env_));
+            gmx::ProgramInfo  info(1, &argv0, move(env_));
             EXPECT_EQ(expectedExecutable_, info.fullBinaryPath());
         }
         void testBinaryPathSearch(const std::string &argv0)
index 09f4b4868cc1fc19b782769ce3efdd10a9391701..366881b7e7290049eb13fa1f41c11a0c18b33af6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 int
 main(int argc, char *argv[])
 {
-    gmx::ProgramInfo &info = gmx::init("gmx", &argc, &argv);
+    gmx::ProgramInfo &info = gmx::init(&argc, &argv);
     try
     {
-        gmx::CommandLineModuleManager manager(&info);
+        gmx::CommandLineModuleManager manager("gmx", &info);
         registerTrajectoryAnalysisModules(&manager);
         registerLegacyModules(&manager);
         manager.addHelpTopic(gmx::SelectionCollection::createDefaultHelpTopic());