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