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