Improve (Selection|FileName)OptionManager handling
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 9 May 2014 04:40:21 +0000 (07:40 +0300)
committerDavid van der Spoel <davidvanderspoel@gmail.com>
Sat, 7 Jun 2014 13:33:00 +0000 (15:33 +0200)
commit1d6ad5df361f93ed933e33134b2dba9297c56e5c
tree589f5d6079dfbbdd2e209b930a8d7d8278d55ec1
parenteb9a45e5088458dadf5dd4dc47c7a38213788d11
Improve (Selection|FileName)OptionManager handling

The way the managers get passed to the option storage classes is now
reversed: the manager is passed already to the constructor.  This has
several benefits:
 - Already the constructor can use the manager if necessary.
 - It is possible to easily assert on all incorrect usage scenarios.
 - There is much less boilerplate code associated with propagating the
   manager into the storage classes.  There is also less code in
   general: even with an addition of a new file and its copyright
   header, as well as more extensive documentation, there are still
   fewer total lines with the new approach.

The minor disadvantage is that also option types that do not use a
manager get the container passed as an argument to createStorage(), but
they can just ignore the parameter, so the above benefits should clearly
outweigh this.

There was an outdated comment in options.h about the usage of
addSubSection(), which is fixed here.  It is now necessary to add
subsections before any options are added to them, but this is likely a
reasonable constraint for some other future stuff as well.

Change-Id: I4a5e69d3fd596dbe265613f81399219f8b8b19c8
26 files changed:
src/gromacs/commandline/pargs.cpp
src/gromacs/commandline/tests/cmdlinehelpwriter.cpp
src/gromacs/options/abstractoption.h
src/gromacs/options/basicoptions.cpp
src/gromacs/options/basicoptions.h
src/gromacs/options/filenameoption.cpp
src/gromacs/options/filenameoption.h
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/options/filenameoptionmanager.h
src/gromacs/options/filenameoptionstorage.h
src/gromacs/options/optionmanagercontainer.h [new file with mode: 0644]
src/gromacs/options/options-impl.h
src/gromacs/options/options.cpp
src/gromacs/options/options.h
src/gromacs/options/tests/abstractoptionstorage.cpp
src/gromacs/options/tests/filenameoption.cpp
src/gromacs/options/tests/optionsassigner.cpp
src/gromacs/selection/selectionfileoption.h
src/gromacs/selection/selectionfileoptionstorage.h
src/gromacs/selection/selectionoption.cpp
src/gromacs/selection/selectionoption.h
src/gromacs/selection/selectionoptionmanager.cpp
src/gromacs/selection/selectionoptionmanager.h
src/gromacs/selection/selectionoptionstorage.h
src/gromacs/selection/tests/selectionoption.cpp
src/gromacs/trajectoryanalysis/cmdlinerunner.cpp