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