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