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 |
|
---|
8 | /*
|
---|
9 | * MapOfActions.cpp
|
---|
10 | *
|
---|
11 | * Created on: 10.05.2010
|
---|
12 | * Author: heber
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "Helpers/MemDebug.hpp"
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 | #include "Actions/MapOfActions.hpp"
|
---|
25 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
26 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
27 | #include "Helpers/Assert.hpp"
|
---|
28 | #include "Patterns/Singleton_impl.hpp"
|
---|
29 |
|
---|
30 | #include <boost/filesystem.hpp>
|
---|
31 | #include <boost/lexical_cast.hpp>
|
---|
32 | #include <boost/optional.hpp>
|
---|
33 | #include <boost/program_options.hpp>
|
---|
34 |
|
---|
35 | #include <iostream>
|
---|
36 |
|
---|
37 | #include "atom.hpp"
|
---|
38 | #include "Box.hpp"
|
---|
39 | #include "CommandLineParser.hpp"
|
---|
40 | #include "element.hpp"
|
---|
41 | #include "Helpers/Log.hpp"
|
---|
42 | #include "LinearAlgebra/Matrix.hpp"
|
---|
43 | #include "molecule.hpp"
|
---|
44 | #include "periodentafel.hpp"
|
---|
45 | #include "LinearAlgebra/BoxVector.hpp"
|
---|
46 | #include "LinearAlgebra/Vector.hpp"
|
---|
47 | #include "Helpers/Verbose.hpp"
|
---|
48 |
|
---|
49 | #include "Actions/ActionRegistry.hpp"
|
---|
50 | #include "Actions/Values.hpp"
|
---|
51 |
|
---|
52 | void validate(boost::any& v, const std::vector<std::string>& values, VectorValue *, int)
|
---|
53 | {
|
---|
54 | VectorValue VV;
|
---|
55 | std::vector<std::string> components;
|
---|
56 |
|
---|
57 | // split comma-separated values
|
---|
58 | if (values.size() != 1) {
|
---|
59 | cerr << "Not one vector but " << components.size() << " given " << endl;
|
---|
60 | throw boost::program_options::validation_error("Unequal to one vector given");
|
---|
61 | }
|
---|
62 | std::string argument(values.at(0));
|
---|
63 | std::string::iterator Aiter = argument.begin();
|
---|
64 | std::string::iterator Biter = argument.begin();
|
---|
65 | for (; Aiter != argument.end(); ++Aiter) {
|
---|
66 | if (*Aiter == ',') {
|
---|
67 | components.push_back(string(Biter,Aiter));
|
---|
68 | do {
|
---|
69 | Aiter++;
|
---|
70 | } while (*Aiter == ' ' || *Aiter == '\t');
|
---|
71 | Biter = Aiter;
|
---|
72 | }
|
---|
73 | }
|
---|
74 | components.push_back(string(Biter,argument.end()));
|
---|
75 |
|
---|
76 | if (components.size() != 3) {
|
---|
77 | cerr << "Specified vector does not have three components but " << components.size() << endl;
|
---|
78 | throw boost::program_options::validation_error("Specified vector does not have three components");
|
---|
79 | }
|
---|
80 | VV.x = boost::lexical_cast<double>(components.at(0));
|
---|
81 | VV.y = boost::lexical_cast<double>(components.at(1));
|
---|
82 | VV.z = boost::lexical_cast<double>(components.at(2));
|
---|
83 | v = boost::any(VectorValue(VV));
|
---|
84 | }
|
---|
85 |
|
---|
86 | void validate(boost::any& v, const std::vector<std::string>& values, BoxValue *, int)
|
---|
87 | {
|
---|
88 | BoxValue BV;
|
---|
89 | std::vector<std::string> components;
|
---|
90 |
|
---|
91 | // split comma-separated values
|
---|
92 | if (values.size() != 1) {
|
---|
93 | cerr << "Not one vector but " << components.size() << " given " << endl;
|
---|
94 | throw boost::program_options::validation_error("Unequal to one vector given");
|
---|
95 | }
|
---|
96 | std::string argument(values.at(0));
|
---|
97 | std::string::iterator Aiter = argument.begin();
|
---|
98 | std::string::iterator Biter = argument.begin();
|
---|
99 | for (; Aiter != argument.end(); ++Aiter) {
|
---|
100 | if (*Aiter == ',') {
|
---|
101 | components.push_back(string(Biter,Aiter));
|
---|
102 | do {
|
---|
103 | Aiter++;
|
---|
104 | } while (*Aiter == ' ' || *Aiter == '\t');
|
---|
105 | Biter = Aiter;
|
---|
106 | }
|
---|
107 | }
|
---|
108 | components.push_back(string(Biter,argument.end()));
|
---|
109 |
|
---|
110 | if (components.size() != 6) {
|
---|
111 | cerr << "Specified vector does not have three components but " << components.size() << endl;
|
---|
112 | throw boost::program_options::validation_error("Specified symmetric box matrix does not have six components");
|
---|
113 | }
|
---|
114 | BV.xx = boost::lexical_cast<double>(components.at(0));
|
---|
115 | BV.yx = boost::lexical_cast<double>(components.at(1));
|
---|
116 | BV.yy = boost::lexical_cast<double>(components.at(2));
|
---|
117 | BV.zx = boost::lexical_cast<double>(components.at(3));
|
---|
118 | BV.zy = boost::lexical_cast<double>(components.at(4));
|
---|
119 | BV.zz = boost::lexical_cast<double>(components.at(5));
|
---|
120 | v = boost::any(BoxValue(BV));
|
---|
121 | }
|
---|
122 |
|
---|
123 | void validate(boost::any& v, const std::vector<std::string>& values, boost::filesystem::path *, int)
|
---|
124 | {
|
---|
125 | boost::filesystem::path filename;
|
---|
126 | std::vector<std::string> components;
|
---|
127 |
|
---|
128 | std::cout << "boost::filesystem::path validator used." << std::endl;
|
---|
129 |
|
---|
130 | // split comma-separated values
|
---|
131 | if (values.size() != 1) {
|
---|
132 | cerr << "Not one file but " << components.size() << " given " << endl;
|
---|
133 | throw boost::program_options::validation_error("Unequal to one file given");
|
---|
134 | }
|
---|
135 | filename = values.at(0);
|
---|
136 | v = boost::any(boost::filesystem::path(filename));
|
---|
137 | }
|
---|
138 |
|
---|
139 | /** Constructor of class MapOfActions.
|
---|
140 | *
|
---|
141 | */
|
---|
142 | MapOfActions::MapOfActions()
|
---|
143 | {
|
---|
144 | // initialise lookup map
|
---|
145 | CmdParserLookup[&generic] = &(CommandLineParser::getInstance().generic);
|
---|
146 | CmdParserLookup[&config] = &(CommandLineParser::getInstance().config);
|
---|
147 | CmdParserLookup[&hidden] = &(CommandLineParser::getInstance().hidden);
|
---|
148 | CmdParserLookup[&visible] = &(CommandLineParser::getInstance().visible);
|
---|
149 |
|
---|
150 | // keys for actions
|
---|
151 | DescriptionMap["add-atom"] = "add atom of specified element";
|
---|
152 | DescriptionMap["bond-table"] = "setting name of the bond length table file";
|
---|
153 | DescriptionMap["bond-file"] = "name of the bond file";
|
---|
154 | DescriptionMap["boundary"] = "change box to add an empty boundary around all atoms";
|
---|
155 | DescriptionMap["bound-in-box"] = "bound all atoms in the domain";
|
---|
156 | DescriptionMap["center-edge"] = "center edge of all atoms on (0,0,0)";
|
---|
157 | DescriptionMap["center-in-box"] = "center all atoms in the domain";
|
---|
158 | DescriptionMap["change-box"] = "change the symmetrc matrix of the simulation domain";
|
---|
159 | DescriptionMap["change-element"] = "change the element of an atom";
|
---|
160 | DescriptionMap["change-molname"] = "change the name of a molecule";
|
---|
161 | DescriptionMap["clear-atom-selection"] = "clear the atom selection";
|
---|
162 | DescriptionMap["clear-molecule-selection"] = "clear the molecule selection";
|
---|
163 | DescriptionMap["construct-bondgraph"] = "construct the bond graph of the selected atoms";
|
---|
164 | DescriptionMap["convex-envelope"] = "create the convex envelope for a molecule";
|
---|
165 | DescriptionMap["copy-molecule"] = "copies a molecule with all atoms and bonds";
|
---|
166 | DescriptionMap["default-molname"] = "set the default name of new molecules";
|
---|
167 | DescriptionMap["depth-first-search"] = "Depth-First Search analysis of the molecular system";
|
---|
168 | DescriptionMap["element-db"] = "setting the path where the element databases can be found";
|
---|
169 | DescriptionMap["fastparsing"] = "setting whether trajectories shall be parsed completely (n) or just first step (y)";
|
---|
170 | DescriptionMap["fill-molecule"] = "fill around molecules' surface with a filler molecule";
|
---|
171 | DescriptionMap["fill-void"] = "fill void space of box with a filler molecule";
|
---|
172 | DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order";
|
---|
173 | DescriptionMap["help"] = "help screen";
|
---|
174 | DescriptionMap["input"] = "specify input files";
|
---|
175 | DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule";
|
---|
176 | DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule";
|
---|
177 | DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule";
|
---|
178 | DescriptionMap["output"] = "write output files";
|
---|
179 | DescriptionMap["set-output"] = "specify output formats";
|
---|
180 | DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements";
|
---|
181 | DescriptionMap["parse-xyz"] = "parse xyz file into World";
|
---|
182 | DescriptionMap["point-correlation"] = "pair correlation analysis between element and point";
|
---|
183 | DescriptionMap["principal-axis-system"] = "calculate the principal axis system of the specified molecule";
|
---|
184 | DescriptionMap["redo"] = "redo last action";
|
---|
185 | DescriptionMap["remove-atom"] = "remove a specified atom";
|
---|
186 | DescriptionMap["repeat-box"] = "create periodic copies of the simulation box per axis";
|
---|
187 | DescriptionMap["rotate-origin"] = "rotate selected atoms by a specific angle around origin";
|
---|
188 | DescriptionMap["rotate-self"] = "rotates molecules by a specific angle around own center of gravity";
|
---|
189 | DescriptionMap["rotate-to-pas"] = "calculate the principal axis system of the specified molecule and rotate specified axis to align with main axis";
|
---|
190 | DescriptionMap["save-adjacency"] = "name of the adjacency file to write to";
|
---|
191 | DescriptionMap["save-bonds"] = "name of the bonds file to write to";
|
---|
192 | DescriptionMap["save-temperature"] = "name of the temperature file to write to";
|
---|
193 | DescriptionMap["SaveXyz"] = "save world as xyz file";
|
---|
194 | DescriptionMap["scale-box"] = "scale box and atomic positions inside";
|
---|
195 | DescriptionMap["select-all-atoms"] = "select all atoms";
|
---|
196 | DescriptionMap["select-all-molecules"] = "select all molecules";
|
---|
197 | DescriptionMap["select-atom-by-element"] = "select an atom by element";
|
---|
198 | DescriptionMap["select-atom-by-id"] = "select an atom by index";
|
---|
199 | DescriptionMap["select-atoms-inside-cuboid"] = "select all atoms inside a cuboid";
|
---|
200 | DescriptionMap["select-atoms-inside-sphere"] = "select all atoms inside a sphere";
|
---|
201 | DescriptionMap["select-molecule-by-id"] = "select a molecule by index";
|
---|
202 | DescriptionMap["select-molecule-by-formula"] = "select a molecule by chemical formula";
|
---|
203 | DescriptionMap["select-molecule-of-atom"] = "select a molecule to which a given atom belongs";
|
---|
204 | DescriptionMap["select-molecules-atoms"] = "select all atoms of a molecule";
|
---|
205 | DescriptionMap["set-basis"] = "set the name of the gaussian basis set for MPQC";
|
---|
206 | DescriptionMap["set-output"] = "specify output formats";
|
---|
207 | DescriptionMap["subgraph-dissect"] = "dissect the molecular system into molecules representing disconnected subgraphs";
|
---|
208 | DescriptionMap["surface-correlation"] = "pair correlation analysis between element and surface";
|
---|
209 | DescriptionMap["suspend-in-water"] = "suspend the given molecule in water such that in the domain the mean density is as specified";
|
---|
210 | DescriptionMap["translate-atoms"] = "translate all selected atoms by given vector";
|
---|
211 | DescriptionMap["undo"] = "undo last action";
|
---|
212 | DescriptionMap["unselect-all-atoms"] = "unselect all atoms";
|
---|
213 | DescriptionMap["unselect-all-molecules"] = "unselect all molecules";
|
---|
214 | DescriptionMap["unselect-atom-by-element"] = "unselect an atom by element";
|
---|
215 | DescriptionMap["unselect-atom-by-id"] = "unselect an atom by index";
|
---|
216 | DescriptionMap["unselect-atoms-inside-cuboid"] = "unselect all atoms inside a cuboid";
|
---|
217 | DescriptionMap["unselect-atoms-inside-sphere"] = "unselect all atoms inside a sphere";
|
---|
218 | DescriptionMap["unselect-molecule-by-formula"] = "unselect a molecule by chemical formula";
|
---|
219 | DescriptionMap["unselect-molecule-by-id"] = "unselect a molecule by index";
|
---|
220 | DescriptionMap["unselect-molecule-of-atom"] = "unselect a molecule to which a given atom belongs";
|
---|
221 | DescriptionMap["unselect-molecules-atoms"] = "unselect all atoms of a molecule";
|
---|
222 | DescriptionMap["verbose"] = "set verbosity level";
|
---|
223 | DescriptionMap["verlet-integrate"] = "perform verlet integration of a given force file";
|
---|
224 | DescriptionMap["version"] = "show version";
|
---|
225 | DescriptionMap["warranty"] = "statement concerning warranty of the software";
|
---|
226 | // keys for values
|
---|
227 | DescriptionMap["angle-x"] = "angle of a rotation around x axis";
|
---|
228 | DescriptionMap["angle-y"] = "angle of a rotation around y axis";
|
---|
229 | DescriptionMap["angle-z"] = "angle of a rotation around z axis";
|
---|
230 | DescriptionMap["bin-output-file"] = "name of the bin output file";
|
---|
231 | DescriptionMap["bin-end"] = "start of the last bin";
|
---|
232 | DescriptionMap["bin-start"] = "start of the first bin";
|
---|
233 | DescriptionMap["bin-width"] = "width of the bins";
|
---|
234 | DescriptionMap["convex-file"] = "filename of the non-convex envelope";
|
---|
235 | DescriptionMap["distance"] = "distance in space";
|
---|
236 | DescriptionMap["distances"] = "list of three of distances in space, one for each axis direction";
|
---|
237 | DescriptionMap["DoRotate"] = "whether to rotate or just report angles";
|
---|
238 | DescriptionMap["element"] = "single element";
|
---|
239 | DescriptionMap["elements"] = "set of elements";
|
---|
240 | DescriptionMap["end-step"] = "last or end step";
|
---|
241 | DescriptionMap["id-mapping"] = "whether the identity shall be used in mapping atoms onto atoms or some closest distance measure shall be used";
|
---|
242 | DescriptionMap["input"] = "name of input file";
|
---|
243 | DescriptionMap["length"] = "length in space";
|
---|
244 | DescriptionMap["lengths"] = "list of three of lengths in space, one for each axis direction";
|
---|
245 | DescriptionMap["MaxDistance"] = "maximum distance in space";
|
---|
246 | DescriptionMap["molecule-by-id"] = "index of a molecule";
|
---|
247 | DescriptionMap["nonconvex-file"] = "filename of the non-convex envelope";
|
---|
248 | DescriptionMap["order"] = "order of a discretization, dissection, ...";
|
---|
249 | DescriptionMap["output-file"] = "name of the output file";
|
---|
250 | DescriptionMap["periodic"] = "system is constraint to periodic boundary conditions (y/n)";
|
---|
251 | DescriptionMap["position"] = "position in R^3 space";
|
---|
252 | DescriptionMap["start-step"] = "first or start step";
|
---|
253 |
|
---|
254 | // short forms for the actions
|
---|
255 | ShortFormMap["add-atom"] = "a";
|
---|
256 | ShortFormMap["bond-table"] = "g";
|
---|
257 | ShortFormMap["bond-file"] = "A";
|
---|
258 | ShortFormMap["boundary"] = "c";
|
---|
259 | ShortFormMap["change-box"] = "B";
|
---|
260 | ShortFormMap["center-edge"] = "O";
|
---|
261 | ShortFormMap["center-in-box"] = "b";
|
---|
262 | ShortFormMap["change-element"] = "E";
|
---|
263 | // ShortFormMap["convex-envelope"] = "x";
|
---|
264 | ShortFormMap["default-molname"] = "X";
|
---|
265 | ShortFormMap["depth-first-search"] = "D";
|
---|
266 | ShortFormMap["element-db"] = "e";
|
---|
267 | ShortFormMap["fastparsing"] = "n";
|
---|
268 | ShortFormMap["fill-molecule"] = "F";
|
---|
269 | ShortFormMap["fragment-mol"] = "f";
|
---|
270 | ShortFormMap["help"] = "h";
|
---|
271 | ShortFormMap["input"] = "i";
|
---|
272 | ShortFormMap["linear-interpolate"] = "L";
|
---|
273 | ShortFormMap["nonconvex-envelope"] = "N";
|
---|
274 | // ShortFormMap["output"] = "o";
|
---|
275 | // ShortFormMap["pair-correlation"] = "C";
|
---|
276 | ShortFormMap["parse-xyz"] = "p";
|
---|
277 | ShortFormMap["remove-atom"] = "r";
|
---|
278 | ShortFormMap["repeat-box"] = "d";
|
---|
279 | ShortFormMap["rotate-to-pas"] = "m";
|
---|
280 | ShortFormMap["save-adjacency"] = "J";
|
---|
281 | ShortFormMap["save-bonds"] = "j";
|
---|
282 | ShortFormMap["save-temperature"] = "S";
|
---|
283 | ShortFormMap["scale-box"] = "s";
|
---|
284 | ShortFormMap["set-basis"] = "M";
|
---|
285 | ShortFormMap["set-output"] = "o";
|
---|
286 | ShortFormMap["subgraph-dissect"] = "I";
|
---|
287 | ShortFormMap["suspend-in-water"] = "u";
|
---|
288 | ShortFormMap["translate-atoms"] = "t";
|
---|
289 | ShortFormMap["verbose"] = "v";
|
---|
290 | ShortFormMap["verlet-integrate"] = "P";
|
---|
291 | ShortFormMap["version"] = "V";
|
---|
292 |
|
---|
293 | // value types for the actions
|
---|
294 | TypeMap["add-atom"] = &typeid(const element);
|
---|
295 | TypeMap["bond-file"] = &typeid(std::string);
|
---|
296 | TypeMap["bond-table"] = &typeid(std::string);
|
---|
297 | TypeMap["boundary"] = &typeid(VectorValue);
|
---|
298 | TypeMap["center-in-box"] = &typeid(BoxValue);
|
---|
299 | TypeMap["change-box"] = &typeid(BoxValue);
|
---|
300 | TypeMap["change-element"] = &typeid(const element);
|
---|
301 | TypeMap["change-molname"] = &typeid(std::string);
|
---|
302 | TypeMap["clear-atom-selection"] = &typeid(void);
|
---|
303 | TypeMap["clear-molecule-selection"] = &typeid(void);
|
---|
304 | TypeMap["construct-bondgraph"] = &typeid(void);
|
---|
305 | TypeMap["convex-envelope"] = &typeid(void);
|
---|
306 | TypeMap["copy-molecule"] = &typeid(molecule);
|
---|
307 | TypeMap["default-molname"] = &typeid(std::string);
|
---|
308 | TypeMap["depth-first-search"] = &typeid(double);
|
---|
309 | TypeMap["element-db"] = &typeid(std::string);
|
---|
310 | TypeMap["fastparsing"] = &typeid(bool);
|
---|
311 | TypeMap["fill-molecule"] = &typeid(std::string);
|
---|
312 | TypeMap["fill-void"] = &typeid(std::string);
|
---|
313 | TypeMap["fragment-mol"] = &typeid(std::string);
|
---|
314 | TypeMap["input"] = &typeid(boost::filesystem::path);
|
---|
315 | TypeMap["linear-interpolate"] = &typeid(std::string);
|
---|
316 | TypeMap["molecular-volume"] = &typeid(molecule);
|
---|
317 | TypeMap["nonconvex-envelope"] = &typeid(double);
|
---|
318 | TypeMap["output"] = &typeid(void);
|
---|
319 | TypeMap["parse-xyz"] = &typeid(std::string);
|
---|
320 | TypeMap["pair-correlation"] = &typeid(void);
|
---|
321 | TypeMap["point-correlation"] = &typeid(void);
|
---|
322 | TypeMap["principal-axis-system"] = &typeid(void);
|
---|
323 | TypeMap["redo"] = &typeid(void);
|
---|
324 | TypeMap["remove-atom"] = &typeid(void);
|
---|
325 | TypeMap["repeat-box"] = &typeid(VectorValue);
|
---|
326 | TypeMap["rotate-origin"] = &typeid(double);
|
---|
327 | TypeMap["rotate-self"] = &typeid(double);
|
---|
328 | TypeMap["rotate-to-pas"] = &typeid(VectorValue);
|
---|
329 | TypeMap["save-adjacency"] = &typeid(std::string);
|
---|
330 | TypeMap["save-bonds"] = &typeid(std::string);
|
---|
331 | TypeMap["save-temperature"] = &typeid(std::string);
|
---|
332 | TypeMap["scale-box"] = &typeid(VectorValue);
|
---|
333 | TypeMap["select-all-atoms"] = &typeid(void);
|
---|
334 | TypeMap["select-all-molecules"] = &typeid(void);
|
---|
335 | TypeMap["select-atom-by-element"] = &typeid(const element);
|
---|
336 | TypeMap["select-atom-by-id"] = &typeid(atom);
|
---|
337 | TypeMap["select-atoms-inside-cuboid"] = &typeid(VectorValue);
|
---|
338 | TypeMap["select-atoms-inside-sphere"] = &typeid(double);
|
---|
339 | TypeMap["select-molecule-by-formula"] = &typeid(std::string);
|
---|
340 | TypeMap["select-molecule-by-id"] = &typeid(molecule);
|
---|
341 | TypeMap["select-molecule-of-atom"] = &typeid(atom);
|
---|
342 | TypeMap["select-molecules-atoms"] = &typeid(molecule);
|
---|
343 | TypeMap["set-basis"] = &typeid(std::string);
|
---|
344 | TypeMap["set-output"] = &typeid(std::vector<std::string>);
|
---|
345 | TypeMap["subgraph-dissect"] = &typeid(void);
|
---|
346 | TypeMap["surface-correlation"] = &typeid(void);
|
---|
347 | TypeMap["suspend-in-water"] = &typeid(double);
|
---|
348 | TypeMap["translate-atoms"] = &typeid(VectorValue);
|
---|
349 | TypeMap["undo"] = &typeid(void);
|
---|
350 | TypeMap["unselect-all-atoms"] = &typeid(void);
|
---|
351 | TypeMap["unselect-all-molecules"] = &typeid(void);
|
---|
352 | TypeMap["unselect-atom-by-element"] = &typeid(const element);
|
---|
353 | TypeMap["unselect-atom-by-id"] = &typeid(atom);
|
---|
354 | TypeMap["unselect-atoms-inside-cuboid"] = &typeid(VectorValue);
|
---|
355 | TypeMap["unselect-atoms-inside-sphere"] = &typeid(double);
|
---|
356 | TypeMap["unselect-molecule-by-formula"] = &typeid(std::string);
|
---|
357 | TypeMap["unselect-molecule-by-id"] = &typeid(molecule);
|
---|
358 | TypeMap["unselect-molecule-of-atom"] = &typeid(atom);
|
---|
359 | TypeMap["unselect-molecules-atoms"] = &typeid(molecule);
|
---|
360 | TypeMap["verlet-integrate"] = &typeid(std::string);
|
---|
361 | TypeMap["verbose"] = &typeid(int);
|
---|
362 |
|
---|
363 | // value types for the values
|
---|
364 | TypeMap["angle-x"] = &typeid(double);
|
---|
365 | TypeMap["angle-y"] = &typeid(double);
|
---|
366 | TypeMap["angle-z"] = &typeid(double);
|
---|
367 | TypeMap["bin-output-file"] = &typeid(std::string);
|
---|
368 | TypeMap["bin-end"] = &typeid(double);
|
---|
369 | TypeMap["bin-start"] = &typeid(double);
|
---|
370 | TypeMap["bin-width"] = &typeid(double);
|
---|
371 | TypeMap["convex-file"] = &typeid(std::string);
|
---|
372 | TypeMap["distance"] = &typeid(double);
|
---|
373 | TypeMap["distances"] = &typeid(VectorValue);
|
---|
374 | TypeMap["DoRotate"] = &typeid(bool);
|
---|
375 | TypeMap["element"] = &typeid(const element);
|
---|
376 | TypeMap["elements"] = &typeid(std::vector<const element *>);
|
---|
377 | TypeMap["end-step"] = &typeid(int);
|
---|
378 | TypeMap["id-mapping"] = &typeid(bool);
|
---|
379 | TypeMap["length"] = &typeid(double);
|
---|
380 | TypeMap["lengths"] = &typeid(VectorValue);
|
---|
381 | TypeMap["MaxDistance"] = &typeid(double);
|
---|
382 | TypeMap["molecule-by-id"] = &typeid(molecule);
|
---|
383 | TypeMap["nonconvex-file"] = &typeid(std::string);
|
---|
384 | TypeMap["order"] = &typeid(int);
|
---|
385 | TypeMap["output-file"] = &typeid(std::string);
|
---|
386 | TypeMap["periodic"] = &typeid(bool);
|
---|
387 | TypeMap["position"] = &typeid(VectorValue);
|
---|
388 | TypeMap["start-step"] = &typeid(int);
|
---|
389 |
|
---|
390 | TypeEnumMap[&typeid(void)] = None;
|
---|
391 | TypeEnumMap[&typeid(bool)] = Boolean;
|
---|
392 | TypeEnumMap[&typeid(int)] = Integer;
|
---|
393 | TypeEnumMap[&typeid(boost::filesystem::path)] = File;
|
---|
394 | TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers;
|
---|
395 | TypeEnumMap[&typeid(double)] = Double;
|
---|
396 | TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles;
|
---|
397 | TypeEnumMap[&typeid(std::string)] = String;
|
---|
398 | TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings;
|
---|
399 | TypeEnumMap[&typeid(VectorValue)] = Vector;
|
---|
400 | TypeEnumMap[&typeid(std::vector<VectorValue>)] = ListOfVectors;
|
---|
401 | TypeEnumMap[&typeid(BoxValue)] = Box;
|
---|
402 | TypeEnumMap[&typeid(molecule)] = Molecule;
|
---|
403 | TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules;
|
---|
404 | TypeEnumMap[&typeid(atom)] = Atom;
|
---|
405 | TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms;
|
---|
406 | TypeEnumMap[&typeid(const element)] = Element;
|
---|
407 | TypeEnumMap[&typeid(std::vector<const element *>)] = ListOfElements;
|
---|
408 |
|
---|
409 | // default values for any action that needs one (always string!)
|
---|
410 | CurrentValueMap["bin-width"] = "0.5";
|
---|
411 | CurrentValueMap["fastparsing"] = "0";
|
---|
412 | CurrentValueMap["periodic"] = "0";
|
---|
413 |
|
---|
414 | // put action into each menu category
|
---|
415 | MenuDescription["analysis"] = pair<std::string,std::string>("Analysis (pair correlation, volume)", "Analysis");
|
---|
416 | MenuDescription["atom"] = pair<std::string,std::string>("Edit atoms", "Atoms");
|
---|
417 | MenuDescription["command"] = pair<std::string,std::string>("Configuration", "configuration options");
|
---|
418 | MenuDescription["fragmentation"] = pair<std::string,std::string>("Fragmentation", "Fragmentation");
|
---|
419 | MenuDescription["molecule"] = pair<std::string,std::string>("Parse files into system", "Molecules");
|
---|
420 | MenuDescription["parser"] = pair<std::string,std::string>("Edit molecules (load, parse, save)", "Input/Output");
|
---|
421 | MenuDescription["selection"] = pair<std::string,std::string>("Select atoms/molecules", "Selection");
|
---|
422 | MenuDescription["tesselation"] = pair<std::string,std::string>("Tesselate molecules", "Tesselation");
|
---|
423 | MenuDescription["world"] = pair<std::string,std::string>("Edit world", "Globals");
|
---|
424 |
|
---|
425 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "molecular-volume") );
|
---|
426 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "pair-correlation") );
|
---|
427 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "point-correlation") );
|
---|
428 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "surface-correlation") );
|
---|
429 | MenuContainsActionMap.insert( pair<std::string, std::string> ("analysis", "principal-axis-system") );
|
---|
430 |
|
---|
431 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "add-atom") );
|
---|
432 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "change-element") );
|
---|
433 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "remove-atom") );
|
---|
434 | MenuContainsActionMap.insert( pair<std::string, std::string> ("atom", "translate-atoms") );
|
---|
435 |
|
---|
436 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "bond-table") );
|
---|
437 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "element-db") );
|
---|
438 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "fastparsing") );
|
---|
439 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "help") );
|
---|
440 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "verbose") );
|
---|
441 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "version") );
|
---|
442 | MenuContainsActionMap.insert( pair<std::string, std::string> ("command", "warranty") );
|
---|
443 |
|
---|
444 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "construct-bondgraph") );
|
---|
445 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "depth-first-search") );
|
---|
446 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "fragment-mol") );
|
---|
447 | MenuContainsActionMap.insert( pair<std::string, std::string> ("fragmentation", "subgraph-dissect") );
|
---|
448 |
|
---|
449 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "bond-file") );
|
---|
450 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "copy-molecule") );
|
---|
451 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "change-molname") );
|
---|
452 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-molecule") );
|
---|
453 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "fill-void") );
|
---|
454 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "linear-interpolate") );
|
---|
455 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-origin") );
|
---|
456 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-self") );
|
---|
457 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "rotate-to-pas") );
|
---|
458 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-adjacency") );
|
---|
459 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-bonds") );
|
---|
460 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "save-temperature") );
|
---|
461 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "suspend-in-water") );
|
---|
462 | MenuContainsActionMap.insert( pair<std::string, std::string> ("molecule", "verlet-integrate") );
|
---|
463 |
|
---|
464 | MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "parse-xyz") );
|
---|
465 | MenuContainsActionMap.insert( pair<std::string, std::string> ("parser", "SaveXyz") );
|
---|
466 |
|
---|
467 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-atom-selection") );
|
---|
468 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "clear-molecule-selection") );
|
---|
469 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-atoms") );
|
---|
470 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-all-molecules") );
|
---|
471 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-element") );
|
---|
472 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atom-by-id") );
|
---|
473 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-cuboid") );
|
---|
474 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-atoms-inside-sphere") );
|
---|
475 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-id") );
|
---|
476 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-by-formula") );
|
---|
477 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecule-of-atom") );
|
---|
478 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "select-molecules-atoms") );
|
---|
479 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-atoms") );
|
---|
480 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-all-molecules") );
|
---|
481 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-element") );
|
---|
482 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atom-by-id") );
|
---|
483 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-cuboid") );
|
---|
484 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-atoms-inside-sphere") );
|
---|
485 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-formula") );
|
---|
486 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-by-id") );
|
---|
487 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecule-of-atom") );
|
---|
488 | MenuContainsActionMap.insert( pair<std::string, std::string> ("selection", "unselect-molecules-atoms") );
|
---|
489 |
|
---|
490 | MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "convex-envelope") );
|
---|
491 | MenuContainsActionMap.insert( pair<std::string, std::string> ("tesselation", "nonconvex-envelope") );
|
---|
492 |
|
---|
493 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "boundary") );
|
---|
494 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "bound-in-box") );
|
---|
495 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-in-box") );
|
---|
496 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "center-edge") );
|
---|
497 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "change-box") );
|
---|
498 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "input") );
|
---|
499 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "output") );
|
---|
500 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "repeat-box") );
|
---|
501 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "scale-box") );
|
---|
502 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "default-molname") );
|
---|
503 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-basis") );
|
---|
504 | MenuContainsActionMap.insert( pair<std::string, std::string> ("world", "set-output") );
|
---|
505 |
|
---|
506 | // put actions into command line category
|
---|
507 | generic.insert("add-atom");
|
---|
508 | generic.insert("bond-file");
|
---|
509 | generic.insert("bond-table");
|
---|
510 | generic.insert("boundary");
|
---|
511 | // generic.insert("bound-in-box");
|
---|
512 | generic.insert("center-edge");
|
---|
513 | generic.insert("center-in-box");
|
---|
514 | generic.insert("change-box");
|
---|
515 | // generic.insert("change-molname");
|
---|
516 | generic.insert("change-element");
|
---|
517 | generic.insert("clear-atom-selection");
|
---|
518 | generic.insert("clear-molecule-selection");
|
---|
519 | generic.insert("construct-bondgraph");
|
---|
520 | generic.insert("convex-envelope");
|
---|
521 | generic.insert("copy-molecule");
|
---|
522 | generic.insert("default-molname");
|
---|
523 | generic.insert("depth-first-search");
|
---|
524 | generic.insert("element-db");
|
---|
525 | generic.insert("fastparsing");
|
---|
526 | generic.insert("fill-molecule");
|
---|
527 | generic.insert("fill-void");
|
---|
528 | generic.insert("fragment-mol");
|
---|
529 | generic.insert("help");
|
---|
530 | generic.insert("input");
|
---|
531 | generic.insert("linear-interpolate");
|
---|
532 | // generic.insert("molecular-volume");
|
---|
533 | generic.insert("nonconvex-envelope");
|
---|
534 | generic.insert("output");
|
---|
535 | generic.insert("pair-correlation");
|
---|
536 | generic.insert("parse-xyz");
|
---|
537 | generic.insert("point-correlation");
|
---|
538 | // generic.insert("principal-axis-system");
|
---|
539 | generic.insert("redo");
|
---|
540 | generic.insert("remove-atom");
|
---|
541 | generic.insert("repeat-box");
|
---|
542 | generic.insert("rotate-origin");
|
---|
543 | generic.insert("rotate-self");
|
---|
544 | generic.insert("rotate-to-pas");
|
---|
545 | generic.insert("save-adjacency");
|
---|
546 | generic.insert("save-bonds");
|
---|
547 | generic.insert("save-temperature");
|
---|
548 | generic.insert("scale-box");
|
---|
549 | generic.insert("select-all-atoms");
|
---|
550 | generic.insert("select-all-molecules");
|
---|
551 | generic.insert("select-atom-by-element");
|
---|
552 | generic.insert("select-atom-by-id");
|
---|
553 | generic.insert("select-atoms-inside-cuboid");
|
---|
554 | generic.insert("select-atoms-inside-sphere");
|
---|
555 | generic.insert("select-molecule-by-id");
|
---|
556 | generic.insert("select-molecule-by-formula");
|
---|
557 | generic.insert("select-molecule-of-atom");
|
---|
558 | generic.insert("select-molecules-atoms");
|
---|
559 | generic.insert("set-basis");
|
---|
560 | generic.insert("set-output");
|
---|
561 | generic.insert("subgraph-dissect");
|
---|
562 | generic.insert("surface-correlation");
|
---|
563 | generic.insert("suspend-in-water");
|
---|
564 | generic.insert("translate-atoms");
|
---|
565 | generic.insert("undo");
|
---|
566 | generic.insert("unselect-all-atoms");
|
---|
567 | generic.insert("unselect-all-molecules");
|
---|
568 | generic.insert("unselect-atom-by-element");
|
---|
569 | generic.insert("unselect-atom-by-id");
|
---|
570 | generic.insert("unselect-atoms-inside-cuboid");
|
---|
571 | generic.insert("unselect-atoms-inside-sphere");
|
---|
572 | generic.insert("unselect-molecule-by-formula");
|
---|
573 | generic.insert("unselect-molecule-by-id");
|
---|
574 | generic.insert("unselect-molecule-of-atom");
|
---|
575 | generic.insert("unselect-molecules-atoms");
|
---|
576 | generic.insert("verbose");
|
---|
577 | generic.insert("verlet-integrate");
|
---|
578 | generic.insert("version");
|
---|
579 | generic.insert("warranty");
|
---|
580 |
|
---|
581 | // positional arguments
|
---|
582 | generic.insert("input");
|
---|
583 |
|
---|
584 | // hidden arguments
|
---|
585 | hidden.insert("angle-x");
|
---|
586 | hidden.insert("angle-y");
|
---|
587 | hidden.insert("angle-z");
|
---|
588 | hidden.insert("bin-end");
|
---|
589 | hidden.insert("bin-output-file");
|
---|
590 | hidden.insert("bin-start");
|
---|
591 | hidden.insert("bin-width");
|
---|
592 | hidden.insert("convex-file");
|
---|
593 | hidden.insert("distance");
|
---|
594 | hidden.insert("DoRotate");
|
---|
595 | hidden.insert("distances");
|
---|
596 | hidden.insert("element");
|
---|
597 | hidden.insert("elements");
|
---|
598 | hidden.insert("end-step");
|
---|
599 | hidden.insert("id-mapping");
|
---|
600 | hidden.insert("lengths");
|
---|
601 | hidden.insert("MaxDistance");
|
---|
602 | hidden.insert("molecule-by-id");
|
---|
603 | hidden.insert("nonconvex-file");
|
---|
604 | hidden.insert("order");
|
---|
605 | hidden.insert("output-file");
|
---|
606 | hidden.insert("periodic");
|
---|
607 | hidden.insert("position");
|
---|
608 | hidden.insert("start-step");
|
---|
609 | }
|
---|
610 |
|
---|
611 | /** Destructor of class MapOfActions.
|
---|
612 | *
|
---|
613 | */
|
---|
614 | MapOfActions::~MapOfActions()
|
---|
615 | {
|
---|
616 | DescriptionMap.clear();
|
---|
617 | }
|
---|
618 |
|
---|
619 | bool MapOfActions::isCurrentValuePresent(const char *name) const
|
---|
620 | {
|
---|
621 | return (CurrentValueMap.find(name) != CurrentValueMap.end());
|
---|
622 | }
|
---|
623 |
|
---|
624 | void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
|
---|
625 | {
|
---|
626 | int atomID = -1;
|
---|
627 | if (typeid( atom ) == *TypeMap[name]) {
|
---|
628 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
629 | throw MissingValueException(__FILE__, __LINE__);
|
---|
630 | atomID = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
631 | CurrentValueMap.erase(name);
|
---|
632 | } else
|
---|
633 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
634 | _T = World::getInstance().getAtom(AtomById(atomID));
|
---|
635 | }
|
---|
636 |
|
---|
637 | void MapOfActions::queryCurrentValue(const char * name, const element * &_T) {
|
---|
638 | int Z = -1;
|
---|
639 | if (typeid(const element ) == *TypeMap[name]) {
|
---|
640 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
641 | throw MissingValueException(__FILE__, __LINE__);
|
---|
642 | Z = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
643 | CurrentValueMap.erase(name);
|
---|
644 | } else
|
---|
645 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
646 | _T = World::getInstance().getPeriode()->FindElement(Z);
|
---|
647 | }
|
---|
648 |
|
---|
649 | void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
|
---|
650 | int molID = -1;
|
---|
651 | if (typeid( molecule ) == *TypeMap[name]) {
|
---|
652 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
653 | throw MissingValueException(__FILE__, __LINE__);
|
---|
654 | molID = lexical_cast<int>(CurrentValueMap[name].c_str());
|
---|
655 | CurrentValueMap.erase(name);
|
---|
656 | } else
|
---|
657 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
658 | _T = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
659 | }
|
---|
660 |
|
---|
661 | void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
|
---|
662 | Matrix M;
|
---|
663 | double tmp;
|
---|
664 | if (typeid( BoxValue ) == *TypeMap[name]) {
|
---|
665 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
666 | throw MissingValueException(__FILE__, __LINE__);
|
---|
667 | std::istringstream stream(CurrentValueMap[name]);
|
---|
668 | stream >> tmp;
|
---|
669 | M.set(0,0,tmp);
|
---|
670 | stream >> tmp;
|
---|
671 | M.set(0,1,tmp);
|
---|
672 | M.set(1,0,tmp);
|
---|
673 | stream >> tmp;
|
---|
674 | M.set(0,2,tmp);
|
---|
675 | M.set(2,0,tmp);
|
---|
676 | stream >> tmp;
|
---|
677 | M.set(1,1,tmp);
|
---|
678 | stream >> tmp;
|
---|
679 | M.set(1,2,tmp);
|
---|
680 | M.set(2,1,tmp);
|
---|
681 | stream >> tmp;
|
---|
682 | M.set(2,2,tmp);
|
---|
683 | _T = M;
|
---|
684 | CurrentValueMap.erase(name);
|
---|
685 | } else
|
---|
686 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
687 | }
|
---|
688 |
|
---|
689 | void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
|
---|
690 | if (typeid( VectorValue ) == *TypeMap[name]) {
|
---|
691 | std::istringstream stream(CurrentValueMap[name]);
|
---|
692 | CurrentValueMap.erase(name);
|
---|
693 | stream >> _T[0];
|
---|
694 | stream >> _T[1];
|
---|
695 | stream >> _T[2];
|
---|
696 | } else
|
---|
697 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
698 | }
|
---|
699 |
|
---|
700 | void MapOfActions::queryCurrentValue(const char * name, class BoxVector &_T) {
|
---|
701 | if (typeid( VectorValue ) == *TypeMap[name]) {
|
---|
702 | std::istringstream stream(CurrentValueMap[name]);
|
---|
703 | CurrentValueMap.erase(name);
|
---|
704 | stream >> _T[0];
|
---|
705 | stream >> _T[1];
|
---|
706 | stream >> _T[2];
|
---|
707 | } else
|
---|
708 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
709 | }
|
---|
710 |
|
---|
711 | void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T)
|
---|
712 | {
|
---|
713 | int atomID = -1;
|
---|
714 | atom *Walker = NULL;
|
---|
715 | if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
|
---|
716 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
717 | throw MissingValueException(__FILE__, __LINE__);
|
---|
718 | std::istringstream stream(CurrentValueMap[name]);
|
---|
719 | CurrentValueMap.erase(name);
|
---|
720 | while (!stream.fail()) {
|
---|
721 | stream >> atomID >> ws;
|
---|
722 | Walker = World::getInstance().getAtom(AtomById(atomID));
|
---|
723 | if (Walker != NULL)
|
---|
724 | _T.push_back(Walker);
|
---|
725 | atomID = -1;
|
---|
726 | Walker = NULL;
|
---|
727 | }
|
---|
728 | } else
|
---|
729 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
730 | }
|
---|
731 |
|
---|
732 | void MapOfActions::queryCurrentValue(const char * name, std::vector<const element *>&_T)
|
---|
733 | {
|
---|
734 | int Z = -1;
|
---|
735 | const element *elemental = NULL;
|
---|
736 | if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
|
---|
737 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
738 | throw MissingValueException(__FILE__, __LINE__);
|
---|
739 | std::istringstream stream(CurrentValueMap[name]);
|
---|
740 | CurrentValueMap.erase(name);
|
---|
741 | while (!stream.fail()) {
|
---|
742 | stream >> Z >> ws;
|
---|
743 | elemental = World::getInstance().getPeriode()->FindElement(Z);
|
---|
744 | if (elemental != NULL)
|
---|
745 | _T.push_back(elemental);
|
---|
746 | Z = -1;
|
---|
747 | }
|
---|
748 | } else
|
---|
749 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
750 | }
|
---|
751 |
|
---|
752 | void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T)
|
---|
753 | {
|
---|
754 | int molID = -1;
|
---|
755 | molecule *mol = NULL;
|
---|
756 | if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
|
---|
757 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
758 | throw MissingValueException(__FILE__, __LINE__);
|
---|
759 | std::istringstream stream(CurrentValueMap[name]);
|
---|
760 | CurrentValueMap.erase(name);
|
---|
761 | while (!stream.fail()) {
|
---|
762 | stream >> molID >> ws;
|
---|
763 | mol = World::getInstance().getMolecule(MoleculeById(molID));
|
---|
764 | if (mol != NULL)
|
---|
765 | _T.push_back(mol);
|
---|
766 | molID = -1;
|
---|
767 | mol = NULL;
|
---|
768 | }
|
---|
769 | } else
|
---|
770 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
771 | }
|
---|
772 |
|
---|
773 | void MapOfActions::queryCurrentValue(const char * name, boost::filesystem::path&_T)
|
---|
774 | {
|
---|
775 | std::string tmp;
|
---|
776 | if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
|
---|
777 | if (CurrentValueMap.find(name) == CurrentValueMap.end())
|
---|
778 | throw MissingValueException(__FILE__, __LINE__);
|
---|
779 | std::istringstream stream(CurrentValueMap[name]);
|
---|
780 | CurrentValueMap.erase(name);
|
---|
781 | if (!stream.fail()) {
|
---|
782 | stream >> tmp >> ws;
|
---|
783 | _T = tmp;
|
---|
784 | }
|
---|
785 | } else
|
---|
786 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
787 | }
|
---|
788 |
|
---|
789 | void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
|
---|
790 | {
|
---|
791 | if (typeid( atom ) == *TypeMap[name]) {
|
---|
792 | std::ostringstream stream;
|
---|
793 | stream << _T->getId();
|
---|
794 | CurrentValueMap[name] = stream.str();
|
---|
795 | } else
|
---|
796 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
797 | }
|
---|
798 |
|
---|
799 | void MapOfActions::setCurrentValue(const char * name, const element * &_T)
|
---|
800 | {
|
---|
801 | if (typeid(const element ) == *TypeMap[name]) {
|
---|
802 | std::ostringstream stream;
|
---|
803 | stream << _T->getAtomicNumber();
|
---|
804 | CurrentValueMap[name] = stream.str();
|
---|
805 | } else
|
---|
806 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
807 | }
|
---|
808 |
|
---|
809 | void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
|
---|
810 | {
|
---|
811 | if (typeid( molecule ) == *TypeMap[name]) {
|
---|
812 | std::ostringstream stream;
|
---|
813 | stream << _T->getId();
|
---|
814 | CurrentValueMap[name] = stream.str();
|
---|
815 | } else
|
---|
816 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
817 | }
|
---|
818 |
|
---|
819 | void MapOfActions::setCurrentValue(const char * name, class Box &_T)
|
---|
820 | {
|
---|
821 | const Matrix &M = _T.getM();
|
---|
822 | if (typeid( BoxValue ) == *TypeMap[name]) {
|
---|
823 | std::ostringstream stream;
|
---|
824 | stream << M.at(0,0) << " ";
|
---|
825 | stream << M.at(0,1) << " ";
|
---|
826 | stream << M.at(0,2) << " ";
|
---|
827 | stream << M.at(1,1) << " ";
|
---|
828 | stream << M.at(1,2) << " ";
|
---|
829 | stream << M.at(2,2) << " ";
|
---|
830 | CurrentValueMap[name] = stream.str();
|
---|
831 | } else
|
---|
832 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
833 | }
|
---|
834 |
|
---|
835 | void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
|
---|
836 | {
|
---|
837 | if (typeid( VectorValue ) == *TypeMap[name]){
|
---|
838 | std::ostringstream stream;
|
---|
839 | stream << _T[0] << " ";
|
---|
840 | stream << _T[1] << " ";
|
---|
841 | stream << _T[2] << " ";
|
---|
842 | CurrentValueMap[name] = stream.str();
|
---|
843 | } else
|
---|
844 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
845 | }
|
---|
846 |
|
---|
847 | void MapOfActions::setCurrentValue(const char * name, class BoxVector &_T)
|
---|
848 | {
|
---|
849 | if (typeid( VectorValue ) == *TypeMap[name]){
|
---|
850 | std::ostringstream stream;
|
---|
851 | stream << _T[0] << " ";
|
---|
852 | stream << _T[1] << " ";
|
---|
853 | stream << _T[2] << " ";
|
---|
854 | CurrentValueMap[name] = stream.str();
|
---|
855 | } else
|
---|
856 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
857 | }
|
---|
858 |
|
---|
859 | void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T)
|
---|
860 | {
|
---|
861 | if (typeid( std::vector<atom *> ) == *TypeMap[name]) {
|
---|
862 | std::ostringstream stream;
|
---|
863 | for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
864 | stream << (*iter)->getId() << " ";
|
---|
865 | }
|
---|
866 | CurrentValueMap[name] = stream.str();
|
---|
867 | } else
|
---|
868 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
869 | }
|
---|
870 |
|
---|
871 | void MapOfActions::setCurrentValue(const char * name, std::vector<const element *>&_T)
|
---|
872 | {
|
---|
873 | if (typeid( std::vector<const element *> ) == *TypeMap[name]) {
|
---|
874 | std::ostringstream stream;
|
---|
875 | for (std::vector<const element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
876 | stream << (*iter)->getAtomicNumber() << " ";
|
---|
877 | }
|
---|
878 | CurrentValueMap[name] = stream.str();
|
---|
879 | } else
|
---|
880 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
881 | }
|
---|
882 |
|
---|
883 | void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T)
|
---|
884 | {
|
---|
885 | if (typeid( std::vector<molecule *> ) == *TypeMap[name]) {
|
---|
886 | std::ostringstream stream;
|
---|
887 | for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
|
---|
888 | stream << (*iter)->getId() << " ";
|
---|
889 | }
|
---|
890 | CurrentValueMap[name] = stream.str();
|
---|
891 | } else
|
---|
892 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
893 | }
|
---|
894 |
|
---|
895 | void MapOfActions::setCurrentValue(const char * name, boost::filesystem::path &_T)
|
---|
896 | {
|
---|
897 | if (typeid( boost::filesystem::path ) == *TypeMap[name]) {
|
---|
898 | std::ostringstream stream;
|
---|
899 | stream << _T.string();
|
---|
900 | CurrentValueMap[name] = stream.str();
|
---|
901 | } else
|
---|
902 | throw IllegalTypeException(__FILE__,__LINE__);
|
---|
903 | }
|
---|
904 |
|
---|
905 | /** Adds all options to the CommandLineParser.
|
---|
906 | *
|
---|
907 | */
|
---|
908 | void MapOfActions::AddOptionsToParser()
|
---|
909 | {
|
---|
910 | // add other options
|
---|
911 | for (map< set<string>*, po::options_description* >::iterator ListRunner = CmdParserLookup.begin(); ListRunner != CmdParserLookup.end(); ++ListRunner) {
|
---|
912 | for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) {
|
---|
913 | if (hasValue(*OptionRunner)) {
|
---|
914 | DoLog(1) && (Log() << Verbose(1) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl);
|
---|
915 | switch(TypeEnumMap[TypeMap[*OptionRunner]]) {
|
---|
916 | default:
|
---|
917 | case None:
|
---|
918 | ListRunner->second->add_options()
|
---|
919 | (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
|
---|
920 | ;
|
---|
921 | break;
|
---|
922 | case Boolean:
|
---|
923 | ListRunner->second->add_options()
|
---|
924 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
925 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
926 | po::value< bool >()->default_value(lexical_cast<int>(CurrentValueMap[*OptionRunner].c_str())) :
|
---|
927 | po::value< bool >(),
|
---|
928 | getDescription(*OptionRunner).c_str())
|
---|
929 | ;
|
---|
930 | break;
|
---|
931 | case Box:
|
---|
932 | ListRunner->second->add_options()
|
---|
933 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
934 | po::value<BoxValue>(),
|
---|
935 | getDescription(*OptionRunner).c_str())
|
---|
936 | ;
|
---|
937 | break;
|
---|
938 | case File:
|
---|
939 | ListRunner->second->add_options()
|
---|
940 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
941 | po::value< boost::filesystem::path >(),
|
---|
942 | getDescription(*OptionRunner).c_str())
|
---|
943 | ;
|
---|
944 | break;
|
---|
945 | case Integer:
|
---|
946 | ListRunner->second->add_options()
|
---|
947 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
948 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
949 | po::value< int >()->default_value(lexical_cast<int>(CurrentValueMap[*OptionRunner].c_str())) :
|
---|
950 | po::value< int >(),
|
---|
951 | getDescription(*OptionRunner).c_str())
|
---|
952 | ;
|
---|
953 | break;
|
---|
954 | case ListOfIntegers:
|
---|
955 | ListRunner->second->add_options()
|
---|
956 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
957 | po::value< vector<int> >()->multitoken(),
|
---|
958 | getDescription(*OptionRunner).c_str())
|
---|
959 | ;
|
---|
960 | break;
|
---|
961 | case Double:
|
---|
962 | ListRunner->second->add_options()
|
---|
963 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
964 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
965 | po::value< double >()->default_value(lexical_cast<double>(CurrentValueMap[*OptionRunner].c_str())) :
|
---|
966 | po::value< double >(),
|
---|
967 | getDescription(*OptionRunner).c_str())
|
---|
968 | ;
|
---|
969 | break;
|
---|
970 | case ListOfDoubles:
|
---|
971 | ListRunner->second->add_options()
|
---|
972 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
973 | po::value< vector<double> >()->multitoken(),
|
---|
974 | getDescription(*OptionRunner).c_str())
|
---|
975 | ;
|
---|
976 | break;
|
---|
977 | case String:
|
---|
978 | ListRunner->second->add_options()
|
---|
979 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
980 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
981 | po::value< std::string >()->default_value(CurrentValueMap[*OptionRunner]) :
|
---|
982 | po::value< std::string >(),
|
---|
983 | getDescription(*OptionRunner).c_str())
|
---|
984 | ;
|
---|
985 | break;
|
---|
986 | case ListOfStrings:
|
---|
987 | ListRunner->second->add_options()
|
---|
988 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
989 | po::value< vector<std::string> >()->multitoken(),
|
---|
990 | getDescription(*OptionRunner).c_str())
|
---|
991 | ;
|
---|
992 | break;
|
---|
993 | case Vector:
|
---|
994 | ListRunner->second->add_options()
|
---|
995 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
996 | po::value<VectorValue>(),
|
---|
997 | getDescription(*OptionRunner).c_str())
|
---|
998 | ;
|
---|
999 | break;
|
---|
1000 | case ListOfVectors:
|
---|
1001 | ListRunner->second->add_options()
|
---|
1002 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1003 | po::value< vector<VectorValue> >()->multitoken(),
|
---|
1004 | getDescription(*OptionRunner).c_str())
|
---|
1005 | ;
|
---|
1006 | break;
|
---|
1007 | case Molecule:
|
---|
1008 | ListRunner->second->add_options()
|
---|
1009 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1010 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
1011 | po::value< int >()->default_value(lexical_cast<int>(CurrentValueMap[*OptionRunner].c_str())) :
|
---|
1012 | po::value< int >(),
|
---|
1013 | getDescription(*OptionRunner).c_str())
|
---|
1014 | ;
|
---|
1015 | break;
|
---|
1016 | case ListOfMolecules:
|
---|
1017 | ListRunner->second->add_options()
|
---|
1018 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1019 | po::value< vector<int> >()->multitoken(),
|
---|
1020 | getDescription(*OptionRunner).c_str())
|
---|
1021 | ;
|
---|
1022 | break;
|
---|
1023 | case Atom:
|
---|
1024 | ListRunner->second->add_options()
|
---|
1025 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1026 | CurrentValueMap.find(*OptionRunner) != CurrentValueMap.end() ?
|
---|
1027 | po::value< int >()->default_value(lexical_cast<int>(CurrentValueMap[*OptionRunner].c_str())) :
|
---|
1028 | po::value< int >(),
|
---|
1029 | getDescription(*OptionRunner).c_str())
|
---|
1030 | ;
|
---|
1031 | break;
|
---|
1032 | case ListOfAtoms:
|
---|
1033 | ListRunner->second->add_options()
|
---|
1034 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1035 | po::value< vector<int> >()->multitoken(),
|
---|
1036 | getDescription(*OptionRunner).c_str())
|
---|
1037 | ;
|
---|
1038 | break;
|
---|
1039 | case Element:
|
---|
1040 | ListRunner->second->add_options()
|
---|
1041 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1042 | po::value< int >(),
|
---|
1043 | getDescription(*OptionRunner).c_str())
|
---|
1044 | ;
|
---|
1045 | break;
|
---|
1046 | case ListOfElements:
|
---|
1047 | ListRunner->second->add_options()
|
---|
1048 | (getKeyAndShortForm(*OptionRunner).c_str(),
|
---|
1049 | po::value< vector<int> >()->multitoken(),
|
---|
1050 | getDescription(*OptionRunner).c_str())
|
---|
1051 | ;
|
---|
1052 | break;
|
---|
1053 | }
|
---|
1054 | } else {
|
---|
1055 | DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);
|
---|
1056 | ListRunner->second->add_options()
|
---|
1057 | (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str())
|
---|
1058 | ;
|
---|
1059 | }
|
---|
1060 | }
|
---|
1061 | }
|
---|
1062 | }
|
---|
1063 |
|
---|
1064 | /** Getter for MapOfActions:DescriptionMap.
|
---|
1065 | * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
|
---|
1066 | * \param actionname name of the action to lookup
|
---|
1067 | * \return Description of the action
|
---|
1068 | */
|
---|
1069 | const std::string MapOfActions::getDescription(string actionname)
|
---|
1070 | {
|
---|
1071 | ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescription");
|
---|
1072 | return DescriptionMap[actionname];
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | /** Specific Getter for a MapOfActions:ShortFormMap.
|
---|
1076 | * If action has a short for, then combination is as "actionname,ShortForm" (this is
|
---|
1077 | * the desired format for boost::program_options). If no short form exists in the map,
|
---|
1078 | * just actionname will be returned
|
---|
1079 | * Note that we assert when action does not exist in CommandLineParser::DescriptionMap.
|
---|
1080 | * \param actionname name of the action to lookup
|
---|
1081 | * \return actionname,ShortForm or Description of the action
|
---|
1082 | */
|
---|
1083 | const std::string MapOfActions::getKeyAndShortForm(string actionname)
|
---|
1084 | {
|
---|
1085 | stringstream output;
|
---|
1086 | ASSERT(DescriptionMap.find(actionname) != DescriptionMap.end(), "Unknown action name passed to MapOfActions::getDescriptionAndShortForm");
|
---|
1087 | output << actionname;
|
---|
1088 | if (ShortFormMap.find(actionname) != DescriptionMap.end())
|
---|
1089 | output << "," << ShortFormMap[actionname];
|
---|
1090 | return output.str();
|
---|
1091 | }
|
---|
1092 |
|
---|
1093 | /** Getter for MapOfActions:ShortFormMap.
|
---|
1094 | * Note that we assert when action does not exist CommandLineParser::ShortFormMap.
|
---|
1095 | * \param actionname name of the action to lookup
|
---|
1096 | * \return ShortForm of the action
|
---|
1097 | */
|
---|
1098 | const std::string MapOfActions::getShortForm(string actionname)
|
---|
1099 | {
|
---|
1100 | if (ShortFormMap.find(actionname) != ShortFormMap.end())
|
---|
1101 | return ShortFormMap[actionname];
|
---|
1102 | else
|
---|
1103 | return std::string();
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | /** Getter for MapOfActions:CurrentValueMap.
|
---|
1107 | * Note that we assert when action does not exist in CommandLineParser::CurrentValueMap.
|
---|
1108 | * \param actionname name of the action to lookup
|
---|
1109 | * \return CurrentValueMap of the action
|
---|
1110 | */
|
---|
1111 | const std::string MapOfActions::getCurrentValue(string actionname)
|
---|
1112 | {
|
---|
1113 | if (CurrentValueMap.find(actionname) != CurrentValueMap.end())
|
---|
1114 | return CurrentValueMap[actionname];
|
---|
1115 | else
|
---|
1116 | return std::string();
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 | /** Returns whether the given action needs a value or not.
|
---|
1120 | * \param actionname name of the action to look up
|
---|
1121 | * \return true - value is needed, false - no value is stored in MapOfActions::TypeMap
|
---|
1122 | */
|
---|
1123 | bool MapOfActions::hasValue(string actionname)
|
---|
1124 | {
|
---|
1125 | return (TypeMap.find(actionname) != TypeMap.end());
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | /** Getter for MapOfActions::TypeMap::name.
|
---|
1129 | * \param actionname name of the action to look up
|
---|
1130 | * \return name of type of the action
|
---|
1131 | */
|
---|
1132 | const std::string MapOfActions::getValueType(string actionname)
|
---|
1133 | {
|
---|
1134 | return TypeMap[actionname]->name();
|
---|
1135 | }
|
---|
1136 |
|
---|
1137 | /** Getter for MapOfActions::TypeMap.
|
---|
1138 | * \param actionname name of the action to look up
|
---|
1139 | * \return type of the action
|
---|
1140 | */
|
---|
1141 | const std::type_info * MapOfActions::getType(string actionname)
|
---|
1142 | {
|
---|
1143 | return TypeMap[actionname];
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | /** Searches whether action is registered with CommandLineParser.
|
---|
1147 | * Note that this method is only meant transitionally for ParseCommandLineOptions' removal.
|
---|
1148 | * I.e. All actions that are already handled by the new CommandLineUIFactory can be checked
|
---|
1149 | * by this function.
|
---|
1150 | * \param shortform command short form to look for
|
---|
1151 | * \return true - action has been registered, false - action has not been registered.
|
---|
1152 | */
|
---|
1153 | bool MapOfActions::isShortFormPresent(string shortform)
|
---|
1154 | {
|
---|
1155 | bool result = false;
|
---|
1156 | string actionname;
|
---|
1157 | for (map<std::string, std::string>::iterator ShortFormRunner = ShortFormMap.begin(); ShortFormRunner != ShortFormMap.end(); ++ShortFormRunner)
|
---|
1158 | if (ShortFormRunner->second == shortform) {
|
---|
1159 | actionname = ShortFormRunner->first;
|
---|
1160 | break;
|
---|
1161 | }
|
---|
1162 | result = result || (generic.find(actionname) != generic.end());
|
---|
1163 | result = result || (config.find(actionname) != config.end());
|
---|
1164 | result = result || (hidden.find(actionname) != hidden.end());
|
---|
1165 | result = result || (visible.find(actionname) != visible.end());
|
---|
1166 | result = result || (inputfile.find(actionname) != inputfile.end());
|
---|
1167 | return result;
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | /** Returns the inverse to MapOfActions::ShortFormMap, i.e. lookup actionname for its short form.
|
---|
1171 | * \return map from short form of action to name of action
|
---|
1172 | */
|
---|
1173 | map <std::string, std::string> MapOfActions::getShortFormToActionMap()
|
---|
1174 | {
|
---|
1175 | map <std::string, std::string> result;
|
---|
1176 |
|
---|
1177 | for (map<std::string, std::string>::iterator iter = ShortFormMap.begin(); iter != ShortFormMap.end(); ++iter)
|
---|
1178 | result[iter->second] = iter->first;
|
---|
1179 |
|
---|
1180 | return result;
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 |
|
---|
1184 | CONSTRUCT_SINGLETON(MapOfActions)
|
---|