source: src/Actions/MapOfActions.cpp@ c27778

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 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 c27778 was b9c847, checked in by Frederik Heber <heber@…>, 15 years ago

New SetOutputFormatsAction introduced.

Fixes:

new SetOutputFormatsAction:

  • new action SetOutputFormatsAction which instantiates various specializations of FormatParser in FormatParserStorage.
  • main(): mpqc, pcp and xyz and no more added by default to FormatParserStorage, this now has to be done by specifying them (e.g. on the command line as -o pcp mpqc xyz)
  • TESTFIXES: case 10,11,13,16,17,22 all failed due to the missing -o specification which has been added (this has been intended in this way from the very beginning of the ParseCommandLineOptions() refactoring)
  • action "convex-envelope" now more has ShortForm "-o" due to obvious reasons.
  • Property mode set to 100644
File size: 33.2 KB
RevLine 
[97ebf8]1/*
2 * MapOfActions.cpp
3 *
4 * Created on: 10.05.2010
5 * Author: heber
6 */
7
[112b09]8#include "Helpers/MemDebug.hpp"
9
[97ebf8]10using namespace std;
11
12#include "Patterns/Singleton_impl.hpp"
13#include "Actions/MapOfActions.hpp"
14#include "Helpers/Assert.hpp"
15
[0286bc]16#include <boost/lexical_cast.hpp>
17#include <boost/optional.hpp>
18#include <boost/program_options.hpp>
19
[97ebf8]20#include "CommandLineParser.hpp"
21#include "log.hpp"
22#include "verbose.hpp"
23
[326bbe]24#include "Actions/ActionRegistry.hpp"
25#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
26#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
27#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
28#include "Actions/AtomAction/AddAction.hpp"
29#include "Actions/AtomAction/ChangeElementAction.hpp"
30#include "Actions/AtomAction/RemoveAction.hpp"
31#include "Actions/CmdAction/BondLengthTableAction.hpp"
32#include "Actions/CmdAction/ElementDbAction.hpp"
33#include "Actions/CmdAction/FastParsingAction.hpp"
34#include "Actions/CmdAction/HelpAction.hpp"
35#include "Actions/CmdAction/VerboseAction.hpp"
36#include "Actions/CmdAction/VersionAction.hpp"
37#include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
38#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
39#include "Actions/FragmentationAction/FragmentationAction.hpp"
40#include "Actions/MoleculeAction/BondFileAction.hpp"
41#include "Actions/MoleculeAction/ChangeNameAction.hpp"
42#include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
43#include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
[b2531f]44#include "Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp"
[326bbe]45#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
46#include "Actions/MoleculeAction/SaveBondsAction.hpp"
47#include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
[b2531f]48#include "Actions/MoleculeAction/SuspendInWaterAction.hpp"
[326bbe]49#include "Actions/MoleculeAction/TranslateAction.hpp"
50#include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
51#include "Actions/ParserAction/LoadXyzAction.hpp"
52#include "Actions/ParserAction/SaveXyzAction.hpp"
53#include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
54#include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
55#include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
56#include "Actions/WorldAction/BoundInBoxAction.hpp"
57#include "Actions/WorldAction/CenterInBoxAction.hpp"
58#include "Actions/WorldAction/CenterOnEdgeAction.hpp"
59#include "Actions/WorldAction/ChangeBoxAction.hpp"
60#include "Actions/WorldAction/InputAction.hpp"
61#include "Actions/WorldAction/OutputAction.hpp"
62#include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
63#include "Actions/WorldAction/RepeatBoxAction.hpp"
64#include "Actions/WorldAction/ScaleBoxAction.hpp"
65#include "Actions/WorldAction/SetDefaultNameAction.hpp"
66#include "Actions/WorldAction/SetGaussianBasisAction.hpp"
[b9c847]67#include "Actions/WorldAction/SetOutputFormatsAction.hpp"
[0286bc]68#include "Actions/Values.hpp"
69
70void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
71{
72 VectorValue VV;
73 if (values.size() != 3) {
74 cerr << "Specified vector does not have three components but " << values.size() << endl;
75 throw boost::program_options::validation_error("Specified vector does not have three components");
76 }
77 VV.x = boost::lexical_cast<double>(values.at(0));
78 VV.y = boost::lexical_cast<double>(values.at(1));
79 VV.z = boost::lexical_cast<double>(values.at(2));
80 v = boost::any(VectorValue(VV));
81}
82
83void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
84{
85 BoxValue BV;
86 if (values.size() != 6) {
87 cerr << "Specified vector does not have three components but " << values.size() << endl;
88 throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
89 }
90 BV.xx = boost::lexical_cast<double>(values.at(0));
91 BV.xy = boost::lexical_cast<double>(values.at(1));
92 BV.xz = boost::lexical_cast<double>(values.at(2));
93 BV.yy = boost::lexical_cast<double>(values.at(3));
94 BV.yz = boost::lexical_cast<double>(values.at(4));
95 BV.zz = boost::lexical_cast<double>(values.at(5));
96 v = boost::any(BoxValue(BV));
97}
98
[97ebf8]99/** Constructor of class MapOfActions.
100 *
101 */
102MapOfActions::MapOfActions()
103{
104 // initialise lookup map
105 CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
106 CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
107 CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
108 CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
109
110 // keys for actions
111 DescriptionMap["add-atom"] = "add atom of specified element";
112 DescriptionMap["bond-table"] = "setting name of the bond length table file";
113 DescriptionMap["bond-file"] = "name of the bond file";
114 DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
115 DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
116 DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
117 DescriptionMap["center-in-box"] = "center all atoms in the domain";
118 DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
119 DescriptionMap["change-element"] = "change the element of an atom";
120 DescriptionMap["change-molname"] = "change the name of a molecule";
121 DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
122 DescriptionMap["default-molname"] = "set the default name of new molecules";
123 DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
124 DescriptionMap["element-db"] = "setting the path where the element databases can be found";
125 DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
126 DescriptionMap["fill-molecule"] = "fill empty space of box with a filler molecule";
127 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
[a77976]128 DescriptionMap["help"] = "Give this help screen";
[4f7f34e]129 DescriptionMap["input"] = "specify input files";
[97ebf8]130 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
131 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
[b9c847]132 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
133 DescriptionMap["output"] = "write output files";
134 DescriptionMap["set-output"] = "specify output formats";
[58bbd3]135 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface";
[97ebf8]136 DescriptionMap["parse-xyz"] = "parse xyz file into World";
137 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
138 DescriptionMap["remove-atom"] = "remove a specified atom";
139 DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
140 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
141 DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
142 DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
143 DescriptionMap["save-bonds"] = "name of the bonds file to write to";
144 DescriptionMap["save-temperature"] = "name of the temperature file to write to";
[326bbe]145 DescriptionMap["SaveXyz"] = "save world as xyz file";
[2a92ff]146 DescriptionMap["scale-box"] = "scale box and atomic positions inside";
[b9c847]147 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
148 DescriptionMap["set-output"] = "specify output formats";
[6866aa]149 DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
[97ebf8]150 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
151 DescriptionMap["translate-mol"] = "translate molecule by given vector";
152 DescriptionMap["verbose"] = "set verbosity level";
153 DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
154 DescriptionMap["version"] = "show version";
155 // keys for values
[54b953]156 DescriptionMap["atom-by-id"] = "index of an atom";
[97ebf8]157 DescriptionMap["bin-output-file"] = "name of the bin output file";
158 DescriptionMap["bin-end"] = "start of the last bin";
159 DescriptionMap["bin-start"] = "start of the first bin";
160 DescriptionMap["bin-width"] = "width of the bins";
[f6bd32]161 DescriptionMap["convex-file"] = "filename of the non-convex envelope";
[97ebf8]162 DescriptionMap["distance"] = "distance in space";
163 DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
[0286bc]164 DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
[58bbd3]165 DescriptionMap["element"] = "single element";
166 DescriptionMap["elements"] = "set of elements";
[a02462]167 DescriptionMap["end-step"] = "last or end step";
168 DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used";
[97ebf8]169 DescriptionMap["input"] = "name of input file";
170 DescriptionMap["length"] = "length in space";
171 DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
172 DescriptionMap["MaxDistance"] = "maximum distance in space";
173 DescriptionMap["molecule-by-id"] = "index of a molecule";
[58bbd3]174 DescriptionMap["molecule-by-name"] = "name of a molecule";
[f6bd32]175 DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
[e4b5de]176 DescriptionMap["order"] = "order of a discretization, dissection, ...";
[97ebf8]177 DescriptionMap["output-file"] = "name of the output file";
178 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
179 DescriptionMap["position"] = "position in R^3 space";
[980dd6]180 DescriptionMap["sphere-radius"] = "radius of tesselation sphere";
[a02462]181 DescriptionMap["start-step"] = "first or start step";
[97ebf8]182
183 // short forms for the actions
184 ShortFormMap["add-atom"] = "a";
185 ShortFormMap["bond-table"] = "g";
186 ShortFormMap["bond-file"] = "A";
187 ShortFormMap["boundary"] = "c";
[6ca1f7]188 ShortFormMap["change-box"] = "B";
[97ebf8]189 ShortFormMap["center-edge"] = "O";
190 ShortFormMap["center-in-box"] = "b";
191 ShortFormMap["change-element"] = "E";
[b9c847]192// ShortFormMap["convex-envelope"] = "x";
[97ebf8]193 ShortFormMap["default-molname"] = "X";
194 ShortFormMap["depth-first-search"] = "D";
195 ShortFormMap["element-db"] = "e";
196 ShortFormMap["fastparsing"] = "n";
197 ShortFormMap["fill-molecule"] = "F";
198 ShortFormMap["fragment-mol"] = "f";
199 ShortFormMap["help"] = "h";
200 ShortFormMap["input"] = "i";
201 ShortFormMap["linear-interpolate"] = "L";
202 ShortFormMap["nonconvex-envelope"] = "N";
[cd8e55]203// ShortFormMap["output"] = "o";
[58bbd3]204 ShortFormMap["pair-correlation"] = "C";
[97ebf8]205 ShortFormMap["parse-xyz"] = "p";
206 ShortFormMap["remove-atom"] = "r";
207 ShortFormMap["remove-sphere"] = "R";
208 ShortFormMap["repeat-box"] = "d";
209 ShortFormMap["rotate-to-pas"] = "m";
210 ShortFormMap["save-adjacency"] = "J";
211 ShortFormMap["save-bonds"] = "j";
212 ShortFormMap["save-temperature"] = "S";
213 ShortFormMap["scale-box"] = "s";
214 ShortFormMap["set-basis"] = "M";
[b9c847]215 ShortFormMap["set-output"] = "o";
[6866aa]216 ShortFormMap["subgraph-dissect"] = "I";
[48ab70a]217 ShortFormMap["suspend-in-water"] = "u";
[97ebf8]218 ShortFormMap["translate-mol"] = "t";
[6670a97]219 ShortFormMap["verbose"] = "v";
[97ebf8]220 ShortFormMap["verlet-integrate"] = "P";
[6670a97]221 ShortFormMap["version"] = "V";
[97ebf8]222
223 // value types for the actions
[f0a3ec]224 TypeMap["add-atom"] = Element;
[97ebf8]225 TypeMap["bond-file"] = String;
226 TypeMap["bond-table"] = String;
227 TypeMap["boundary"] = Vector;
[0286bc]228 TypeMap["center-in-box"] = Box;
229 TypeMap["change-box"] = Box;
[54b953]230 TypeMap["change-element"] = Atom;
[97ebf8]231 TypeMap["change-molname"] = String;
232 TypeMap["convex-envelope"] = Molecule;
233 TypeMap["default-molname"] = String;
234 TypeMap["depth-first-search"] = Double;
235 TypeMap["element-db"] = String;
236 TypeMap["fastparsing"] = Boolean;
237 TypeMap["fill-molecule"] = String;
[35b698]238 TypeMap["fragment-mol"] = String;
[97ebf8]239 TypeMap["input"] = String;
240 TypeMap["linear-interpolate"] = String;
241 TypeMap["molecular-volume"] = Molecule;
242 TypeMap["nonconvex-envelope"] = Molecule;
[b9c847]243 TypeMap["output"] = None;
[97ebf8]244 TypeMap["parse-xyz"] = String;
[58bbd3]245 TypeMap["pair-correlation"] = String;
[2b5574]246 TypeMap["principal-axis-system"] = Molecule;
[97ebf8]247 TypeMap["remove-atom"] = Atom;
[e2b47c]248 TypeMap["remove-sphere"] = Double;
[e30ce8]249 TypeMap["repeat-box"] = Vector;
[97ebf8]250 TypeMap["rotate-to-pas"] = Molecule;
251 TypeMap["save-adjacency"] = String;
252 TypeMap["save-bonds"] = String;
253 TypeMap["save-temperature"] = String;
254 TypeMap["scale-box"] = Vector;
255 TypeMap["set-basis"] = String;
[b9c847]256 TypeMap["set-output"] = ListOfString;
[6866aa]257 TypeMap["subgraph-dissect"] = None;
[48ab70a]258 TypeMap["suspend-in-water"] = Double;
[97ebf8]259 TypeMap["translate-mol"] = Vector;
260 TypeMap["verlet-integrate"] = String;
261 TypeMap["verbose"] = Integer;
[e30ce8]262
[97ebf8]263 // value types for the values
[54b953]264 TypeMap["atom-by-id"] = Atom;
[97ebf8]265 TypeMap["bin-output-file"] = String;
266 TypeMap["bin-end"] = Double;
267 TypeMap["bin-start"] = Double;
[58bbd3]268 TypeMap["bin-width"] = Double;
[f6bd32]269 TypeMap["convex-file"] = String;
[97ebf8]270 TypeMap["distance"] = Double;
[0286bc]271 TypeMap["distances"] = Vector;
272 TypeMap["DoRotate"] = Boolean;
[f0a3ec]273 TypeMap["element"] = Element;
[97ebf8]274 TypeMap["elements"] = ListOfElements;
[a02462]275 TypeMap["end-step"] = Integer;
276 TypeMap["id-mapping"] = Boolean;
[97ebf8]277 TypeMap["length"] = Double;
[0286bc]278 TypeMap["lengths"] = Vector;
[97ebf8]279 TypeMap["MaxDistance"] = Double;
280 TypeMap["molecule-by-id"] = Molecule;
[58bbd3]281 TypeMap["molecule-by-name"] = Molecule;
[f6bd32]282 TypeMap["nonconvex-file"] = String;
[e4b5de]283 TypeMap["order"] = Integer;
[97ebf8]284 TypeMap["output-file"] = String;
285 TypeMap["periodic"] = Boolean;
286 TypeMap["position"] = Vector;
[980dd6]287 TypeMap["sphere-radius"] = Double;
[a02462]288 TypeMap["start-step"] = Integer;
[97ebf8]289
[e30ce8]290 // default values for any action that needs one (always string!)
[58bbd3]291 DefaultValue["bin-width"] = "0.5";
[f821d6]292 DefaultValue["fastparsing"] = "0";
[54b953]293 DefaultValue["atom-by-id"] = "-1";
[e30ce8]294 DefaultValue["molecule-by-id"] = "-1";
[58bbd3]295 DefaultValue["periodic"] = "0";
[e30ce8]296
[326bbe]297 // put action into each menu category
[b2531f]298 MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
299 MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Edit atoms");
300 MenuDescription["command"] = pair<std::string,std::string>("Configuration", "Configuration");
301 MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
302 MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Parse files");
303 MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Edit molecules");
304 MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselate molecules");
305 MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Edit world");
306
[326bbe]307 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
308 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
309 MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
[e30ce8]310
[326bbe]311 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
312 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
313 MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
314
315 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
316 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
317 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
318 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
319 MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
320
321 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
322 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
323 MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
324
325 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
326 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
327 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
328 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
329 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
330 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
331 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
332 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
333 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
334 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "translate-mol") );
335 MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
336
337 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
338 MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
339
340 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
341 MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
342
343 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
344 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
345 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
346 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
347 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
348 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
349 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
350 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "remove-sphere") );
351 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
352 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
353 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
354 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
[b9c847]355 MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
[326bbe]356
357 // put actions into command line category
[f0a3ec]358 generic.insert("add-atom");
[f4bd01]359 generic.insert("bond-file");
[39af9f]360 generic.insert("bond-table");
[116f37]361 generic.insert("boundary");
[97ebf8]362// generic.insert("bound-in-box");
[584a2a]363 generic.insert("center-edge");
[158c594]364 generic.insert("center-in-box");
[6ca1f7]365 generic.insert("change-box");
[97ebf8]366// generic.insert("change-molname");
[54b953]367 generic.insert("change-element");
[f6bd32]368 generic.insert("convex-envelope");
[387b36]369 generic.insert("default-molname");
[8540f0]370 generic.insert("depth-first-search");
[198494]371 generic.insert("element-db");
[f821d6]372 generic.insert("fastparsing");
[0286bc]373 generic.insert("fill-molecule");
[e4b5de]374 generic.insert("fragment-mol");
[97ebf8]375 generic.insert("help");
[4f7f34e]376 generic.insert("input");
377 generic.insert("linear-interpolate");
[97ebf8]378// generic.insert("molecular-volume");
[980dd6]379 generic.insert("nonconvex-envelope");
[4f7f34e]380 generic.insert("output");
[58bbd3]381 generic.insert("pair-correlation");
[a1e929]382 generic.insert("parse-xyz");
[97ebf8]383// generic.insert("principal-axis-system");
[d55743e]384 generic.insert("remove-atom");
[e2b47c]385 generic.insert("remove-sphere");
[0286bc]386 generic.insert("repeat-box");
[2b5574]387 generic.insert("rotate-to-pas");
[77de81]388 generic.insert("save-adjacency");
389 generic.insert("save-bonds");
[a307af]390 generic.insert("save-temperature");
[2a92ff]391 generic.insert("scale-box");
[bdaacd]392 generic.insert("set-basis");
[b9c847]393 generic.insert("set-output");
[6866aa]394 generic.insert("subgraph-dissect");
[48ab70a]395 generic.insert("suspend-in-water");
[77b2d7]396 generic.insert("translate-mol");
[97ebf8]397 generic.insert("verbose");
[aacce8]398 generic.insert("verlet-integrate");
[97ebf8]399 generic.insert("version");
400
401 // positional arguments
[f6bd32]402 generic.insert("input");
403 inputfile.insert("input");
[0286bc]404
405 // hidden arguments
[54b953]406 generic.insert("atom-by-id");
[58bbd3]407 generic.insert("bin-end");
408 generic.insert("bin-output-file");
409 generic.insert("bin-start");
410 generic.insert("bin-width");
[f6bd32]411 generic.insert("convex-file");
[e4b5de]412 generic.insert("distance");
413 generic.insert("DoRotate");
414 generic.insert("distances");
[58bbd3]415 generic.insert("element");
416 generic.insert("elements");
[a02462]417 generic.insert("end-step");
418 generic.insert("id-mapping");
[e4b5de]419 generic.insert("lengths");
420 generic.insert("MaxDistance");
421 generic.insert("molecule-by-id");
[58bbd3]422 generic.insert("molecule-by-name");
[f6bd32]423 generic.insert("nonconvex-file");
[e4b5de]424 generic.insert("order");
[58bbd3]425 generic.insert("output-file");
426 generic.insert("periodic");
427 generic.insert("position");
[980dd6]428 generic.insert("sphere-radius");
[a02462]429 generic.insert("start-step");
[97ebf8]430}
431
432/** Destructor of class MapOfActions.
433 *
434 */
435MapOfActions::~MapOfActions()
436{
437 DescriptionMap.clear();
438}
439
[326bbe]440
441void MapOfActions::populateActions()
442{
443 new AnalysisMolecularVolumeAction();
444 new AnalysisPairCorrelationAction();
445 new AnalysisPrincipalAxisSystemAction();
446
447 new AtomAddAction();
448 new AtomChangeElementAction();
449 new AtomRemoveAction();
450
451 new CommandLineBondLengthTableAction();
452 new CommandLineElementDbAction();
453 new CommandLineFastParsingAction();
454 new CommandLineHelpAction();
455 new CommandLineVerboseAction();
456 new CommandLineVersionAction();
457
458 new FragmentationDepthFirstSearchAction();
459 new FragmentationFragmentationAction();
460 new FragmentationSubgraphDissectionAction();
461
462 new MoleculeBondFileAction();
463 new MoleculeChangeNameAction();
464 new MoleculeFillWithMoleculeAction();
465 new MoleculeLinearInterpolationofTrajectoriesAction();
[b2531f]466 new MoleculeRotateToPrincipalAxisSystemAction();
[326bbe]467 new MoleculeSaveAdjacencyAction();
468 new MoleculeSaveBondsAction();
469 new MoleculeSaveTemperatureAction();
[b2531f]470 new MoleculeSuspendInWaterAction();
[326bbe]471 new MoleculeTranslateAction();
472 new MoleculeVerletIntegrationAction();
473
474 new ParserLoadXyzAction();
475 new ParserSaveXyzAction();
476
477 new TesselationConvexEnvelopeAction();
478 new TesselationNonConvexEnvelopeAction();
479
480 new WorldAddEmptyBoundaryAction();
481 new WorldBoundInBoxAction();
482 new WorldCenterInBoxAction();
483 new WorldCenterOnEdgeAction();
484 new WorldChangeBoxAction();
485 new WorldInputAction();
486 new WorldOutputAction();
487 new WorldRemoveSphereOfAtomsAction();
488 new WorldRepeatBoxAction();
489 new WorldScaleBoxAction();
490 new WorldSetDefaultNameAction();
491 new WorldSetGaussianBasisAction();
[b9c847]492 new WorldSetOutputFormatsAction();
[326bbe]493}
494
495
[97ebf8]496/** Adds all options to the CommandLineParser.
497 *
498 */
499void MapOfActions::AddOptionsToParser()
500{
501 // add other options
502 for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
503 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
504 if (hasValue(*OptionRunner)) {
505 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
506 switch((enum OptionTypes) TypeMap[*OptionRunner]) {
507 default:
508 case None:
509 ListRunner->second->add_options()
510 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
511 ;
512 break;
513 case Boolean:
514 ListRunner->second->add_options()
[e30ce8]515 (getKeyAndShortForm(*OptionRunner).c_str(),
516 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
517 po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
518 po::value< bool >(),
519 getDescription(*OptionRunner).c_str())
[97ebf8]520 ;
521 break;
[0286bc]522 case Box:
523 ListRunner->second->add_options()
524 (getKeyAndShortForm(*OptionRunner).c_str(),
525 po::value<BoxValue>()->multitoken(),
526 getDescription(*OptionRunner).c_str())
527 ;
528 break;
[97ebf8]529 case Integer:
530 ListRunner->second->add_options()
[e30ce8]531 (getKeyAndShortForm(*OptionRunner).c_str(),
532 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
533 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
534 po::value< int >(),
535 getDescription(*OptionRunner).c_str())
[97ebf8]536 ;
537 break;
538 case ListOfInts:
539 ListRunner->second->add_options()
[e30ce8]540 (getKeyAndShortForm(*OptionRunner).c_str(),
541 po::value< vector<int> >()->multitoken(),
542 getDescription(*OptionRunner).c_str())
[97ebf8]543 ;
544 break;
545 case Double:
546 ListRunner->second->add_options()
[e30ce8]547 (getKeyAndShortForm(*OptionRunner).c_str(),
548 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
549 po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
550 po::value< double >(),
551 getDescription(*OptionRunner).c_str())
[97ebf8]552 ;
553 break;
554 case ListOfDoubles:
555 ListRunner->second->add_options()
[e30ce8]556 (getKeyAndShortForm(*OptionRunner).c_str(),
557 po::value< vector<double> >()->multitoken(),
558 getDescription(*OptionRunner).c_str())
[97ebf8]559 ;
560 break;
561 case String:
562 ListRunner->second->add_options()
[e30ce8]563 (getKeyAndShortForm(*OptionRunner).c_str(),
564 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
565 po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
566 po::value< std::string >(),
567 getDescription(*OptionRunner).c_str())
[97ebf8]568 ;
569 break;
[cd8e55]570 case ListOfString:
571 ListRunner->second->add_options()
572 (getKeyAndShortForm(*OptionRunner).c_str(),
573 po::value< vector<std::string> >()->multitoken(),
574 getDescription(*OptionRunner).c_str())
575 ;
576 break;
[97ebf8]577 case Axis:
578 ListRunner->second->add_options()
[e30ce8]579 (getKeyAndShortForm(*OptionRunner).c_str(),
580 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
581 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
582 po::value< int >(),
583 getDescription(*OptionRunner).c_str())
[97ebf8]584 ;
585 break;
586 case Vector:
587 ListRunner->second->add_options()
[e30ce8]588 (getKeyAndShortForm(*OptionRunner).c_str(),
[0286bc]589 po::value<VectorValue>()->multitoken(),
[e30ce8]590 getDescription(*OptionRunner).c_str())
[97ebf8]591 ;
592 break;
593 case Molecule:
594 ListRunner->second->add_options()
[e30ce8]595 (getKeyAndShortForm(*OptionRunner).c_str(),
596 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
597 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
598 po::value< int >(),
599 getDescription(*OptionRunner).c_str())
[97ebf8]600 ;
601 break;
602 case ListOfMolecules:
603 ListRunner->second->add_options()
[e30ce8]604 (getKeyAndShortForm(*OptionRunner).c_str(),
605 po::value< vector<int> >()->multitoken(),
606 getDescription(*OptionRunner).c_str())
[97ebf8]607 ;
608 break;
609 case Atom:
610 ListRunner->second->add_options()
[e30ce8]611 (getKeyAndShortForm(*OptionRunner).c_str(),
612 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
613 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
614 po::value< int >(),
615 getDescription(*OptionRunner).c_str())
[97ebf8]616 ;
617 break;
618 case ListOfAtoms:
619 ListRunner->second->add_options()
[e30ce8]620 (getKeyAndShortForm(*OptionRunner).c_str(),
621 po::value< vector<int> >()->multitoken(),
622 getDescription(*OptionRunner).c_str())
[97ebf8]623 ;
624 break;
625 case Element:
626 ListRunner->second->add_options()
[e30ce8]627 (getKeyAndShortForm(*OptionRunner).c_str(),
[f0a3ec]628 po::value< vector<int> >(),
[e30ce8]629 getDescription(*OptionRunner).c_str())
[97ebf8]630 ;
631 break;
632 case ListOfElements:
633 ListRunner->second->add_options()
[e30ce8]634 (getKeyAndShortForm(*OptionRunner).c_str(),
635 po::value< vector<int> >()->multitoken(),
636 getDescription(*OptionRunner).c_str())
[97ebf8]637 ;
638 break;
639 }
640 } else {
641 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
642 ListRunner->second->add_options()
643 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
644 ;
645 }
646 }
647 }
648 // add positional arguments
649 for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {
650 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);
651 CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);
652 }
653 cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;
654}
655
656/** Getter for MapOfActions:DescriptionMap.
657 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
658 * \param actionname name of the action to lookup
659 * \return Description of the action
660 */
661std::string MapOfActions::getDescription(string actionname)
662{
663 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
664 return DescriptionMap[actionname];
665}
666
667/** Specific Getter for a MapOfActions:ShortFormMap.
668 * If action has a short for, then combination is as "actionname,ShortForm" (this is
669 * the desired format for boost::program_options). If no short form exists in the map,
670 * just actionname will be returned
671 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
672 * \param actionname name of the action to lookup
673 * \return actionname,ShortForm or Description of the action
674 */
675std::string MapOfActions::getKeyAndShortForm(string actionname)
676{
677 stringstream output;
678 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
679 output << actionname;
680 if (ShortFormMap.find(actionname) != DescriptionMap.end())
681 output << "," << ShortFormMap[actionname];
682 return output.str();
683}
684
685/** Getter for MapOfActions:ShortFormMap.
686 * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
687 * \param actionname name of the action to lookup
688 * \return ShortForm of the action
689 */
690std::string MapOfActions::getShortForm(string actionname)
691{
692 ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
693 return ShortFormMap[actionname];
694}
695
696/** Returns whether the given action needs a value or not.
697 * \param actionname name of the action to look up
698 * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
699 */
700bool MapOfActions::hasValue(string actionname)
701{
702 return (TypeMap.find(actionname) != TypeMap.end());
703}
704
705/** Getter for MapOfActions::TypeMap.
706 * \param actionname name of the action to look up
707 * \return type of the action
708 */
709enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
710{
711 return TypeMap[actionname];
712}
713
714/** Searches whether action is registered with CommandLineParser.
715 * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
716 * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
717 * by this function.
718 * \param shortform command short form to look for
719 * \return true - action has been registered, false - action has not been registered.
720 */
721bool MapOfActions::isShortFormPresent(string shortform)
722{
723 bool result = false;
724 string actionname;
725 for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
726 if (ShortFormRunner->second == shortform) {
727 actionname = ShortFormRunner->first;
728 break;
729 }
730 result = result || (generic.find(actionname) != generic.end());
731 result = result || (config.find(actionname) != config.end());
732 result = result || (hidden.find(actionname) != hidden.end());
733 result = result || (visible.find(actionname) != visible.end());
734 result = result || (inputfile.find(actionname) != inputfile.end());
735 return result;
736}
737
[7e6b00]738/** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
739 * \return map from short form of action to name of action
740 */
741map <std::string, std::string> MapOfActions::getShortFormToActionMap()
742{
743 map <std::string, std::string> result;
744
745 for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter)
746 result[iter->second] = iter->first;
747
748 return result;
749}
[97ebf8]750
751
752CONSTRUCT_SINGLETON(MapOfActions)
Note: See TracBrowser for help on using the repository browser.