Part of IssueID #666.
Change-Id: Ia4969f636fbf6a3b00a9859d6705fc7375f0eb36
add_subdirectory(mdlib)
add_subdirectory(gmxpreprocess)
add_subdirectory(analysisdata)
+add_subdirectory(commandline)
add_subdirectory(options)
add_subdirectory(selection)
add_subdirectory(trajectoryanalysis)
--- /dev/null
+/*
+ *
+ * This source code is part of
+ *
+ * G R O M A C S
+ *
+ * GROningen MAchine for Chemical Simulations
+ *
+ * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2009, The GROMACS development team,
+ * check out http://www.gromacs.org for more information.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * If you want to redistribute modifications, please consider that
+ * scientific software is very special. Version control is crucial -
+ * bugs must be traceable. We will be happy to consider code for
+ * inclusion in the official distribution, but derived work must not
+ * be called official GROMACS. Details are found in the README & COPYING
+ * files - if they are missing, get the official version at www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the papers on the package - you can find them in the top README file.
+ *
+ * For more info, check our website at http://www.gromacs.org
+ */
+/*! \defgroup module_commandline Command Line Parsing and Help
+ * \ingroup group_utilitymodules
+ * \brief
+ * Provides functionality for parsing command-line arguments and writing help.
+ *
+ * This module implements gmx::CommandLineParser that assigns values to
+ * gmx::Options (see \ref module_options) based on command-line arguments.
+ * gmx::CommandLineHelpWriter is also provided to write help text for a program
+ * that uses the parser.
+ *
+ * \author Teemu Murtola <teemu.murtola@cbr.su.se>
+ */
+/*! \file
+ * \brief
+ * Public API convenience header for handling command-line parameters.
+ *
+ * \author Teemu Murtola <teemu.murtola@cbr.su.se>
+ * \inpublicapi
+ * \ingroup module_commandline
+ */
+#ifndef GMX_COMMANDLINE_H
+#define GMX_COMMANDLINE_H
+
+#include "commandline/cmdlinehelpwriter.h"
+#include "commandline/cmdlineparser.h"
+
+#endif
--- /dev/null
+file(GLOB COMMANDLINE_SOURCES *.cpp)
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${COMMANDLINE_SOURCES} PARENT_SCOPE)
+
+set(COMMANDLINE_PUBLIC_HEADERS
+ cmdlinehelpwriter.h
+ cmdlineparser.h)
+install(FILES ${COMMANDLINE_PUBLIC_HEADERS}
+ DESTINATION ${INCL_INSTALL_DIR}/gromacs/commandline
+ COMPONENT development)
+
+if (BUILD_TESTING)
+ add_subdirectory(tests)
+endif (BUILD_TESTING)
* Declares private implementation class for gmx::CommandLineHelpWriter.
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#ifndef GMX_OPTIONS_CMDLINEHELPWRITER_IMPL_H
-#define GMX_OPTIONS_CMDLINEHELPWRITER_IMPL_H
+#ifndef GMX_COMMANDLINE_CMDLINEHELPWRITER_IMPL_H
+#define GMX_COMMANDLINE_CMDLINEHELPWRITER_IMPL_H
#include "cmdlinehelpwriter.h"
/*! \internal \brief
* Private implementation class for CommandLineHelpWriter.
*
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class CommandLineHelpWriter::Impl
{
* Implements gmx::CommandLineHelpWriter.
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#include "gromacs/options/cmdlinehelpwriter.h"
+#include "cmdlinehelpwriter.h"
#include <cstdio>
#include <cstdlib>
/*! \internal \brief
* Helper object for writing section descriptions to help.
*
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class DescriptionWriter : public OptionsVisitor
{
/*! \internal \brief
* Helper object for writing help for file parameters.
*
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class FileParameterWriter : public OptionsTypeVisitor<FileNameOptionInfo>
{
/*! \internal \brief
* Helper object for writing help for non-file parameters.
*
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class ParameterWriter : public OptionsVisitor
{
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
* \inpublicapi
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#ifndef GMX_OPTIONS_CMDLINEHELPWRITER_H
-#define GMX_OPTIONS_CMDLINEHELPWRITER_H
+#ifndef GMX_COMMANDLINE_CMDLINEHELPWRITER_H
+#define GMX_COMMANDLINE_CMDLINEHELPWRITER_H
#include <cstdio>
* Writes help information for Options in ascii format.
*
* \inpublicapi
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class CommandLineHelpWriter
{
* Declares private implementation class for gmx::CommandLineParser.
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#ifndef GMX_OPTIONS_CMDLINEPARSER_IMPL_H
-#define GMX_OPTIONS_CMDLINEPARSER_IMPL_H
+#ifndef GMX_COMMANDLINE_CMDLINEPARSER_IMPL_H
+#define GMX_COMMANDLINE_CMDLINEPARSER_IMPL_H
#include "cmdlineparser.h"
-#include "optionsassigner.h"
+#include "../options/optionsassigner.h"
namespace gmx
{
/*! \internal \brief
* Private implementation class for CommandLineParser.
*
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class CommandLineParser::Impl
{
public:
//! Sets the options object to parse to.
- Impl(Options *options);
+ explicit Impl(Options *options);
//! Helper object for assigning the options.
OptionsAssigner _assigner;
* Implements gmx::CommandLineParser.
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#include "gromacs/options/cmdlineparser.h"
+#include "cmdlineparser.h"
#include <cctype>
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
* \inpublicapi
- * \ingroup module_options
+ * \ingroup module_commandline
*/
-#ifndef GMX_OPTIONS_CMDLINEPARSER_H
-#define GMX_OPTIONS_CMDLINEPARSER_H
+#ifndef GMX_COMMANDLINE_CMDLINEPARSER_H
+#define GMX_COMMANDLINE_CMDLINEPARSER_H
#include <string>
#include <vector>
* \endcode
*
* \inpublicapi
- * \ingroup module_options
+ * \ingroup module_commandline
*/
class CommandLineParser
{
--- /dev/null
+add_gtest_test(CommandLineUnitTests commandline-test
+ cmdlineparser.cpp)
* catch errors in other parts than just in command-line parsing.
*
* \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
+ * \ingroup module_commandline
*/
#include <cstdlib>
#include <cstring>
#include <gtest/gtest.h>
+#include "gromacs/commandline/cmdlineparser.h"
#include "gromacs/options/basicoptions.h"
-#include "gromacs/options/cmdlineparser.h"
#include "gromacs/options/options.h"
namespace
* Basic interface for providing options is implemented by the Options class
* and classes defined in basicoptions.h for specifying individual options.
* Only these are needed if a class wants to provide a set of standard options.
+ * When creating an Options object and adding options, it is possible to add
+ * descriptions for individual options as well as for the whole set of options.
+ * These can then be used to write out help text.
*
- * Values for options can be set using option parsers.
- * Currently, only one is defined: CommandLineParser.
- * As the name suggests, this parser gets values from command-line arguments.
- * Multiple parsers can be used in sequence to provide option values from
- * multiple sources; in such cases, if an option is provided in multiple
- * sources, new values overwrite any values from previous sources.
- *
- * In most cases, it is desirable to be able to provide a help describing the
- * available options. When creating an Options object and adding options, it
- * is possible to add descriptions for individual options as well as for the
- * whole set of options. These can then be used to write out a help using one
- * of the provided help writers.
- * Currently, only one is defined: CommandLineHelpWriter
- * (implementation is not yet complete).
+ * Module \ref module_commandline implements classes that assign option values
+ * from command line and produce help for programs that use the command line
+ * parser.
*
* \if libapi
* <H3>Advanced Use (in library API)</H3>
add_gtest_or_gmock_test(OptionsUnitTests options-test
- cmdlineparser.cpp option.cpp optionsassigner.cpp
+ option.cpp optionsassigner.cpp
timeunitmanager.cpp
GMOCK_ONLY abstractoptionstorage.cpp)
#include "statutil.h"
#include "gromacs/analysisdata/paralleloptions.h"
-#include "gromacs/options/cmdlinehelpwriter.h"
-#include "gromacs/options/cmdlineparser.h"
+#include "gromacs/commandline/cmdlinehelpwriter.h"
+#include "gromacs/commandline/cmdlineparser.h"
#include "gromacs/options/options.h"
#include "gromacs/selection/selectioncollection.h"
#include "gromacs/selection/selectionoptioninfo.h"
#include <boost/scoped_ptr.hpp>
-#include "gromacs/options/cmdlineparser.h"
+#include "gromacs/commandline/cmdlineparser.h"
#include "gromacs/options/options.h"
#include "gromacs/utility/errorcodes.h"
#include "gromacs/utility/gmxassert.h"