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