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