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