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