source: src/Actions/MapOfActions.cpp@ 6d6b54

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 6d6b54 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

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