source: src/Actions/MapOfActions.cpp@ df32ee

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 Candidate_v1.7.0 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since df32ee was bd2390, checked in by Frederik Heber <heber@…>, 15 years ago

BUGFIX: new boost::filesystem led to non-parsing of files.

  • BUGFIX: MapOfActions::TypeMap is not only important for set/queryCurrentValue but also for CommandLineParser.
    • CommandLineDialog::FileCommandLineQuery::handle() expects boost::filesystem::path
    • new validate for boost::filesystem::path
    • AddOptionsToParser was missing case for enum File
    • no enum File in TypeEnumMap
  • BUGFIX: InputAction
    • now setting prefix for all parsers even if filename nor present
    • now always setting name of last inserted molecule in World::getInstance().getMolecules()
    • not returning Action::failure when not present, only when not has_filename()
  • BUGFIX: PdbParser and TremoloParser were not inserting, but only creating a new molecule
  • BUGFIX: TremoloParser::load() nad no ASSET(false) as it's not implemented.
  • BUGFIX: as molId of 0 may occur, PdbParser::save() prints -1 for homeless atoms now
  • TESTFIX: Simple_configuration/2/test.pdb has molnr of 0 instead of former 1 (see above)
  • Property mode set to 100644
File size: 56.9 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[97ebf8]8/*
9 * MapOfActions.cpp
10 *
11 * Created on: 10.05.2010
12 * Author: heber
13 */
14
[bf3817]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[112b09]20#include "Helpers/MemDebug.hpp"
21
[97ebf8]22using namespace std;
23
24#include "Actions/MapOfActions.hpp"
[d02e07]25#include "Descriptors/AtomIdDescriptor.hpp"
26#include "Descriptors/MoleculeIdDescriptor.hpp"
[97ebf8]27#include "Helpers/Assert.hpp"
[4e145c]28#include "Patterns/Singleton_impl.hpp"
[97ebf8]29
[0286bc]30#include <boost/lexical_cast.hpp>
31#include <boost/optional.hpp>
32#include <boost/program_options.hpp>
[6f5dfe]33#include <boost/filesystem.hpp>
[0286bc]34
[986ed3]35#include <iostream>
36
[ab9a27]37#include "atom.hpp"
[d02e07]38#include "Box.hpp"
[97ebf8]39#include "CommandLineParser.hpp"
[ab9a27]40#include "element.hpp"
[952f38]41#include "Helpers/Log.hpp"
[57f243]42#include "LinearAlgebra/Matrix.hpp"
[ab9a27]43#include "molecule.hpp"
[d02e07]44#include "periodentafel.hpp"
[72f611]45#include "LinearAlgebra/BoxVector.hpp"
[57f243]46#include "LinearAlgebra/Vector.hpp"
[952f38]47#include "Helpers/Verbose.hpp"
[97ebf8]48
[326bbe]49#include "Actions/ActionRegistry.hpp"
50#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
51#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
[d02e07]52#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
[326bbe]53#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
[d02e07]54#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
[326bbe]55#include "Actions/AtomAction/AddAction.hpp"
56#include "Actions/AtomAction/ChangeElementAction.hpp"
57#include "Actions/AtomAction/RemoveAction.hpp"
[22c44bf]58#include "Actions/AtomAction/RotateAroundOriginByAngleAction.hpp"
[34c338]59#include "Actions/AtomAction/TranslateAction.hpp"
[53d01c]60#include "Actions/CommandAction/BondLengthTableAction.hpp"
61#include "Actions/CommandAction/ElementDbAction.hpp"
62#include "Actions/CommandAction/FastParsingAction.hpp"
63#include "Actions/CommandAction/HelpAction.hpp"
64#include "Actions/CommandAction/VerboseAction.hpp"
65#include "Actions/CommandAction/VersionAction.hpp"
[7230be]66#include "Actions/CommandAction/WarrantyAction.hpp"
[1a7fd2]67#include "Actions/FragmentationAction/ConstructBondGraphAction.hpp"
[326bbe]68#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
69#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
70#include "Actions/FragmentationAction/FragmentationAction.hpp"
71#include "Actions/MoleculeAction/BondFileAction.hpp"
72#include "Actions/MoleculeAction/ChangeNameAction.hpp"
[1a7fd2]73#include "Actions/MoleculeAction/CopyAction.hpp"
[326bbe]74#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
[eee966]75#include "Actions/MoleculeAction/FillVoidWithMoleculeAction.hpp"
[326bbe]76#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
[eaf4ae]77#include "Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp"
[b2531f]78#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
[326bbe]79#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
80#include "Actions/MoleculeAction/SaveBondsAction.hpp"
81#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
[b2531f]82#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
[326bbe]83#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
84#include "Actions/ParserAction/LoadXyzAction.hpp"
85#include "Actions/ParserAction/SaveXyzAction.hpp"
[e472eab]86#include "Actions/SelectionAction/AllAtomsAction.hpp"
[1cc87e]87#include "Actions/SelectionAction/AllAtomsInsideCuboidAction.hpp"
88#include "Actions/SelectionAction/AllAtomsInsideSphereAction.hpp"
[770287]89#include "Actions/SelectionAction/AllAtomsOfMoleculeAction.hpp"
[e472eab]90#include "Actions/SelectionAction/AllMoleculesAction.hpp"
[51769f]91#include "Actions/SelectionAction/AtomByElementAction.hpp"
[533838]92#include "Actions/SelectionAction/AtomByIdAction.hpp"
[e212ff]93#include "Actions/SelectionAction/ClearAllAtomsAction.hpp"
[2218d94]94#include "Actions/SelectionAction/ClearAllMoleculesAction.hpp"
[51769f]95#include "Actions/SelectionAction/MoleculeByFormulaAction.hpp"
[533838]96#include "Actions/SelectionAction/MoleculeByIdAction.hpp"
[481e92]97#include "Actions/SelectionAction/MoleculeOfAtomAction.hpp"
[e472eab]98#include "Actions/SelectionAction/NotAllAtomsAction.hpp"
[1cc87e]99#include "Actions/SelectionAction/NotAllAtomsInsideCuboidAction.hpp"
100#include "Actions/SelectionAction/NotAllAtomsInsideSphereAction.hpp"
[381c5f]101#include "Actions/SelectionAction/NotAllAtomsOfMoleculeAction.hpp"
[e472eab]102#include "Actions/SelectionAction/NotAllMoleculesAction.hpp"
[51769f]103#include "Actions/SelectionAction/NotAtomByElementAction.hpp"
[533838]104#include "Actions/SelectionAction/NotAtomByIdAction.hpp"
[51769f]105#include "Actions/SelectionAction/NotMoleculeByFormulaAction.hpp"
[533838]106#include "Actions/SelectionAction/NotMoleculeByIdAction.hpp"
[75a80f]107#include "Actions/SelectionAction/NotMoleculeOfAtomAction.hpp"
[326bbe]108#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
109#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
110#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
111#include "Actions/WorldAction/BoundInBoxAction.hpp"
112#include "Actions/WorldAction/CenterInBoxAction.hpp"
113#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
114#include "Actions/WorldAction/ChangeBoxAction.hpp"
115#include "Actions/WorldAction/InputAction.hpp"
116#include "Actions/WorldAction/OutputAction.hpp"
117#include "Actions/WorldAction/RepeatBoxAction.hpp"
118#include "Actions/WorldAction/ScaleBoxAction.hpp"
119#include "Actions/WorldAction/SetDefaultNameAction.hpp"
120#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
[b9c847]121#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
[0286bc]122#include "Actions/Values.hpp"
123
124void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
125{
126 VectorValue VV;
[b540f3]127 std::vector<std::string> components;
128
129 // split comma-separated values
130 if (values.size() != 1) {
131 cerr << "Not one vector but " << components.size() << " given " << endl;
132 throw boost::program_options::validation_error("Unequal to one vector given");
133 }
134 std::string argument(values.at(0));
135 std::string::iterator Aiter = argument.begin();
136 std::string::iterator Biter = argument.begin();
137 for (; Aiter != argument.end(); ++Aiter) {
138 if (*Aiter == ',') {
139 components.push_back(string(Biter,Aiter));
140 do {
141 Aiter++;
142 } while (*Aiter == ' ' || *Aiter == '\t');
143 Biter = Aiter;
144 }
145 }
146 components.push_back(string(Biter,argument.end()));
147
148 if (components.size() != 3) {
149 cerr << "Specified vector does not have three components but " << components.size() << endl;
[0286bc]150 throw boost::program_options::validation_error("Specified vector does not have three components");
151 }
[b540f3]152 VV.x = boost::lexical_cast<double>(components.at(0));
153 VV.y = boost::lexical_cast<double>(components.at(1));
154 VV.z = boost::lexical_cast<double>(components.at(2));
[0286bc]155 v = boost::any(VectorValue(VV));
156}
157
158void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
159{
160 BoxValue BV;
[b540f3]161 std::vector<std::string> components;
162
163 // split comma-separated values
164 if (values.size() != 1) {
165 cerr << "Not one vector but " << components.size() << " given " << endl;
166 throw boost::program_options::validation_error("Unequal to one vector given");
167 }
168 std::string argument(values.at(0));
169 std::string::iterator Aiter = argument.begin();
170 std::string::iterator Biter = argument.begin();
171 for (; Aiter != argument.end(); ++Aiter) {
172 if (*Aiter == ',') {
173 components.push_back(string(Biter,Aiter));
174 do {
175 Aiter++;
176 } while (*Aiter == ' ' || *Aiter == '\t');
177 Biter = Aiter;
178 }
179 }
180 components.push_back(string(Biter,argument.end()));
181
182 if (components.size() != 6) {
183 cerr << "Specified vector does not have three components but " << components.size() << endl;
[0286bc]184 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
185 }
[b540f3]186 BV.xx = boost::lexical_cast<double>(components.at(0));
[8467df]187 BV.yx = boost::lexical_cast<double>(components.at(1));
188 BV.yy = boost::lexical_cast<double>(components.at(2));
189 BV.zx = boost::lexical_cast<double>(components.at(3));
190 BV.zy = boost::lexical_cast<double>(components.at(4));
[b540f3]191 BV.zz = boost::lexical_cast<double>(components.at(5));
[0286bc]192 v = boost::any(BoxValue(BV));
193}
194
[bd2390]195void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int)
196{
197 boost::filesystem::path filename;
198 std::vector<std::string> components;
199
200 std::cout << "boost::filesystem::path validator used." << std::endl;
201
202 // split comma-separated values
203 if (values.size() != 1) {
204 cerr << "Not one file but " << components.size() << " given " << endl;
205 throw boost::program_options::validation_error("Unequal to one file given");
206 }
207 filename = values.at(0);
208 v = boost::any(boost::filesystem::path(filename));
209}
210
[97ebf8]211/** Constructor of class MapOfActions.
212 *
213 */
214MapOfActions::MapOfActions()
215{
216 // initialise lookup map
217 CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
218 CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
219 CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
220 CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
221
222 // keys for actions
223 DescriptionMap["add-atom"] = "add atom of specified element";
224 DescriptionMap["bond-table"] = "setting name of the bond length table file";
225 DescriptionMap["bond-file"] = "name of the bond file";
226 DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
227 DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
228 DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
229 DescriptionMap["center-in-box"] = "center all atoms in the domain";
230 DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
231 DescriptionMap["change-element"] = "change the element of an atom";
232 DescriptionMap["change-molname"] = "change the name of a molecule";
[e212ff]233 DescriptionMap["clear-atom-selection"] = "clear the atom selection";
[2218d94]234 DescriptionMap["clear-molecule-selection"] = "clear the molecule selection";
[c449d9]235 DescriptionMap["construct-bondgraph"] = "construct the bond graph of the selected atoms";
[97ebf8]236 DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
[1a7fd2]237 DescriptionMap["copy-molecule"] = "copies a molecule with all atoms and bonds";
[97ebf8]238 DescriptionMap["default-molname"] = "set the default name of new molecules";
239 DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
240 DescriptionMap["element-db"] = "setting the path where the element databases can be found";
241 DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
[eee966]242 DescriptionMap["fill-molecule"] = "fill around molecules' surface with a filler molecule";
243 DescriptionMap["fill-void"] = "fill void space of box with a filler molecule";
[97ebf8]244 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
[7230be]245 DescriptionMap["help"] = "help screen";
[4f7f34e]246 DescriptionMap["input"] = "specify input files";
[97ebf8]247 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
248 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
[b9c847]249 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
250 DescriptionMap["output"] = "write output files";
251 DescriptionMap["set-output"] = "specify output formats";
[e65de8]252 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
[97ebf8]253 DescriptionMap["parse-xyz"] = "parse xyz file into World";
[e65de8]254 DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
[97ebf8]255 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
[446bc1]256 DescriptionMap["redo"] = "redo last action";
[97ebf8]257 DescriptionMap["remove-atom"] = "remove a specified atom";
258 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
[22c44bf]259 DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
[eaf4ae]260 DescriptionMap["rotate-self"] = "rotates molecules by a specific angle around own center of gravity";
[97ebf8]261 DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
262 DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
263 DescriptionMap["save-bonds"] = "name of the bonds file to write to";
264 DescriptionMap["save-temperature"] = "name of the temperature file to write to";
[326bbe]265 DescriptionMap["SaveXyz"] = "save world as xyz file";
[2a92ff]266 DescriptionMap["scale-box"] = "scale box and atomic positions inside";
[4e4c4d]267 DescriptionMap["select-all-atoms"] = "select all atoms";
268 DescriptionMap["select-all-molecules"] = "select all molecules";
[51769f]269 DescriptionMap["select-atom-by-element"] = "select an atom by element";
[4e4c4d]270 DescriptionMap["select-atom-by-id"] = "select an atom by index";
[1cc87e]271 DescriptionMap["select-atoms-inside-cuboid"] = "select all atoms inside a cuboid";
272 DescriptionMap["select-atoms-inside-sphere"] = "select all atoms inside a sphere";
[4e4c4d]273 DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
[51769f]274 DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula";
[481e92]275 DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
[770287]276 DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
[b9c847]277 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
278 DescriptionMap["set-output"] = "specify output formats";
[6866aa]279 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
[e65de8]280 DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
[97ebf8]281 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
[34c338]282 DescriptionMap["translate-atoms"] = "translate all selected atoms by given vector";
[446bc1]283 DescriptionMap["undo"] = "undo last action";
[4e4c4d]284 DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
285 DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
[51769f]286 DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element";
[4e4c4d]287 DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
[1cc87e]288 DescriptionMap["unselect-atoms-inside-cuboid"] = "unselect all atoms inside a cuboid";
289 DescriptionMap["unselect-atoms-inside-sphere"] = "unselect all atoms inside a sphere";
[51769f]290 DescriptionMap["unselect-molecule-by-formula"] = "unselect a molecule by chemical formula";
[4e4c4d]291 DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
[75a80f]292 DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
[381c5f]293 DescriptionMap["unselect-molecules-atoms"] = "unselect all atoms of a molecule";
[97ebf8]294 DescriptionMap["verbose"] = "set verbosity level";
295 DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
296 DescriptionMap["version"] = "show version";
[7230be]297 DescriptionMap["warranty"] = "statement concerning warranty of the software";
[97ebf8]298 // keys for values
[31fb1d]299 DescriptionMap["angle-x"] = "angle of a rotation around x axis";
300 DescriptionMap["angle-y"] = "angle of a rotation around y axis";
301 DescriptionMap["angle-z"] = "angle of a rotation around z axis";
[97ebf8]302 DescriptionMap["bin-output-file"] = "name of the bin output file";
303 DescriptionMap["bin-end"] = "start of the last bin";
304 DescriptionMap["bin-start"] = "start of the first bin";
305 DescriptionMap["bin-width"] = "width of the bins";
[f6bd32]306 DescriptionMap["convex-file"] = "filename of the non-convex envelope";
[97ebf8]307 DescriptionMap["distance"] = "distance in space";
308 DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
[0286bc]309 DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
[58bbd3]310 DescriptionMap["element"] = "single element";
311 DescriptionMap["elements"] = "set of elements";
[a02462]312 DescriptionMap["end-step"] = "last or end step";
313 DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used";
[97ebf8]314 DescriptionMap["input"] = "name of input file";
315 DescriptionMap["length"] = "length in space";
316 DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
317 DescriptionMap["MaxDistance"] = "maximum distance in space";
318 DescriptionMap["molecule-by-id"] = "index of a molecule";
[f6bd32]319 DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
[e4b5de]320 DescriptionMap["order"] = "order of a discretization, dissection, ...";
[97ebf8]321 DescriptionMap["output-file"] = "name of the output file";
322 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
323 DescriptionMap["position"] = "position in R^3 space";
[a02462]324 DescriptionMap["start-step"] = "first or start step";
[97ebf8]325
326 // short forms for the actions
327 ShortFormMap["add-atom"] = "a";
328 ShortFormMap["bond-table"] = "g";
329 ShortFormMap["bond-file"] = "A";
330 ShortFormMap["boundary"] = "c";
[6ca1f7]331 ShortFormMap["change-box"] = "B";
[97ebf8]332 ShortFormMap["center-edge"] = "O";
333 ShortFormMap["center-in-box"] = "b";
334 ShortFormMap["change-element"] = "E";
[b9c847]335// ShortFormMap["convex-envelope"] = "x";
[97ebf8]336 ShortFormMap["default-molname"] = "X";
337 ShortFormMap["depth-first-search"] = "D";
338 ShortFormMap["element-db"] = "e";
339 ShortFormMap["fastparsing"] = "n";
340 ShortFormMap["fill-molecule"] = "F";
341 ShortFormMap["fragment-mol"] = "f";
342 ShortFormMap["help"] = "h";
343 ShortFormMap["input"] = "i";
344 ShortFormMap["linear-interpolate"] = "L";
345 ShortFormMap["nonconvex-envelope"] = "N";
[cd8e55]346// ShortFormMap["output"] = "o";
[e65de8]347// ShortFormMap["pair-correlation"] = "C";
[97ebf8]348 ShortFormMap["parse-xyz"] = "p";
349 ShortFormMap["remove-atom"] = "r";
350 ShortFormMap["repeat-box"] = "d";
351 ShortFormMap["rotate-to-pas"] = "m";
352 ShortFormMap["save-adjacency"] = "J";
353 ShortFormMap["save-bonds"] = "j";
354 ShortFormMap["save-temperature"] = "S";
355 ShortFormMap["scale-box"] = "s";
356 ShortFormMap["set-basis"] = "M";
[b9c847]357 ShortFormMap["set-output"] = "o";
[6866aa]358 ShortFormMap["subgraph-dissect"] = "I";
[48ab70a]359 ShortFormMap["suspend-in-water"] = "u";
[34c338]360 ShortFormMap["translate-atoms"] = "t";
[6670a97]361 ShortFormMap["verbose"] = "v";
[97ebf8]362 ShortFormMap["verlet-integrate"] = "P";
[6670a97]363 ShortFormMap["version"] = "V";
[97ebf8]364
365 // value types for the actions
[e5c0a1]366 TypeMap["add-atom"] = &typeid(const element);
[ab9a27]367 TypeMap["bond-file"] = &typeid(std::string);
368 TypeMap["bond-table"] = &typeid(std::string);
369 TypeMap["boundary"] = &typeid(VectorValue);
370 TypeMap["center-in-box"] = &typeid(BoxValue);
371 TypeMap["change-box"] = &typeid(BoxValue);
[e5c0a1]372 TypeMap["change-element"] = &typeid(const element);
[ab9a27]373 TypeMap["change-molname"] = &typeid(std::string);
[e212ff]374 TypeMap["clear-atom-selection"] = &typeid(void);
[2218d94]375 TypeMap["clear-molecule-selection"] = &typeid(void);
[c449d9]376 TypeMap["construct-bondgraph"] = &typeid(void);
[1d9b7d2]377 TypeMap["convex-envelope"] = &typeid(void);
[1a7fd2]378 TypeMap["copy-molecule"] = &typeid(molecule);
[ab9a27]379 TypeMap["default-molname"] = &typeid(std::string);
380 TypeMap["depth-first-search"] = &typeid(double);
381 TypeMap["element-db"] = &typeid(std::string);
382 TypeMap["fastparsing"] = &typeid(bool);
383 TypeMap["fill-molecule"] = &typeid(std::string);
[eee966]384 TypeMap["fill-void"] = &typeid(std::string);
[ab9a27]385 TypeMap["fragment-mol"] = &typeid(std::string);
[6f5dfe]386 TypeMap["input"] = &typeid(boost::filesystem::path);
[ab9a27]387 TypeMap["linear-interpolate"] = &typeid(std::string);
388 TypeMap["molecular-volume"] = &typeid(molecule);
[1d9b7d2]389 TypeMap["nonconvex-envelope"] = &typeid(double);
[ab9a27]390 TypeMap["output"] = &typeid(void);
391 TypeMap["parse-xyz"] = &typeid(std::string);
[e65de8]392 TypeMap["pair-correlation"] = &typeid(void);
393 TypeMap["point-correlation"] = &typeid(void);
[b76394]394 TypeMap["principal-axis-system"] = &typeid(void);
[446bc1]395 TypeMap["redo"] = &typeid(void);
[120088]396 TypeMap["remove-atom"] = &typeid(void);
[ab9a27]397 TypeMap["repeat-box"] = &typeid(VectorValue);
[eaf4ae]398 TypeMap["rotate-origin"] = &typeid(double);
399 TypeMap["rotate-self"] = &typeid(double);
400 TypeMap["rotate-to-pas"] = &typeid(VectorValue);
[ab9a27]401 TypeMap["save-adjacency"] = &typeid(std::string);
402 TypeMap["save-bonds"] = &typeid(std::string);
403 TypeMap["save-temperature"] = &typeid(std::string);
404 TypeMap["scale-box"] = &typeid(VectorValue);
[770287]405 TypeMap["select-all-atoms"] = &typeid(void);
406 TypeMap["select-all-molecules"] = &typeid(void);
[51769f]407 TypeMap["select-atom-by-element"] = &typeid(const element);
[770287]408 TypeMap["select-atom-by-id"] = &typeid(atom);
[1cc87e]409 TypeMap["select-atoms-inside-cuboid"] = &typeid(VectorValue);
410 TypeMap["select-atoms-inside-sphere"] = &typeid(double);
[51769f]411 TypeMap["select-molecule-by-formula"] = &typeid(std::string);
[770287]412 TypeMap["select-molecule-by-id"] = &typeid(molecule);
[481e92]413 TypeMap["select-molecule-of-atom"] = &typeid(atom);
[770287]414 TypeMap["select-molecules-atoms"] = &typeid(molecule);
[ab9a27]415 TypeMap["set-basis"] = &typeid(std::string);
416 TypeMap["set-output"] = &typeid(std::vector<std::string>);
417 TypeMap["subgraph-dissect"] = &typeid(void);
[e65de8]418 TypeMap["surface-correlation"] = &typeid(void);
[ab9a27]419 TypeMap["suspend-in-water"] = &typeid(double);
[34c338]420 TypeMap["translate-atoms"] = &typeid(VectorValue);
[446bc1]421 TypeMap["undo"] = &typeid(void);
[770287]422 TypeMap["unselect-all-atoms"] = &typeid(void);
423 TypeMap["unselect-all-molecules"] = &typeid(void);
[51769f]424 TypeMap["unselect-atom-by-element"] = &typeid(const element);
[770287]425 TypeMap["unselect-atom-by-id"] = &typeid(atom);
[1cc87e]426 TypeMap["unselect-atoms-inside-cuboid"] = &typeid(VectorValue);
427 TypeMap["unselect-atoms-inside-sphere"] = &typeid(double);
[51769f]428 TypeMap["unselect-molecule-by-formula"] = &typeid(std::string);
[770287]429 TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
[75a80f]430 TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
[381c5f]431 TypeMap["unselect-molecules-atoms"] = &typeid(molecule);
[ab9a27]432 TypeMap["verlet-integrate"] = &typeid(std::string);
433 TypeMap["verbose"] = &typeid(int);
[e30ce8]434
[97ebf8]435 // value types for the values
[31fb1d]436 TypeMap["angle-x"] = &typeid(double);
437 TypeMap["angle-y"] = &typeid(double);
438 TypeMap["angle-z"] = &typeid(double);
[ab9a27]439 TypeMap["bin-output-file"] = &typeid(std::string);
440 TypeMap["bin-end"] = &typeid(double);
441 TypeMap["bin-start"] = &typeid(double);
442 TypeMap["bin-width"] = &typeid(double);
443 TypeMap["convex-file"] = &typeid(std::string);
444 TypeMap["distance"] = &typeid(double);
445 TypeMap["distances"] = &typeid(VectorValue);
446 TypeMap["DoRotate"] = &typeid(bool);
[e5c0a1]447 TypeMap["element"] = &typeid(const element);
448 TypeMap["elements"] = &typeid(std::vector<const element *>);
[ab9a27]449 TypeMap["end-step"] = &typeid(int);
450 TypeMap["id-mapping"] = &typeid(bool);
451 TypeMap["length"] = &typeid(double);
452 TypeMap["lengths"] = &typeid(VectorValue);
453 TypeMap["MaxDistance"] = &typeid(double);
[e65de8]454 TypeMap["molecule-by-id"] = &typeid(molecule);
[ab9a27]455 TypeMap["nonconvex-file"] = &typeid(std::string);
456 TypeMap["order"] = &typeid(int);
457 TypeMap["output-file"] = &typeid(std::string);
458 TypeMap["periodic"] = &typeid(bool);
459 TypeMap["position"] = &typeid(VectorValue);
460 TypeMap["start-step"] = &typeid(int);
461
[0b0a20]462 TypeEnumMap[&typeid(void)] = None;
463 TypeEnumMap[&typeid(bool)] = Boolean;
[ab9a27]464 TypeEnumMap[&typeid(int)] = Integer;
[bd2390]465 TypeEnumMap[&typeid(boost::filesystem::path)] = File;
[0b0a20]466 TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
[ab9a27]467 TypeEnumMap[&typeid(double)] = Double;
[0b0a20]468 TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
[ab9a27]469 TypeEnumMap[&typeid(std::string)] = String;
[0b0a20]470 TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
471 TypeEnumMap[&typeid(VectorValue)] = Vector;
[39b639]472 TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
[0b0a20]473 TypeEnumMap[&typeid(BoxValue)] = Box;
474 TypeEnumMap[&typeid(molecule)] = Molecule;
475 TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
[ab9a27]476 TypeEnumMap[&typeid(atom)] = Atom;
[0b0a20]477 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
[e5c0a1]478 TypeEnumMap[&typeid(const element)] = Element;
479 TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
[97ebf8]480
[e30ce8]481 // default values for any action that needs one (always string!)
[ab9a27]482 CurrentValue["bin-width"] = "0.5";
483 CurrentValue["fastparsing"] = "0";
484 CurrentValue["periodic"] = "0";
[e30ce8]485
[326bbe]486 // put action into each menu category
[b2531f]487 MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
[5b5c4d]488 MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
489 MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
[b2531f]490 MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
[5b5c4d]491 MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
492 MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
493 MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
494 MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
495 MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
[b2531f]496
[326bbe]497 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
498 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
[e65de8]499 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
500 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
[326bbe]501 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
[e30ce8]502
[326bbe]503 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
504 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
505 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
[34c338]506 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "translate-atoms") );
[326bbe]507
508 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
509 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
510 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
[7230be]511 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "help") );
[326bbe]512 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
513 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
[7230be]514 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "warranty") );
[326bbe]515
[c449d9]516 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "construct-bondgraph") );
[326bbe]517 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
518 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
519 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
520
521 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
[1a7fd2]522 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "copy-molecule") );
[326bbe]523 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
524 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
[eee966]525 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-void") );
[326bbe]526 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
[eaf4ae]527 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-origin") );
528 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-self") );
[326bbe]529 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
530 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
531 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
532 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
533 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
534 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
535
536 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
537 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
538
[e212ff]539 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-atom-selection") );
[2218d94]540 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-molecule-selection") );
[e212ff]541 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
542 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
[51769f]543 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") );
[5b5c4d]544 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
[1cc87e]545 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-cuboid") );
546 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-sphere") );
[5b5c4d]547 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
[51769f]548 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-formula") );
[481e92]549 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
[770287]550 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
[e212ff]551 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
552 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
[51769f]553 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") );
[5b5c4d]554 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
[1cc87e]555 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-cuboid") );
556 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-sphere") );
[51769f]557 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-formula") );
[5b5c4d]558 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
[75a80f]559 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
[381c5f]560 MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecules-atoms") );
[5b5c4d]561
[326bbe]562 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
563 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
564
565 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
566 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
567 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
568 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
569 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
570 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
571 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
572 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
573 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
574 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
575 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
[b9c847]576 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
[326bbe]577
578 // put actions into command line category
[f0a3ec]579 generic.insert("add-atom");
[f4bd01]580 generic.insert("bond-file");
[39af9f]581 generic.insert("bond-table");
[116f37]582 generic.insert("boundary");
[97ebf8]583// generic.insert("bound-in-box");
[584a2a]584 generic.insert("center-edge");
[158c594]585 generic.insert("center-in-box");
[6ca1f7]586 generic.insert("change-box");
[97ebf8]587// generic.insert("change-molname");
[e212ff]588 generic.insert("change-element");
589 generic.insert("clear-atom-selection");
[2218d94]590 generic.insert("clear-molecule-selection");
[c449d9]591 generic.insert("construct-bondgraph");
[f6bd32]592 generic.insert("convex-envelope");
[1a7fd2]593 generic.insert("copy-molecule");
[387b36]594 generic.insert("default-molname");
[8540f0]595 generic.insert("depth-first-search");
[198494]596 generic.insert("element-db");
[f821d6]597 generic.insert("fastparsing");
[0286bc]598 generic.insert("fill-molecule");
[eee966]599 generic.insert("fill-void");
[e4b5de]600 generic.insert("fragment-mol");
[97ebf8]601 generic.insert("help");
[4f7f34e]602 generic.insert("input");
603 generic.insert("linear-interpolate");
[97ebf8]604// generic.insert("molecular-volume");
[980dd6]605 generic.insert("nonconvex-envelope");
[4f7f34e]606 generic.insert("output");
[58bbd3]607 generic.insert("pair-correlation");
[a1e929]608 generic.insert("parse-xyz");
[e65de8]609 generic.insert("point-correlation");
[97ebf8]610// generic.insert("principal-axis-system");
[446bc1]611 generic.insert("redo");
[d55743e]612 generic.insert("remove-atom");
[0286bc]613 generic.insert("repeat-box");
[eaf4ae]614 generic.insert("rotate-origin");
615 generic.insert("rotate-self");
[2b5574]616 generic.insert("rotate-to-pas");
[77de81]617 generic.insert("save-adjacency");
618 generic.insert("save-bonds");
[a307af]619 generic.insert("save-temperature");
[2a92ff]620 generic.insert("scale-box");
[e472eab]621 generic.insert("select-all-atoms");
622 generic.insert("select-all-molecules");
[51769f]623 generic.insert("select-atom-by-element");
[e472eab]624 generic.insert("select-atom-by-id");
[1cc87e]625 generic.insert("select-atoms-inside-cuboid");
626 generic.insert("select-atoms-inside-sphere");
[e472eab]627 generic.insert("select-molecule-by-id");
[51769f]628 generic.insert("select-molecule-by-formula");
[481e92]629 generic.insert("select-molecule-of-atom");
[770287]630 generic.insert("select-molecules-atoms");
[bdaacd]631 generic.insert("set-basis");
[b9c847]632 generic.insert("set-output");
[6866aa]633 generic.insert("subgraph-dissect");
[e65de8]634 generic.insert("surface-correlation");
[48ab70a]635 generic.insert("suspend-in-water");
[34c338]636 generic.insert("translate-atoms");
[446bc1]637 generic.insert("undo");
[e472eab]638 generic.insert("unselect-all-atoms");
639 generic.insert("unselect-all-molecules");
[51769f]640 generic.insert("unselect-atom-by-element");
[e472eab]641 generic.insert("unselect-atom-by-id");
[1cc87e]642 generic.insert("unselect-atoms-inside-cuboid");
643 generic.insert("unselect-atoms-inside-sphere");
[51769f]644 generic.insert("unselect-molecule-by-formula");
[e472eab]645 generic.insert("unselect-molecule-by-id");
[75a80f]646 generic.insert("unselect-molecule-of-atom");
[381c5f]647 generic.insert("unselect-molecules-atoms");
[97ebf8]648 generic.insert("verbose");
[aacce8]649 generic.insert("verlet-integrate");
[97ebf8]650 generic.insert("version");
[7230be]651 generic.insert("warranty");
[97ebf8]652
653 // positional arguments
[f6bd32]654 generic.insert("input");
[0286bc]655
656 // hidden arguments
[31fb1d]657 hidden.insert("angle-x");
658 hidden.insert("angle-y");
659 hidden.insert("angle-z");
[533838]660 hidden.insert("bin-end");
661 hidden.insert("bin-output-file");
662 hidden.insert("bin-start");
663 hidden.insert("bin-width");
664 hidden.insert("convex-file");
665 hidden.insert("distance");
666 hidden.insert("DoRotate");
667 hidden.insert("distances");
668 hidden.insert("element");
669 hidden.insert("elements");
670 hidden.insert("end-step");
671 hidden.insert("id-mapping");
672 hidden.insert("lengths");
673 hidden.insert("MaxDistance");
[e65de8]674 hidden.insert("molecule-by-id");
[533838]675 hidden.insert("nonconvex-file");
676 hidden.insert("order");
677 hidden.insert("output-file");
678 hidden.insert("periodic");
679 hidden.insert("position");
680 hidden.insert("start-step");
[97ebf8]681}
682
683/** Destructor of class MapOfActions.
684 *
685 */
686MapOfActions::~MapOfActions()
687{
688 DescriptionMap.clear();
689}
690
[03c902]691bool MapOfActions::isCurrentValuePresent(const char *name) const
692{
693 return (CurrentValue.find(name) != CurrentValue.end());
694}
695
[d02e07]696void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
697{
698 int atomID = -1;
[4e145c]699 if (typeid( atom ) == *TypeMap[name]) {
700 if (CurrentValue.find(name) == CurrentValue.end())
701 throw MissingValueException(__FILE__, __LINE__);
[d02e07]702 atomID = lexical_cast<int>(CurrentValue[name].c_str());
[4e145c]703 CurrentValue.erase(name);
704 } else
[d02e07]705 throw IllegalTypeException(__FILE__,__LINE__);
706 _T = World::getInstance().getAtom(AtomById(atomID));
707}
708
[e5c0a1]709void MapOfActions::queryCurrentValue(const char * name, const element * &_T) {
[d02e07]710 int Z = -1;
[e5c0a1]711 if (typeid(const element ) == *TypeMap[name]) {
[4e145c]712 if (CurrentValue.find(name) == CurrentValue.end())
713 throw MissingValueException(__FILE__, __LINE__);
[d02e07]714 Z = lexical_cast<int>(CurrentValue[name].c_str());
[4e145c]715 CurrentValue.erase(name);
716 } else
[d02e07]717 throw IllegalTypeException(__FILE__,__LINE__);
718 _T = World::getInstance().getPeriode()->FindElement(Z);
719}
720
721void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
722 int molID = -1;
[4e145c]723 if (typeid( molecule ) == *TypeMap[name]) {
724 if (CurrentValue.find(name) == CurrentValue.end())
725 throw MissingValueException(__FILE__, __LINE__);
[d02e07]726 molID = lexical_cast<int>(CurrentValue[name].c_str());
[4e145c]727 CurrentValue.erase(name);
728 } else
[d02e07]729 throw IllegalTypeException(__FILE__,__LINE__);
730 _T = World::getInstance().getMolecule(MoleculeById(molID));
731}
732
733void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
734 Matrix M;
735 double tmp;
736 if (typeid( BoxValue ) == *TypeMap[name]) {
[4e145c]737 if (CurrentValue.find(name) == CurrentValue.end())
738 throw MissingValueException(__FILE__, __LINE__);
[d02e07]739 std::istringstream stream(CurrentValue[name]);
740 stream >> tmp;
741 M.set(0,0,tmp);
742 stream >> tmp;
743 M.set(0,1,tmp);
744 M.set(1,0,tmp);
745 stream >> tmp;
746 M.set(0,2,tmp);
747 M.set(2,0,tmp);
748 stream >> tmp;
749 M.set(1,1,tmp);
750 stream >> tmp;
751 M.set(1,2,tmp);
752 M.set(2,1,tmp);
753 stream >> tmp;
754 M.set(2,2,tmp);
[39b639]755 _T = M;
756 CurrentValue.erase(name);
[d02e07]757 } else
758 throw IllegalTypeException(__FILE__,__LINE__);
759}
760
761void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
762 if (typeid( VectorValue ) == *TypeMap[name]) {
763 std::istringstream stream(CurrentValue[name]);
[4e145c]764 CurrentValue.erase(name);
[d02e07]765 stream >> _T[0];
766 stream >> _T[1];
767 stream >> _T[2];
768 } else
769 throw IllegalTypeException(__FILE__,__LINE__);
770}
771
[72f611]772void MapOfActions::queryCurrentValue(const char * name, class BoxVector &_T) {
773 if (typeid( VectorValue ) == *TypeMap[name]) {
774 std::istringstream stream(CurrentValue[name]);
775 CurrentValue.erase(name);
776 stream >> _T[0];
777 stream >> _T[1];
778 stream >> _T[2];
779 } else
780 throw IllegalTypeException(__FILE__,__LINE__);
781}
782
[0b0a20]783void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
784{
785 int atomID = -1;
786 atom *Walker = NULL;
787 if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
788 if (CurrentValue.find(name) == CurrentValue.end())
789 throw MissingValueException(__FILE__, __LINE__);
790 std::istringstream stream(CurrentValue[name]);
791 CurrentValue.erase(name);
792 while (!stream.fail()) {
[e65de8]793 stream >> atomID >> ws;
[0b0a20]794 Walker = World::getInstance().getAtom(AtomById(atomID));
795 if (Walker != NULL)
796 _T.push_back(Walker);
[e65de8]797 atomID = -1;
798 Walker = NULL;
[0b0a20]799 }
800 } else
801 throw IllegalTypeException(__FILE__,__LINE__);
802}
803
[e5c0a1]804void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
[d02e07]805{
806 int Z = -1;
[e5c0a1]807 const element *elemental = NULL;
808 if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
[4e145c]809 if (CurrentValue.find(name) == CurrentValue.end())
810 throw MissingValueException(__FILE__, __LINE__);
[d02e07]811 std::istringstream stream(CurrentValue[name]);
[4e145c]812 CurrentValue.erase(name);
[d02e07]813 while (!stream.fail()) {
[e65de8]814 stream >> Z >> ws;
[d02e07]815 elemental = World::getInstance().getPeriode()->FindElement(Z);
816 if (elemental != NULL)
817 _T.push_back(elemental);
[e65de8]818 Z = -1;
[d02e07]819 }
820 } else
821 throw IllegalTypeException(__FILE__,__LINE__);
822}
823
[0b0a20]824void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
[3e54d0]825{
[0b0a20]826 int molID = -1;
827 molecule *mol = NULL;
828 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
[4e145c]829 if (CurrentValue.find(name) == CurrentValue.end())
830 throw MissingValueException(__FILE__, __LINE__);
[3e54d0]831 std::istringstream stream(CurrentValue[name]);
[4e145c]832 CurrentValue.erase(name);
[3e54d0]833 while (!stream.fail()) {
[e65de8]834 stream >> molID >> ws;
[0b0a20]835 mol = World::getInstance().getMolecule(MoleculeById(molID));
836 if (mol != NULL)
837 _T.push_back(mol);
[e65de8]838 molID = -1;
839 mol = NULL;
[3e54d0]840 }
841 } else
842 throw IllegalTypeException(__FILE__,__LINE__);
843}
844
[6f5dfe]845void MapOfActions::queryCurrentValue(const char * name, boost::filesystem::path&_T)
846{
847 std::string tmp;
848 if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
849 if (CurrentValue.find(name) == CurrentValue.end())
850 throw MissingValueException(__FILE__, __LINE__);
851 std::istringstream stream(CurrentValue[name]);
852 CurrentValue.erase(name);
853 if (!stream.fail()) {
854 stream >> tmp >> ws;
855 _T = tmp;
856 }
857 } else
858 throw IllegalTypeException(__FILE__,__LINE__);
859}
860
[d02e07]861
862void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
863{
864 if (typeid( atom ) == *TypeMap[name]) {
865 std::ostringstream stream;
866 stream << _T->getId();
867 CurrentValue[name] = stream.str();
868 } else
869 throw IllegalTypeException(__FILE__,__LINE__);
870}
871
[e5c0a1]872void MapOfActions::setCurrentValue(const char * name, const element * &_T)
[d02e07]873{
[e5c0a1]874 if (typeid(const element ) == *TypeMap[name]) {
[d02e07]875 std::ostringstream stream;
[83f176]876 stream << _T->getAtomicNumber();
[d02e07]877 CurrentValue[name] = stream.str();
878 } else
879 throw IllegalTypeException(__FILE__,__LINE__);
880}
881
882void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
883{
884 if (typeid( molecule ) == *TypeMap[name]) {
885 std::ostringstream stream;
886 stream << _T->getId();
887 CurrentValue[name] = stream.str();
888 } else
889 throw IllegalTypeException(__FILE__,__LINE__);
890}
891
892void MapOfActions::setCurrentValue(const char * name, class Box &_T)
893{
894 const Matrix &M = _T.getM();
[39b639]895 if (typeid( BoxValue ) == *TypeMap[name]) {
[d02e07]896 std::ostringstream stream;
897 stream << M.at(0,0) << " ";
898 stream << M.at(0,1) << " ";
899 stream << M.at(0,2) << " ";
900 stream << M.at(1,1) << " ";
901 stream << M.at(1,2) << " ";
902 stream << M.at(2,2) << " ";
903 CurrentValue[name] = stream.str();
904 } else
905 throw IllegalTypeException(__FILE__,__LINE__);
906}
907
908void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
909{
[39b639]910 if (typeid( VectorValue ) == *TypeMap[name]){
[d02e07]911 std::ostringstream stream;
912 stream << _T[0] << " ";
913 stream << _T[1] << " ";
914 stream << _T[2] << " ";
915 CurrentValue[name] = stream.str();
916 } else
917 throw IllegalTypeException(__FILE__,__LINE__);
918}
919
[72f611]920void MapOfActions::setCurrentValue(const char * name, class BoxVector &_T)
921{
922 if (typeid( VectorValue ) == *TypeMap[name]){
923 std::ostringstream stream;
924 stream << _T[0] << " ";
925 stream << _T[1] << " ";
926 stream << _T[2] << " ";
927 CurrentValue[name] = stream.str();
928 } else
929 throw IllegalTypeException(__FILE__,__LINE__);
930}
931
[0b0a20]932void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
933{
934 if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
935 std::ostringstream stream;
936 for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
937 stream << (*iter)->getId() << " ";
938 }
939 CurrentValue[name] = stream.str();
940 } else
941 throw IllegalTypeException(__FILE__,__LINE__);
942}
943
[e5c0a1]944void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
[d02e07]945{
[e5c0a1]946 if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
[d02e07]947 std::ostringstream stream;
[e5c0a1]948 for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
[83f176]949 stream << (*iter)->getAtomicNumber() << " ";
[d02e07]950 }
951 CurrentValue[name] = stream.str();
952 } else
953 throw IllegalTypeException(__FILE__,__LINE__);
954}
955
[0b0a20]956void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
[3e54d0]957{
[0b0a20]958 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
[3e54d0]959 std::ostringstream stream;
[0b0a20]960 for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
961 stream << (*iter)->getId() << " ";
[3e54d0]962 }
963 CurrentValue[name] = stream.str();
964 } else
965 throw IllegalTypeException(__FILE__,__LINE__);
966}
967
[6f5dfe]968void MapOfActions::setCurrentValue(const char * name, boost::filesystem::path &_T)
969{
970 if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
971 std::ostringstream stream;
972 stream << _T.string();
973 CurrentValue[name] = stream.str();
974 } else
975 throw IllegalTypeException(__FILE__,__LINE__);
976}
977
[d02e07]978
[326bbe]979
980void MapOfActions::populateActions()
981{
982 new AnalysisMolecularVolumeAction();
983 new AnalysisPairCorrelationAction();
[d02e07]984 new AnalysisPointCorrelationAction();
[326bbe]985 new AnalysisPrincipalAxisSystemAction();
[d02e07]986 new AnalysisSurfaceCorrelationAction();
[326bbe]987
988 new AtomAddAction();
989 new AtomChangeElementAction();
990 new AtomRemoveAction();
[22c44bf]991 new AtomRotateAroundOriginByAngleAction();
[34c338]992 new AtomTranslateAction();
[326bbe]993
[53d01c]994 new CommandBondLengthTableAction();
995 new CommandElementDbAction();
996 new CommandFastParsingAction();
997 new CommandHelpAction();
998 new CommandVerboseAction();
999 new CommandVersionAction();
[7230be]1000 new CommandWarrantyAction();
[326bbe]1001
[1a7fd2]1002 new FragmentationConstructBondGraphAction();
[326bbe]1003 new FragmentationDepthFirstSearchAction();
1004 new FragmentationFragmentationAction();
1005 new FragmentationSubgraphDissectionAction();
1006
1007 new MoleculeBondFileAction();
1008 new MoleculeChangeNameAction();
[1a7fd2]1009 new MoleculeCopyAction();
[326bbe]1010 new MoleculeFillWithMoleculeAction();
[eee966]1011 new MoleculeFillVoidWithMoleculeAction();
[326bbe]1012 new MoleculeLinearInterpolationofTrajectoriesAction();
[eaf4ae]1013 new MoleculeRotateAroundSelfByAngleAction();
[b2531f]1014 new MoleculeRotateToPrincipalAxisSystemAction();
[326bbe]1015 new MoleculeSaveAdjacencyAction();
1016 new MoleculeSaveBondsAction();
1017 new MoleculeSaveTemperatureAction();
[b2531f]1018 new MoleculeSuspendInWaterAction();
[326bbe]1019 new MoleculeVerletIntegrationAction();
1020
1021 new ParserLoadXyzAction();
1022 new ParserSaveXyzAction();
1023
[e212ff]1024 new SelectionClearAllAtomsAction();
[2218d94]1025 new SelectionClearAllMoleculesAction();
[e472eab]1026 new SelectionAllAtomsAction();
[1cc87e]1027 new SelectionAllAtomsInsideCuboidAction();
1028 new SelectionAllAtomsInsideSphereAction();
[770287]1029 new SelectionAllAtomsOfMoleculeAction();
[e472eab]1030 new SelectionAllMoleculesAction();
[51769f]1031 new SelectionAtomByElementAction();
[533838]1032 new SelectionAtomByIdAction();
1033 new SelectionMoleculeByIdAction();
[51769f]1034 new SelectionMoleculeByFormulaAction();
[481e92]1035 new SelectionMoleculeOfAtomAction();
[e472eab]1036 new SelectionNotAllAtomsAction();
[1cc87e]1037 new SelectionNotAllAtomsInsideCuboidAction();
1038 new SelectionNotAllAtomsInsideSphereAction();
[381c5f]1039 new SelectionNotAllAtomsOfMoleculeAction();
[e472eab]1040 new SelectionNotAllMoleculesAction();
[51769f]1041 new SelectionNotAtomByElementAction();
[533838]1042 new SelectionNotAtomByIdAction();
[51769f]1043 new SelectionNotMoleculeByFormulaAction();
[533838]1044 new SelectionNotMoleculeByIdAction();
[75a80f]1045 new SelectionNotMoleculeOfAtomAction();
[533838]1046
[326bbe]1047 new TesselationConvexEnvelopeAction();
1048 new TesselationNonConvexEnvelopeAction();
1049
1050 new WorldAddEmptyBoundaryAction();
1051 new WorldBoundInBoxAction();
1052 new WorldCenterInBoxAction();
1053 new WorldCenterOnEdgeAction();
1054 new WorldChangeBoxAction();
1055 new WorldInputAction();
1056 new WorldOutputAction();
1057 new WorldRepeatBoxAction();
1058 new WorldScaleBoxAction();
1059 new WorldSetDefaultNameAction();
1060 new WorldSetGaussianBasisAction();
[b9c847]1061 new WorldSetOutputFormatsAction();
[326bbe]1062}
1063
[97ebf8]1064/** Adds all options to the CommandLineParser.
1065 *
1066 */
1067void MapOfActions::AddOptionsToParser()
1068{
1069 // add other options
1070 for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
1071 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
1072 if (hasValue(*OptionRunner)) {
[e65de8]1073 DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
[ab9a27]1074 switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
[97ebf8]1075 default:
1076 case None:
1077 ListRunner->second->add_options()
1078 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
1079 ;
1080 break;
1081 case Boolean:
1082 ListRunner->second->add_options()
[e30ce8]1083 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1084 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
[39b639]1085 po::value< bool >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
[e30ce8]1086 po::value< bool >(),
1087 getDescription(*OptionRunner).c_str())
[97ebf8]1088 ;
1089 break;
[0286bc]1090 case Box:
1091 ListRunner->second->add_options()
1092 (getKeyAndShortForm(*OptionRunner).c_str(),
[39b639]1093 po::value<BoxValue>(),
[0286bc]1094 getDescription(*OptionRunner).c_str())
1095 ;
1096 break;
[bd2390]1097 case File:
1098 ListRunner->second->add_options()
1099 (getKeyAndShortForm(*OptionRunner).c_str(),
1100 po::value< boost::filesystem::path >(),
1101 getDescription(*OptionRunner).c_str())
1102 ;
1103 break;
[97ebf8]1104 case Integer:
1105 ListRunner->second->add_options()
[e30ce8]1106 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1107 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
[39b639]1108 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
[e30ce8]1109 po::value< int >(),
1110 getDescription(*OptionRunner).c_str())
[97ebf8]1111 ;
1112 break;
[0b0a20]1113 case ListOfIntegers:
[97ebf8]1114 ListRunner->second->add_options()
[e30ce8]1115 (getKeyAndShortForm(*OptionRunner).c_str(),
1116 po::value< vector<int> >()->multitoken(),
1117 getDescription(*OptionRunner).c_str())
[97ebf8]1118 ;
1119 break;
1120 case Double:
1121 ListRunner->second->add_options()
[e30ce8]1122 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1123 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
[39b639]1124 po::value< double >()->default_value(lexical_cast<double>(CurrentValue[*OptionRunner].c_str())) :
[e30ce8]1125 po::value< double >(),
1126 getDescription(*OptionRunner).c_str())
[97ebf8]1127 ;
1128 break;
1129 case ListOfDoubles:
1130 ListRunner->second->add_options()
[e30ce8]1131 (getKeyAndShortForm(*OptionRunner).c_str(),
1132 po::value< vector<double> >()->multitoken(),
1133 getDescription(*OptionRunner).c_str())
[97ebf8]1134 ;
1135 break;
1136 case String:
1137 ListRunner->second->add_options()
[e30ce8]1138 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1139 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
1140 po::value< std::string >()->default_value(CurrentValue[*OptionRunner]) :
[e30ce8]1141 po::value< std::string >(),
1142 getDescription(*OptionRunner).c_str())
[97ebf8]1143 ;
1144 break;
[0b0a20]1145 case ListOfStrings:
[cd8e55]1146 ListRunner->second->add_options()
1147 (getKeyAndShortForm(*OptionRunner).c_str(),
1148 po::value< vector<std::string> >()->multitoken(),
1149 getDescription(*OptionRunner).c_str())
1150 ;
1151 break;
[0b0a20]1152 case Vector:
[97ebf8]1153 ListRunner->second->add_options()
[e30ce8]1154 (getKeyAndShortForm(*OptionRunner).c_str(),
[0b0a20]1155 po::value<VectorValue>(),
[e30ce8]1156 getDescription(*OptionRunner).c_str())
[97ebf8]1157 ;
1158 break;
[0b0a20]1159 case ListOfVectors:
[97ebf8]1160 ListRunner->second->add_options()
[e30ce8]1161 (getKeyAndShortForm(*OptionRunner).c_str(),
[0b0a20]1162 po::value< vector<VectorValue> >()->multitoken(),
[e30ce8]1163 getDescription(*OptionRunner).c_str())
[97ebf8]1164 ;
1165 break;
1166 case Molecule:
1167 ListRunner->second->add_options()
[e30ce8]1168 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1169 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
[39b639]1170 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
[e30ce8]1171 po::value< int >(),
1172 getDescription(*OptionRunner).c_str())
[97ebf8]1173 ;
1174 break;
1175 case ListOfMolecules:
1176 ListRunner->second->add_options()
[e30ce8]1177 (getKeyAndShortForm(*OptionRunner).c_str(),
1178 po::value< vector<int> >()->multitoken(),
1179 getDescription(*OptionRunner).c_str())
[97ebf8]1180 ;
1181 break;
1182 case Atom:
1183 ListRunner->second->add_options()
[e30ce8]1184 (getKeyAndShortForm(*OptionRunner).c_str(),
[ab9a27]1185 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?
[39b639]1186 po::value< int >()->default_value(lexical_cast<int>(CurrentValue[*OptionRunner].c_str())) :
[e30ce8]1187 po::value< int >(),
1188 getDescription(*OptionRunner).c_str())
[97ebf8]1189 ;
1190 break;
1191 case ListOfAtoms:
1192 ListRunner->second->add_options()
[e30ce8]1193 (getKeyAndShortForm(*OptionRunner).c_str(),
1194 po::value< vector<int> >()->multitoken(),
1195 getDescription(*OptionRunner).c_str())
[97ebf8]1196 ;
1197 break;
1198 case Element:
1199 ListRunner->second->add_options()
[e30ce8]1200 (getKeyAndShortForm(*OptionRunner).c_str(),
[39b639]1201 po::value< int >(),
[e30ce8]1202 getDescription(*OptionRunner).c_str())
[97ebf8]1203 ;
1204 break;
1205 case ListOfElements:
1206 ListRunner->second->add_options()
[e30ce8]1207 (getKeyAndShortForm(*OptionRunner).c_str(),
1208 po::value< vector<int> >()->multitoken(),
1209 getDescription(*OptionRunner).c_str())
[97ebf8]1210 ;
1211 break;
1212 }
1213 } else {
[0b0a20]1214 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
[97ebf8]1215 ListRunner->second->add_options()
1216 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
1217 ;
1218 }
1219 }
1220 }
1221}
1222
1223/** Getter for MapOfActions:DescriptionMap.
1224 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
1225 * \param actionname name of the action to lookup
1226 * \return Description of the action
1227 */
1228std::string MapOfActions::getDescription(string actionname)
1229{
1230 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
1231 return DescriptionMap[actionname];
1232}
1233
1234/** Specific Getter for a MapOfActions:ShortFormMap.
1235 * If action has a short for, then combination is as "actionname,ShortForm" (this is
1236 * the desired format for boost::program_options). If no short form exists in the map,
1237 * just actionname will be returned
1238 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
1239 * \param actionname name of the action to lookup
1240 * \return actionname,ShortForm or Description of the action
1241 */
1242std::string MapOfActions::getKeyAndShortForm(string actionname)
1243{
1244 stringstream output;
1245 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
1246 output << actionname;
1247 if (ShortFormMap.find(actionname) != DescriptionMap.end())
1248 output << "," << ShortFormMap[actionname];
1249 return output.str();
1250}
1251
1252/** Getter for MapOfActions:ShortFormMap.
1253 * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
1254 * \param actionname name of the action to lookup
1255 * \return ShortForm of the action
1256 */
1257std::string MapOfActions::getShortForm(string actionname)
1258{
1259 ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
1260 return ShortFormMap[actionname];
1261}
1262
1263/** Returns whether the given action needs a value or not.
1264 * \param actionname name of the action to look up
1265 * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
1266 */
1267bool MapOfActions::hasValue(string actionname)
1268{
1269 return (TypeMap.find(actionname) != TypeMap.end());
1270}
1271
1272/** Getter for MapOfActions::TypeMap.
1273 * \param actionname name of the action to look up
1274 * \return type of the action
1275 */
[ab9a27]1276std::string MapOfActions::getValueType(string actionname)
[97ebf8]1277{
[ab9a27]1278 return TypeMap[actionname]->name();
[97ebf8]1279}
1280
1281/** Searches whether action is registered with CommandLineParser.
1282 * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
1283 * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
1284 * by this function.
1285 * \param shortform command short form to look for
1286 * \return true - action has been registered, false - action has not been registered.
1287 */
1288bool MapOfActions::isShortFormPresent(string shortform)
1289{
1290 bool result = false;
1291 string actionname;
1292 for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
1293 if (ShortFormRunner->second == shortform) {
1294 actionname = ShortFormRunner->first;
1295 break;
1296 }
1297 result = result || (generic.find(actionname) != generic.end());
1298 result = result || (config.find(actionname) != config.end());
1299 result = result || (hidden.find(actionname) != hidden.end());
1300 result = result || (visible.find(actionname) != visible.end());
1301 result = result || (inputfile.find(actionname) != inputfile.end());
1302 return result;
1303}
1304
[7e6b00]1305/** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
1306 * \return map from short form of action to name of action
1307 */
1308map <std::string, std::string> MapOfActions::getShortFormToActionMap()
1309{
1310 map <std::string, std::string> result;
1311
1312 for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter)
1313 result[iter->second] = iter->first;
1314
1315 return result;
1316}
[97ebf8]1317
1318
1319CONSTRUCT_SINGLETON(MapOfActions)
Note: See TracBrowser for help on using the repository browser.