Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Static Protected Member Functions
gmx::RepeatingOptionSectionHandle< T > Class Template Reference

#include <gromacs/options/repeatingsection.h>

+ Inheritance diagram for gmx::RepeatingOptionSectionHandle< T >:
+ Collaboration diagram for gmx::RepeatingOptionSectionHandle< T >:

Description

template<class T>
class gmx::RepeatingOptionSectionHandle< T >

Allows adding options to an RepeatingOptionSection.

An instance of this class is returned from IOptionsContainerWithSections::addSection(), and supports adding options and subsections to a section created with OptionSection.

Example:

struct SectionData { int value; }
// as class attribute
std::vector<SectionData> values;
void MyClass::initOptions(gmx::IOptionsContainerWithSections *options)
{
auto sec = options->addSection(gmx::RepeatingOptionSection<SectionData>("sec").storeVector(&values));
sec->addOption(gmx::IntegerOption("arg").store(&sec.bind().value));
}

Public Member Functions

 RepeatingOptionSectionHandle (internal::OptionSectionImpl *section)
 Wraps a given section storage object.
 
T & bind ()
 Supports storing option values within the per-section data structure. More...
 
IOptionsContaineraddGroup () override
 Creates a subgroup of options within the current options. More...
 
template<class SectionType >
SectionType::HandleType addSection (const SectionType &section)
 Adds a section to this collection. More...
 
template<class OptionType >
OptionType::InfoType * addOption (const OptionType &settings)
 Adds a recognized option. More...
 

Static Protected Member Functions

template<typename StorageType >
static StorageType * getStorage (internal::OptionSectionImpl *section)
 Returns the storage for a particular type of section. More...
 

Member Function Documentation

IOptionsContainer & gmx::AbstractOptionSectionHandle::addGroup ( )
overridevirtualinherited

Creates a subgroup of options within the current options.

To add options to the group, use the returned interface.

Currently, this is only used to influence the order of options: all options in a group appear before options in a group added after it, no matter in which order the options are added to the groups. In the future, the groups could also be used to influence the help output.

Implements gmx::IOptionsContainer.

template<class OptionType >
OptionType::InfoType* gmx::IOptionsContainer::addOption ( const OptionType &  settings)
inlineinherited

Adds a recognized option.

Template Parameters
OptionTypeType of the options description object.
Parameters
[in]settingsOption description.
Returns
OptionInfo object for the created option (never NULL).
Exceptions
APIErrorif invalid option settings are provided.

The return value is a pointer for more convenient use in callers: often callers need to declare the variable that will hold the return value in wider scope than would be achieved by declaring it at the site where addOption() is called. The returned pointer must not be freed.

See class documentation for example usage.

OptionType::InfoType must specify a type that derives from OptionInfo and matches the type that is returned by AbstractOptionStorage::optionInfo() for the storage object that corresponds to OptionType.

Examples:
template.cpp.
template<class SectionType >
SectionType::HandleType gmx::IOptionsContainerWithSections::addSection ( const SectionType &  section)
inlineinherited

Adds a section to this collection.

Template Parameters
SectionTypeType of the section description object.
Parameters
[in]sectionSection description.
Returns
AbstractOptionSectionHandle object for the created option.
Exceptions
APIErrorif invalid option settings are provided.

Options can be added to the section through the returned handle.

template<class T >
T& gmx::RepeatingOptionSectionHandle< T >::bind ( )
inline

Supports storing option values within the per-section data structure.

See class documentation for an example.

template<typename StorageType >
IOptionSectionStorage * gmx::AbstractOptionSectionHandle::getStorage ( internal::OptionSectionImpl *  section)
inlinestaticprotectedinherited

Returns the storage for a particular type of section.

This is intended for use in derived class constructors, where the handle needs access to the actual storage. The handle should know the type of storage created for the section type it deals with, so the cast should always be successful.


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