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