source: src/Actions/MapOfActions.cpp@ 76c0d6

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

Case 'd' is now handled by CommandLineUI (RepeatBoxAction).

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 21.2 KB
Line 
1/*
2 * MapOfActions.cpp
3 *
4 * Created on: 10.05.2010
5 * Author: heber
6 */
7
8using namespace std;
9
10#include "Patterns/Singleton_impl.hpp"
11#include "Actions/MapOfActions.hpp"
12#include "Helpers/Assert.hpp"
13
14#include "CommandLineParser.hpp"
15#include "log.hpp"
16#include "verbose.hpp"
17
18/** Constructor of class MapOfActions.
19 *
20 */
21MapOfActions::MapOfActions()
22{
23 // initialise lookup map
24 CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
25 CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
26 CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
27 CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
28
29 // keys for actions
30 DescriptionMap["add-atom"] = "add atom of specified element";
31 DescriptionMap["bond-table"] = "setting name of the bond length table file";
32 DescriptionMap["bond-file"] = "name of the bond file";
33 DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
34 DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
35 DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
36 DescriptionMap["center-in-box"] = "center all atoms in the domain";
37 DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
38 DescriptionMap["change-element"] = "change the element of an atom";
39 DescriptionMap["change-molname"] = "change the name of a molecule";
40 DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
41 DescriptionMap["default-molname"] = "set the default name of new molecules";
42 DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
43 DescriptionMap["element-db"] = "setting the path where the element databases can be found";
44 DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
45 DescriptionMap["fill-molecule"] = "fill empty space of box with a filler molecule";
46 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
47 DescriptionMap["help"] = "Give this help screen";
48 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
49 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
50 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
51 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
52 DescriptionMap["pair-correlation-point"] = "pair correlation analysis between atoms of a element to a given point";
53 DescriptionMap["pair-correlation-surface"] = "pair correlation analysis between atoms of a given element and a surface";
54 DescriptionMap["parse-xyz"] = "parse xyz file into World";
55 DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
56 DescriptionMap["remove-atom"] = "remove a specified atom";
57 DescriptionMap["remove-sphere"] = "remove sphere of atoms of around a specified atom";
58 DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
59 DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
60 DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
61 DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
62 DescriptionMap["save-bonds"] = "name of the bonds file to write to";
63 DescriptionMap["save-temperature"] = "name of the temperature file to write to";
64 DescriptionMap["scale-box"] = "scale box and atomic positions inside";
65 DescriptionMap["subspace-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
66 DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
67 DescriptionMap["translate-mol"] = "translate molecule by given vector";
68 DescriptionMap["verbose"] = "set verbosity level";
69 DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
70 DescriptionMap["version"] = "show version";
71 // keys for values
72 DescriptionMap["bin-output-file"] = "name of the bin output file";
73 DescriptionMap["bin-end"] = "start of the last bin";
74 DescriptionMap["bin-start"] = "start of the first bin";
75 DescriptionMap["bin-width"] = "width of the bins";
76 DescriptionMap["distance"] = "distance in space";
77 DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
78 DescriptionMap["element"] = "set of elements";
79 DescriptionMap["end-mol"] = "last or end step";
80 DescriptionMap["input"] = "name of input file";
81 DescriptionMap["length"] = "length in space";
82 DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
83 DescriptionMap["MaxDistance"] = "maximum distance in space";
84 DescriptionMap["molecule-by-id"] = "index of a molecule";
85 DescriptionMap["output-file"] = "name of the output file";
86 DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
87 DescriptionMap["position"] = "position in R^3 space";
88 DescriptionMap["start-mol"] = "first or start step";
89
90 // short forms for the actions
91 ShortFormMap["add-atom"] = "a";
92 ShortFormMap["bond-table"] = "g";
93 ShortFormMap["bond-file"] = "A";
94 ShortFormMap["boundary"] = "c";
95 ShortFormMap["change-box"] = "B";
96 ShortFormMap["center-edge"] = "O";
97 ShortFormMap["center-in-box"] = "b";
98 ShortFormMap["change-element"] = "E";
99 ShortFormMap["convex-envelope"] = "o";
100 ShortFormMap["default-molname"] = "X";
101 ShortFormMap["depth-first-search"] = "D";
102 ShortFormMap["element-db"] = "e";
103 ShortFormMap["fastparsing"] = "n";
104 ShortFormMap["fill-molecule"] = "F";
105 ShortFormMap["fragment-mol"] = "f";
106 ShortFormMap["help"] = "h";
107 ShortFormMap["input"] = "i";
108 ShortFormMap["linear-interpolate"] = "L";
109 ShortFormMap["nonconvex-envelope"] = "N";
110 ShortFormMap["pair-correlation"] = "CE";
111 ShortFormMap["pair-correlation-point"] = "CP";
112 ShortFormMap["pair-correlation-surface"] = "CS";
113 ShortFormMap["parse-xyz"] = "p";
114 ShortFormMap["remove-atom"] = "r";
115 ShortFormMap["remove-sphere"] = "R";
116 ShortFormMap["repeat-box"] = "d";
117 ShortFormMap["rotate-to-pas"] = "m";
118 ShortFormMap["save-adjacency"] = "J";
119 ShortFormMap["save-bonds"] = "j";
120 ShortFormMap["save-temperature"] = "S";
121 ShortFormMap["scale-box"] = "s";
122 ShortFormMap["set-basis"] = "M";
123 ShortFormMap["subspace-dissect"] = "I";
124 ShortFormMap["suspend-in-water"] = "U";
125 ShortFormMap["translate-mol"] = "t";
126 ShortFormMap["verbose"] = "v";
127 ShortFormMap["verlet-integrate"] = "P";
128 ShortFormMap["version"] = "V";
129
130 // value types for the actions
131 TypeMap["add-atom"] = Atom;
132 TypeMap["bond-file"] = String;
133 TypeMap["bond-table"] = String;
134 TypeMap["boundary"] = Vector;
135 TypeMap["center-in-box"] = ListOfDoubles;
136 TypeMap["change-box"] = ListOfDoubles;
137 TypeMap["change-element"] = Element;
138 TypeMap["change-molname"] = String;
139 TypeMap["convex-envelope"] = Molecule;
140 TypeMap["default-molname"] = String;
141 TypeMap["depth-first-search"] = Double;
142 TypeMap["element-db"] = String;
143 TypeMap["end-mol"] = Molecule;
144 TypeMap["fastparsing"] = Boolean;
145 TypeMap["fill-molecule"] = String;
146 TypeMap["fragment-mol"] = Molecule;
147 TypeMap["input"] = String;
148 TypeMap["linear-interpolate"] = String;
149 TypeMap["molecular-volume"] = Molecule;
150 TypeMap["nonconvex-envelope"] = Molecule;
151 TypeMap["parse-xyz"] = String;
152 TypeMap["principal-axis-system"] = Axis;
153 TypeMap["remove-atom"] = Atom;
154 TypeMap["remove-sphere"] = Atom;
155 TypeMap["repeat-box"] = Vector;
156 TypeMap["rotate-to-pas"] = Molecule;
157 TypeMap["save-adjacency"] = String;
158 TypeMap["save-bonds"] = String;
159 TypeMap["save-temperature"] = String;
160 TypeMap["scale-box"] = Vector;
161 TypeMap["set-basis"] = String;
162 TypeMap["start-mol"] = Molecule;
163 TypeMap["suspend-in-water"] = Molecule;
164 TypeMap["translate-mol"] = Vector;
165 TypeMap["verlet-integrate"] = String;
166 TypeMap["verbose"] = Integer;
167
168 // value types for the values
169 TypeMap["bin-output-file"] = String;
170 TypeMap["bin-end"] = Double;
171 TypeMap["bin-start"] = Double;
172 TypeMap["distance"] = Double;
173 TypeMap["distances"] = ListOfDoubles;
174 TypeMap["elements"] = Element;
175 TypeMap["elements"] = ListOfElements;
176 TypeMap["length"] = Double;
177 TypeMap["lengths"] = ListOfDoubles;
178 TypeMap["MaxDistance"] = Double;
179 TypeMap["molecule-by-id"] = Molecule;
180 TypeMap["output-file"] = String;
181 TypeMap["periodic"] = Boolean;
182 TypeMap["position"] = Vector;
183
184 // default values for any action that needs one (always string!)
185 DefaultValue["molecule-by-id"] = "-1";
186
187
188 // list of generic actions
189// generic.insert("add-atom");
190// generic.insert("bond-file");
191// generic.insert("bond-table");
192 generic.insert("boundary");
193// generic.insert("bound-in-box");
194 generic.insert("center-edge");
195 generic.insert("center-in-box");
196 generic.insert("change-box");
197// generic.insert("change-molname");
198// generic.insert("change-element");
199// generic.insert("convex-envelope");
200// generic.insert("default-molname");
201// generic.insert("depth-first-search");
202// generic.insert("element-db");
203// generic.insert("fastparsing");
204// generic.insert("fill-molecule");
205// generic.insert("fragment-mol");
206 generic.insert("help");
207// generic.insert("linear-interpolate");
208// generic.insert("molecular-volume");
209// generic.insert("nonconvex-envelope");
210// generic.insert("pair-correlation");
211// generic.insert("pair-correlation-point");
212// generic.insert("pair-correlation-surface");
213// generic.insert("parse-xyz");
214// generic.insert("principal-axis-system");
215// generic.insert("remove-atom");
216// generic.insert("remove-sphere");
217 generic.insert("repeat-box");
218// generic.insert("rotate-to-pas");
219// generic.insert("save-adjacency");
220// generic.insert("save-bonds");
221// generic.insert("save-temperature");
222 generic.insert("scale-box");
223// generic.insert("set-basis");
224// generic.insert("subspace-dissect");
225// generic.insert("suspend-in-water");
226// generic.insert("translate-mol");
227 generic.insert("verbose");
228// generic.insert("verlet-integrate");
229 generic.insert("version");
230// // list of generic values
231// generic.insert("bin-output-file");
232// generic.insert("bin-end");
233// generic.insert("bin-start");
234// generic.insert("distance");
235// generic.insert("distances");
236// generic.insert("element");
237// generic.insert("end-mol");
238 generic.insert("input");
239// generic.insert("length");
240// generic.insert("lengths");
241// generic.insert("MaxDistance");
242// generic.insert("molecule-by-id");
243// generic.insert("output-file");
244// generic.insert("periodic");
245// generic.insert("position");
246// generic.insert("start-mol");
247
248 // positional arguments
249 inputfile.insert("input");
250}
251
252/** Destructor of class MapOfActions.
253 *
254 */
255MapOfActions::~MapOfActions()
256{
257 DescriptionMap.clear();
258}
259
260/** Adds all options to the CommandLineParser.
261 *
262 */
263void MapOfActions::AddOptionsToParser()
264{
265 // add other options
266 for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
267 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
268 if (hasValue(*OptionRunner)) {
269 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner] << " to CommandLineParser." << endl);
270 switch((enum OptionTypes) TypeMap[*OptionRunner]) {
271 default:
272 case None:
273 ListRunner->second->add_options()
274 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
275 ;
276 break;
277 case Boolean:
278 ListRunner->second->add_options()
279 (getKeyAndShortForm(*OptionRunner).c_str(),
280 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
281 po::value< bool >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
282 po::value< bool >(),
283 getDescription(*OptionRunner).c_str())
284 ;
285 break;
286 case Integer:
287 ListRunner->second->add_options()
288 (getKeyAndShortForm(*OptionRunner).c_str(),
289 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
290 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
291 po::value< int >(),
292 getDescription(*OptionRunner).c_str())
293 ;
294 break;
295 case ListOfInts:
296 ListRunner->second->add_options()
297 (getKeyAndShortForm(*OptionRunner).c_str(),
298 po::value< vector<int> >()->multitoken(),
299 getDescription(*OptionRunner).c_str())
300 ;
301 break;
302 case Double:
303 ListRunner->second->add_options()
304 (getKeyAndShortForm(*OptionRunner).c_str(),
305 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
306 po::value< double >()->default_value(atof(DefaultValue[*OptionRunner].c_str())) :
307 po::value< double >(),
308 getDescription(*OptionRunner).c_str())
309 ;
310 break;
311 case ListOfDoubles:
312 ListRunner->second->add_options()
313 (getKeyAndShortForm(*OptionRunner).c_str(),
314 po::value< vector<double> >()->multitoken(),
315 getDescription(*OptionRunner).c_str())
316 ;
317 break;
318 case String:
319 ListRunner->second->add_options()
320 (getKeyAndShortForm(*OptionRunner).c_str(),
321 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
322 po::value< std::string >()->default_value(DefaultValue[*OptionRunner]) :
323 po::value< std::string >(),
324 getDescription(*OptionRunner).c_str())
325 ;
326 break;
327 case Axis:
328 ListRunner->second->add_options()
329 (getKeyAndShortForm(*OptionRunner).c_str(),
330 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
331 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
332 po::value< int >(),
333 getDescription(*OptionRunner).c_str())
334 ;
335 break;
336 case Vector:
337 ListRunner->second->add_options()
338 (getKeyAndShortForm(*OptionRunner).c_str(),
339 po::value< vector<double> >()->multitoken(),
340 getDescription(*OptionRunner).c_str())
341 ;
342 break;
343 case Box:
344 ListRunner->second->add_options()
345 (getKeyAndShortForm(*OptionRunner).c_str(),
346 po::value< vector<double> >(),
347 getDescription(*OptionRunner).c_str())
348 ;
349 break;
350 case Molecule:
351 ListRunner->second->add_options()
352 (getKeyAndShortForm(*OptionRunner).c_str(),
353 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
354 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
355 po::value< int >(),
356 getDescription(*OptionRunner).c_str())
357 ;
358 break;
359 case ListOfMolecules:
360 ListRunner->second->add_options()
361 (getKeyAndShortForm(*OptionRunner).c_str(),
362 po::value< vector<int> >()->multitoken(),
363 getDescription(*OptionRunner).c_str())
364 ;
365 break;
366 case Atom:
367 ListRunner->second->add_options()
368 (getKeyAndShortForm(*OptionRunner).c_str(),
369 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
370 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
371 po::value< int >(),
372 getDescription(*OptionRunner).c_str())
373 ;
374 break;
375 case ListOfAtoms:
376 ListRunner->second->add_options()
377 (getKeyAndShortForm(*OptionRunner).c_str(),
378 po::value< vector<int> >()->multitoken(),
379 getDescription(*OptionRunner).c_str())
380 ;
381 break;
382 case Element:
383 ListRunner->second->add_options()
384 (getKeyAndShortForm(*OptionRunner).c_str(),
385 DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
386 po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
387 po::value< int >(),
388 getDescription(*OptionRunner).c_str())
389 ;
390 break;
391 case ListOfElements:
392 ListRunner->second->add_options()
393 (getKeyAndShortForm(*OptionRunner).c_str(),
394 po::value< vector<int> >()->multitoken(),
395 getDescription(*OptionRunner).c_str())
396 ;
397 break;
398 }
399 } else {
400 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
401 ListRunner->second->add_options()
402 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
403 ;
404 }
405 }
406 }
407 // add positional arguments
408 for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) {
409 DoLog(0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);
410 CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1);
411 }
412 cout << "Name for position 1: " << CommandLineParser::getInstance().inputfile.name_for_position(1) << endl;
413}
414
415/** Getter for MapOfActions:DescriptionMap.
416 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
417 * \param actionname name of the action to lookup
418 * \return Description of the action
419 */
420std::string MapOfActions::getDescription(string actionname)
421{
422 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
423 return DescriptionMap[actionname];
424}
425
426/** Specific Getter for a MapOfActions:ShortFormMap.
427 * If action has a short for, then combination is as "actionname,ShortForm" (this is
428 * the desired format for boost::program_options). If no short form exists in the map,
429 * just actionname will be returned
430 * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
431 * \param actionname name of the action to lookup
432 * \return actionname,ShortForm or Description of the action
433 */
434std::string MapOfActions::getKeyAndShortForm(string actionname)
435{
436 stringstream output;
437 ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
438 output << actionname;
439 if (ShortFormMap.find(actionname) != DescriptionMap.end())
440 output << "," << ShortFormMap[actionname];
441 return output.str();
442}
443
444/** Getter for MapOfActions:ShortFormMap.
445 * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
446 * \param actionname name of the action to lookup
447 * \return ShortForm of the action
448 */
449std::string MapOfActions::getShortForm(string actionname)
450{
451 ASSERT(ShortFormMap.find(actionname) != ShortFormMap.end(), "Unknown action name passed to MapOfActions::getShortForm");
452 return ShortFormMap[actionname];
453}
454
455/** Returns whether the given action needs a value or not.
456 * \param actionname name of the action to look up
457 * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
458 */
459bool MapOfActions::hasValue(string actionname)
460{
461 return (TypeMap.find(actionname) != TypeMap.end());
462}
463
464/** Getter for MapOfActions::TypeMap.
465 * \param actionname name of the action to look up
466 * \return type of the action
467 */
468enum MapOfActions::OptionTypes MapOfActions::getValueType(string actionname)
469{
470 return TypeMap[actionname];
471}
472
473/** Searches whether action is registered with CommandLineParser.
474 * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
475 * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
476 * by this function.
477 * \param shortform command short form to look for
478 * \return true - action has been registered, false - action has not been registered.
479 */
480bool MapOfActions::isShortFormPresent(string shortform)
481{
482 bool result = false;
483 string actionname;
484 for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
485 if (ShortFormRunner->second == shortform) {
486 actionname = ShortFormRunner->first;
487 break;
488 }
489 result = result || (generic.find(actionname) != generic.end());
490 result = result || (config.find(actionname) != config.end());
491 result = result || (hidden.find(actionname) != hidden.end());
492 result = result || (visible.find(actionname) != visible.end());
493 result = result || (inputfile.find(actionname) != inputfile.end());
494 return result;
495}
496
497
498
499CONSTRUCT_SINGLETON(MapOfActions)
Note: See TracBrowser for help on using the repository browser.