Gromacs  2025-dev-20241002-88a4191
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Friends
gmx::SelectionOptionManager Class Reference

#include <gromacs/selection/selectionoptionmanager.h>

+ Inheritance diagram for gmx::SelectionOptionManager:
+ Collaboration diagram for gmx::SelectionOptionManager:

Description

Handles interaction of selection options with other options and user input.

This class implements interaction of SelectionOption with SelectionCollection, and also implements features of SelectionOption that require actions outside options parsing. It also implements the coupling between SelectionOption and SelectionFileOption. It needs to be added using Options::addManager() before SelectionOption or SelectionFileOption options can be added to an Options collection.

The main features of this class are:

Classes

class  Impl
 Private implemention class for SelectionOptionManager. More...
 

Public Member Functions

 SelectionOptionManager (SelectionCollection *selections)
 Creates a manager for selection options. More...
 
void registerOption (SelectionOptionStorage *storage)
 Adds a selection option to be managed. More...
 
void convertOptionValue (SelectionOptionStorage *storage, const std::string &value, bool bFullValue)
 Converts a string value to selections for an option. More...
 
void requestOptionDelayedParsing (SelectionOptionStorage *storage)
 Adds a selection option for delayed user input. More...
 
bool hasRequestedSelections () const
 Returns whether there are requested selections that need input from parseRequestedFrom*().
 
void initOptions (IOptionsContainer *options)
 Initializes options for setting global selection properties. More...
 
void parseRequestedFromStdin (bool bInteractive)
 Parses selection(s) from standard input for options not yet provided. More...
 
void parseRequestedFromFile (const std::string &filename)
 Parses selection(s) from a file for options not yet provided. More...
 
void parseRequestedFromString (const std::string &str)
 Parses selection(s) from a string for options not yet provided. More...
 

Friends

class SelectionOptionStorage
 Needed for handling delayed selection parsing requests.
 

Constructor & Destructor Documentation

gmx::SelectionOptionManager::SelectionOptionManager ( SelectionCollection selections)
explicit

Creates a manager for selection options.

Exceptions
std::bad_allocif out of memory.

Member Function Documentation

void gmx::SelectionOptionManager::convertOptionValue ( SelectionOptionStorage storage,
const std::string &  value,
bool  bFullValue 
)

Converts a string value to selections for an option.

Parameters
storageStorage object to receive the selections.
[in]valueValue to convert.
[in]bFullValueIf true, the provided selections are the full value of the option, and additional checks are performed.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif the selection string is not valid, or uses a feature not supported by the option.

This is only for internal use by the selection module. It is not possible to obtain a SelectionOptionStorage pointer through any public or library API.

void gmx::SelectionOptionManager::initOptions ( IOptionsContainer options)

Initializes options for setting global selection properties.

Parameters
[in,out]optionsOptions object to initialize.
Exceptions
std::bad_allocif out of memory.
See Also
SelectionCollection::initOptions()
void gmx::SelectionOptionManager::parseRequestedFromFile ( const std::string &  filename)

Parses selection(s) from a file for options not yet provided.

Parameters
[in]filenameName of the file to parse selections from.
Exceptions
unspecifiedCan throw any exception thrown by SelectionCollection::parseFromFile().
std::bad_allocif out of memory.
InvalidInputErrorif
  • the number of selections in filename doesn't match the number requested.
  • any selection uses a feature that is not allowed for the corresponding option.
  • if there is a request for any number of selections that is not the last (in which case it is not possible to determine which selections belong to which request).

This method behaves as parseRequestedFromStdin(), with two exceptions:

  1. It reads the selections from a file instead of standard input.
  2. If no requests are pending, assigns values to all required options that have not yet been set.

This method used to implement SelectionFileOption.

See Also
parseRequestedFromStdin()
void gmx::SelectionOptionManager::parseRequestedFromStdin ( bool  bInteractive)

Parses selection(s) from standard input for options not yet provided.

Parameters
[in]bInteractiveWhether the parser should behave interactively.
Exceptions
unspecifiedCan throw any exception thrown by SelectionCollection::parseFromStdin().
std::bad_allocif out of memory.

This method cooperates with SelectionOption to allow interactive input of requested selections after all options have been processed. It should be called after the Options::finish() method has been called on all options that add selections to this collection. For each required selection option that has not been given, as well as for optional selection options that have been specified without values, it will prompt the user to input the necessary selections.

void gmx::SelectionOptionManager::parseRequestedFromString ( const std::string &  str)

Parses selection(s) from a string for options not yet provided.

Parameters
[in]strString to parse.
Exceptions
unspecifiedCan throw any exception thrown by SelectionCollection::parseFromString().
std::bad_allocif out of memory.
InvalidInputErrorin same conditions as parseRequestedFromFile().

This method behaves as parseRequestedFromFile(), but reads the selections from a string instead of a file. This method is mainly used for testing.

See Also
parseRequestedFromFile()
void gmx::SelectionOptionManager::registerOption ( SelectionOptionStorage storage)

Adds a selection option to be managed.

Parameters
storageStorage object for the option to register.
Exceptions
std::bad_allocif out of memory.

This is only for internal use by the selection module. It is not possible to obtain a SelectionOptionStorage pointer through any public or library API.

Strong exception safety.

void gmx::SelectionOptionManager::requestOptionDelayedParsing ( SelectionOptionStorage storage)

Adds a selection option for delayed user input.

Parameters
storageStorage object for the option to request.
Exceptions
std::bad_allocif out of memory.

This is only for internal use by the selection module. It is not possible to obtain a SelectionOptionStorage pointer through any public or library API.

Strong exception safety.


The documentation for this class was generated from the following files: