* This constructor is not explicit to allow initialization of
* histograms directly from AnalysisHistogramSettingsInitializer:
* \code
- gmx::AnalysisDataSimpleHistogramModule *hist =
- new gmx::AnalysisDataSimpleHistogramModule(
- histogramFromRange(0.0, 5.0).binWidth(0.5));
+ gmx::AnalysisDataSimpleHistogramModule *hist =
+ new gmx::AnalysisDataSimpleHistogramModule(
+ histogramFromRange(0.0, 5.0).binWidth(0.5));
* \endcode
*/
AnalysisHistogramSettings(const AnalysisHistogramSettingsInitializer &settings);
};
//! Multipoint input data for gmx::AnalysisDataAverageModule tests.
const real mpinputdata[] = {
+ // *INDENT-OFF*
1.0, 0.0, 1.0, 2.0, MPSTOP,
1.0, 0.0, MPSTOP,
2.0, END_OF_FRAME,
2.0, 1.0, 1.0, MPSTOP,
2.0, END_OF_FRAME,
3.0, 2.0, 0.0, 0.0, END_OF_FRAME
+ // *INDENT-ON*
};
*
* Typical usage:
* \code
-int
-main(int argc, char *argv[])
-{
- const gmx::ProgramInfo &programInfo =
- gmx::ProgramInfo::init("gmx", argc, argv);
- CopyRight(stderr, argv[0]);
- try
- {
- gmx::CommandLineModuleManager manager(programInfo);
- // <register all necessary modules>
- return manager.run(argc, argv);
- }
- catch (const std::exception &ex)
- {
- gmx::printFatalErrorMessage(stderr, ex);
- return 1;
- }
-}
+ int
+ main(int argc, char *argv[])
+ {
+ const gmx::ProgramInfo &programInfo =
+ gmx::ProgramInfo::init("gmx", argc, argv);
+ CopyRight(stderr, argv[0]);
+ try
+ {
+ gmx::CommandLineModuleManager manager(programInfo);
+ // <register all necessary modules>
+ return manager.run(argc, argv);
+ }
+ catch (const std::exception &ex)
+ {
+ gmx::printFatalErrorMessage(stderr, ex);
+ return 1;
+ }
+ }
* \endcode
*
* \inpublicapi
*
* Typical usage (without error checking):
* \code
-gmx::Options options("name", "description");
-// Fill up options
+ gmx::Options options("name", "description");
+ // Fill up options
-gmx::CommandLineParser(&options).parse(&argc, argv);
-options.finish();
+ gmx::CommandLineParser(&options).parse(&argc, argv);
+ options.finish();
* \endcode
*
* \inpublicapi
*
* Typical usage:
* \code
-gmx::TextTableFormatter formatter;
-formatter.addColumn("Name", 10, false);
-formatter.addColumn("Type", 10, false);
-formatter.addColumn("Description", 50, true);
-
-formatter.clear();
-formatter.addColumnLine(0, "name");
-formatter.addColumnLine(1, "type");
-formatter.addColumnLine(2, "Description for name");
-printf("%s", formatter.formatRow().c_str());
-
-formatter.clear();
-formatter.addColumnLine(0, "averylongname");
-formatter.addColumnLine(1, "type");
-formatter.setColumnFirstLineOffset(1, 1);
-formatter.addColumnLine(2, "Description for name");
-printf("%s", formatter.formatRow().c_str());
-
-// format other rows by repeating the above code
+ gmx::TextTableFormatter formatter;
+ formatter.addColumn("Name", 10, false);
+ formatter.addColumn("Type", 10, false);
+ formatter.addColumn("Description", 50, true);
+
+ formatter.clear();
+ formatter.addColumnLine(0, "name");
+ formatter.addColumnLine(1, "type");
+ formatter.addColumnLine(2, "Description for name");
+ printf("%s", formatter.formatRow().c_str());
+
+ formatter.clear();
+ formatter.addColumnLine(0, "averylongname");
+ formatter.addColumnLine(1, "type");
+ formatter.setColumnFirstLineOffset(1, 1);
+ formatter.addColumnLine(2, "Description for name");
+ printf("%s", formatter.formatRow().c_str());
+
+ // format other rows by repeating the above code
* \endcode
*
* Methods in this class may throw std::bad_alloc if out of memory.
*
* Typical use:
* \code
-struct ExampleHelpText
-{
- static const char name[];
- static const char title[];
- static const char *const text[];
-};
+ struct ExampleHelpText
+ {
+ static const char name[];
+ static const char title[];
+ static const char *const text[];
+ };
-const char ExampleHelpText::name[] = "example";
-const char ExampleHelpText::title[] =
- "Example title";
-const char *const ExampleHelpText::text[] = {
- "Text for the topic.",
- "More text for the topic."
-};
+ const char ExampleHelpText::name[] = "example";
+ const char ExampleHelpText::title[] =
+ "Example title";
+ const char *const ExampleHelpText::text[] = {
+ "Text for the topic.",
+ "More text for the topic."
+ };
-typedef SimpleHelpTopic<ExampleHelpText> ExampleHelpTopic;
+ typedef SimpleHelpTopic<ExampleHelpText> ExampleHelpTopic;
* \endcode
*
* \inlibraryapi
*
* This template is used as a base class like this:
* \code
-class ConcreteOption : public OptionTemplate<int, ConcreteOption>
-{
+ class ConcreteOption : public OptionTemplate<int, ConcreteOption>
+ {
* \endcode
*
* All public functions in this class return \c *this casted to a reference to
*
* Example:
* \code
-bool bPBC;
-using gmx::BooleanOption;
-options.addOption(BooleanOption("pbc").store(&bPBC));
+ bool bPBC;
+ using gmx::BooleanOption;
+ options.addOption(BooleanOption("pbc").store(&bPBC));
* \endcode
*
* Public methods in this class do not throw.
*
* Examples:
* \code
-using gmx::IntegerOption;
-// Simple option
-int rcut = 0;
-options.addOption(IntegerOption("rcut").store(&rcut));
-// Vector-valued option
-int box[3] = {1, 1, 1}; // Default value
-options.addOption(IntegerOption("box").store(box).vector());
+ using gmx::IntegerOption;
+ // Simple option
+ int rcut = 0;
+ options.addOption(IntegerOption("rcut").store(&rcut));
+ // Vector-valued option
+ int box[3] = {1, 1, 1}; // Default value
+ options.addOption(IntegerOption("box").store(box).vector());
* \endcode
*
* Public methods in this class do not throw.
*
* Examples:
* \code
-using gmx::StringOption;
-// Simple option
-std::string str;
-options.addOption(StringOption("str").store(&str));
-// Option that only accepts predefined values
-const char * const allowed[] = { "atom", "residue", "molecule", NULL };
-std::string str;
-int type;
-options.addOption(StringOption("type").enumValue(allowed).store(&str)
- .storeEnumIndex(&type));
+ using gmx::StringOption;
+ // Simple option
+ std::string str;
+ options.addOption(StringOption("str").store(&str));
+ // Option that only accepts predefined values
+ const char * const allowed[] = { "atom", "residue", "molecule", NULL };
+ std::string str;
+ int type;
+ options.addOption(StringOption("type").enumValue(allowed).store(&str)
+ .storeEnumIndex(&type));
* \endcode
*
* Public methods in this class do not throw.
* Standard usage is to write a method that creates an Options that is owned by
* the object, populates it with supported options, and then returns it:
* \code
-// <as class attributes>
-using gmx::Options;
-Options options("common", "Common Options");
-std::string arg1;
-int arg2;
-
-// <populating>
-using gmx::StringOption;
-using gmx::IntegerOption;
-options.addOption(StringOption("arg1").store(&arg1));
-options.addOption(IntegerOption("arg2").store(&arg2));
-return &options;
+ // <as class attributes>
+ using gmx::Options;
+ Options options("common", "Common Options");
+ std::string arg1;
+ int arg2;
+
+ // <populating>
+ using gmx::StringOption;
+ using gmx::IntegerOption;
+ options.addOption(StringOption("arg1").store(&arg1));
+ options.addOption(IntegerOption("arg2").store(&arg2));
+ return &options;
* \endcode
* The caller of that method can then use a parser implementation such as
* CommandLineParser to provide values for the options.
* to assign values to options in subsections within the Options object.
* Typical use (without error handling):
* \code
-gmx::options::Options options("name", "Title");
-// Set up options
+ gmx::options::Options options("name", "Title");
+ // Set up options
-gmx::options::OptionsAssigner assigner(&options);
-assigner.start();
-assigner.startOption("opt1");
-assigner.appendValue("3");
-assigner.finishOption();
-assigner.startSubSection("section");
-assigner.startOption("opt2"); // Now in the subsection
-assigner.appendValue("yes");
-assigner.finishOption();
-assigner.finishSubSection()
-assigner.startOption("opt3"); // Again in the main options
-assigner.appendValue("2");
-assigner.finishOption();
-assigner.finish();
+ gmx::options::OptionsAssigner assigner(&options);
+ assigner.start();
+ assigner.startOption("opt1");
+ assigner.appendValue("3");
+ assigner.finishOption();
+ assigner.startSubSection("section");
+ assigner.startOption("opt2"); // Now in the subsection
+ assigner.appendValue("yes");
+ assigner.finishOption();
+ assigner.finishSubSection()
+ assigner.startOption("opt3"); // Again in the main options
+ assigner.appendValue("2");
+ assigner.finishOption();
+ assigner.finish();
* \endcode
*
* \inlibraryapi
* Typical use (loop over all options, iteratively descending into
* subsections):
* \code
-class Visitor : public gmx::OptionsVisitor
-{
- public:
- void visitSubSection(const Options §ion)
- {
- OptionsIterator iterator(section);
- iterator.acceptSubSections(this);
- iterator.acceptOptions(this);
- }
+ class Visitor : public gmx::OptionsVisitor
+ {
+ public:
+ void visitSubSection(const Options §ion)
+ {
+ OptionsIterator iterator(section);
+ iterator.acceptSubSections(this);
+ iterator.acceptOptions(this);
+ }
- void visitOption(const OptionInfo &option)
- {
- // Do something.
- }
-}
+ void visitOption(const OptionInfo &option)
+ {
+ // Do something.
+ }
+ }
-Visitor().visitSubSection(options);
+ Visitor().visitSubSection(options);
* \endcode
*
* \inlibraryapi
*
* Example use:
* \code
-SelectionList sel;
-Options options("example", "Example options");
-SelectionOptionInfo *info;
-info = options.addOption(SelectionOption("sel").storeVector(&sel)
- .multiValue());
-// < ... assign values to options ...>
-if ( condition )
-{
- // Put limitations on the selections based on the condition,
- // which can depend on other option values.
- // Throws if input given so far violates the limitations.
- info->setValueCount(2);
- info->setOnlyStatic(true);
-}
+ SelectionList sel;
+ Options options("example", "Example options");
+ SelectionOptionInfo *info;
+ info = options.addOption(SelectionOption("sel").storeVector(&sel)
+ .multiValue());
+ // < ... assign values to options ...>
+ if ( condition )
+ {
+ // Put limitations on the selections based on the condition,
+ // which can depend on other option values.
+ // Throws if input given so far violates the limitations.
+ info->setValueCount(2);
+ info->setOnlyStatic(true);
+ }
* \endcode
*
* \inpublicapi
* An example \c gmx_ana_selmethod_t definition could look like this:
*
* \code
- * gmx_ana_selmethod_t sm_example = {
- * "example", GROUP_VALUE, 0,
- * asize(sm_params_example), sm_params_example,
- * &init_data_example,
- * NULL,
- * &init_example,
- * NULL,
- * &free_data_example,
- * &init_frame_example,
- * &evaluate_example,
- * NULL,
- * {"example from POS_EXPR [cutoff REAL]", 0, NULL},
- * };
+ gmx_ana_selmethod_t sm_example = {
+ "example", GROUP_VALUE, 0,
+ asize(sm_params_example), sm_params_example,
+ &init_data_example,
+ NULL,
+ &init_example,
+ NULL,
+ &free_data_example,
+ &init_frame_example,
+ &evaluate_example,
+ NULL,
+ {"example from POS_EXPR [cutoff REAL]", 0, NULL},
+ };
* \endcode
*
* The first value defines the name of the method.
*
* An example parameter definition:
* \code
- * static gmx_ana_selparam_t sm_params_example[] = {
- * {"cutoff", {REAL_VALUE, 1, {NULL}}, NULL, SPAR_OPTIONAL},
- * {"from", {POS_VALUE, -1, {NULL}}, NULL, SPAR_DYNAMIC | SPAR_VARNUM},
- * };
+ static gmx_ana_selparam_t sm_params_example[] = {
+ {"cutoff", {REAL_VALUE, 1, {NULL}}, NULL, SPAR_OPTIONAL},
+ {"from", {POS_VALUE, -1, {NULL}}, NULL, SPAR_DYNAMIC | SPAR_VARNUM},
+ };
* \endcode
*
* The first value gives the name of the parameter.
*
* Intended use:
* \code
-// In exampleclass.h
-class ExampleClass
-{
- public:
- ExampleClass();
- ~ExampleClass(); // Must not be defined inline
+ // In exampleclass.h
+ class ExampleClass
+ {
+ public:
+ ExampleClass();
+ ~ExampleClass(); // Must not be defined inline
- // <...>
+ // <...>
- private:
- class Impl;
+ private:
+ class Impl;
- PrivateImplPointer<Impl> impl_;
-};
+ PrivateImplPointer<Impl> impl_;
+ };
-// In exampleclass.cpp
+ // In exampleclass.cpp
-// <definition of ExampleClass::Impl>
+ // <definition of ExampleClass::Impl>
-ExampleClass::ExampleClass()
- : impl_(new Impl)
-{
-}
+ ExampleClass::ExampleClass()
+ : impl_(new Impl)
+ {
+ }
-ExampleClass::~ExampleClass()
-{
-}
+ ExampleClass::~ExampleClass()
+ {
+ }
* \endcode
* \inlibraryapi
* \ingroup module_utility
*
* Basic usage:
* \code
-if (value < 0)
-{
- GMX_THROW(InconsistentUserInput("Negative values not allowed for value"));
-}
+ if (value < 0)
+ {
+ GMX_THROW(InconsistentUserInput("Negative values not allowed for value"));
+ }
* \endcode
*/
#define GMX_THROW(e) \
*
* Typical usage (note that gmx::File wraps this particular case):
* \code
-FILE *fp = fopen("filename.txt", "r");
-if (fp == NULL)
-{
- GMX_THROW(FileIOError("Could not open file"), "fopen", errno);
-}
+ FILE *fp = fopen("filename.txt", "r");
+ if (fp == NULL)
+ {
+ GMX_THROW(FileIOError("Could not open file"), "fopen", errno);
+ }
* \endcode
*/
#define GMX_THROW_WITH_ERRNO(e, syscall, err) \
*
* Normal usage in Gromacs command-line programs is like this:
* \code
-int main(int argc, char *argv[])
-{
- gmx::ProgramInfo::init(argc, argv);
- try
- {
- // The actual code for the program
- return 0;
- }
- catch (const std::exception &ex)
- {
- gmx::printFatalErrorMessage(stderr, ex);
- return 1;
- }
-}
+ int main(int argc, char *argv[])
+ {
+ gmx::ProgramInfo::init(argc, argv);
+ try
+ {
+ // The actual code for the program
+ return 0;
+ }
+ catch (const std::exception &ex)
+ {
+ gmx::printFatalErrorMessage(stderr, ex);
+ return 1;
+ }
+ }
* \endcode
*/
void printFatalErrorMessage(FILE *fp, const std::exception &ex);
*
* Usage:
* \code
-try
-{
- // C++ code
-}
-GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+ try
+ {
+ // C++ code
+ }
+ GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
* \endcode
*
* \inlibraryapi
* Terminating newline will be present in \p line if it was present in
* the file.
* To loop over all lines in the file, use:
-\code
-std::string line;
-while (file.readLine(&line))
-{
- // ...
-}
-\endcode
+ * \code
+ std::string line;
+ while (file.readLine(&line))
+ {
+ // ...
+ }
+ * \endcode
*/
bool readLine(std::string *line);
*
* Example usage:
* \code
-bool function(::gmx::MessageStringCollector *errors)
-{
- ::gmx::MessageStringContext errcontext(errors, "In function()");
- bool bOk = function2(errors);
- bOk = function3(errors) && bOk;
- // <more processing>
- return bOk;
-}
+ bool function(::gmx::MessageStringCollector *errors)
+ {
+ ::gmx::MessageStringContext errcontext(errors, "In function()");
+ bool bOk = function2(errors);
+ bOk = function3(errors) && bOk;
+ // <more processing>
+ return bOk;
+ }
* \endcode
*
* \see MessageStringCollector
*
* Typical usage:
* \code
-gmx::TextLineWrapper wrapper;
-wrapper.settings().setLineLength(78);
-printf("%s\n", wrapper.wrapToString(textToWrap).c_str());
+ gmx::TextLineWrapper wrapper;
+ wrapper.settings().setLineLength(78);
+ printf("%s\n", wrapper.wrapToString(textToWrap).c_str());
* \endcode
*
* \inpublicapi
* space.
*
* To iterate over lines in a string, use the following code:
-\code
-gmx::TextLineWrapper wrapper;
-// <set desired wrapping settings>
-size_t lineStart = 0;
-size_t length = input.length();
-while (lineStart < length)
-{
- size_t nextLineStart = wrapper.findNextLine(input, lineStart);
- std::string line = wrapper.formatLine(input, lineStart, nextLineStart));
- // <do something with the line>
- lineStart = nextLineStart;
-}
-return result;
-\endcode
+ * \code
+ gmx::TextLineWrapper wrapper;
+ // <set desired wrapping settings>
+ size_t lineStart = 0;
+ size_t length = input.length();
+ while (lineStart < length)
+ {
+ size_t nextLineStart = wrapper.findNextLine(input, lineStart);
+ std::string line = wrapper.formatLine(input, lineStart, nextLineStart));
+ // <do something with the line>
+ lineStart = nextLineStart;
+ }
+ return result;
+ * \endcode
*
* Does not throw.
*/
*
* Avoid using directly as a type, use a typedef instead. Typical usage:
* \code
-typedef gmx_unique_ptr<ExampleClass>::type ExampleClassPointer;
+ typedef gmx_unique_ptr<ExampleClass>::type ExampleClassPointer;
* \endcode
*
* \ingroup module_utility
*
* Simple example (using Google Test):
* \code
-int functionToTest(int param);
+ int functionToTest(int param);
-TEST(MyTest, SimpleTest)
-{
- gmx::test::TestReferenceData data;
+ TEST(MyTest, SimpleTest)
+ {
+ gmx::test::TestReferenceData data;
- gmx::test::TestReferenceChecker checker(data.rootChecker());
- checker.checkInteger(functionToTest(3), "ValueWith3");
- checker.checkInteger(functionToTest(5), "ValueWith5");
- gmx::test::TestReferenceChecker compound(checker.startCompound("CustomCompound", "Item"));
- compound.checkInteger(function2ToTest(3), "ValueWith3");
- compound.checkInteger(function2ToTest(5), "ValueWith5");
- checker.checkInteger(functionToTest(4), "ValueWith4");
-}
+ gmx::test::TestReferenceChecker checker(data.rootChecker());
+ checker.checkInteger(functionToTest(3), "ValueWith3");
+ checker.checkInteger(functionToTest(5), "ValueWith5");
+ gmx::test::TestReferenceChecker compound(
+ checker.startCompound("CustomCompound", "Item"));
+ compound.checkInteger(function2ToTest(3), "ValueWith3");
+ compound.checkInteger(function2ToTest(5), "ValueWith5");
+ checker.checkInteger(functionToTest(4), "ValueWith4");
+ }
* \endcode
*
* If rootChecker() is never called, no comparison is done (i.e., missing
*
* The main use of this method is to assign meaning for missing
* reference data. Example use:
-\code
-if (checker.checkPresent(bHaveVelocities, "Velocities"))
-{
- // <check the velocities>
-}
-\endcode
+ * \code
+ if (checker.checkPresent(bHaveVelocities, "Velocities"))
+ {
+ // <check the velocities>
+ }
+ * \endcode
*/
bool checkPresent(bool bPresent, const char *id);
*
* Typical usage in test code:
* \code
-try
-{
- // some code that may throw a GromacsException
-}
-catch (const GromacsException &ex)
-{
- GMX_THROW_WRAPPER_TESTEXCEPTION(ex);
-}
+ try
+ {
+ // some code that may throw a GromacsException
+ }
+ catch (const GromacsException &ex)
+ {
+ GMX_THROW_WRAPPER_TESTEXCEPTION(ex);
+ }
* \endcode
*/
#define GMX_THROW_WRAPPER_TESTEXCEPTION(e) \