Changeset 0b0a20
- Timestamp:
- Jul 23, 2010, 5:30:57 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 85f35e
- Parents:
- dde125
- Location:
- src
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MapOfActions.cpp
rdde125 r0b0a20 343 343 TypeMap["start-step"] = &typeid(int); 344 344 345 TypeEnumMap[&typeid(void)] = None; 346 TypeEnumMap[&typeid(bool)] = Boolean; 345 347 TypeEnumMap[&typeid(int)] = Integer; 348 TypeEnumMap[&typeid(std::vector<int>)] = ListOfIntegers; 346 349 TypeEnumMap[&typeid(double)] = Double; 347 TypeEnumMap[&typeid( bool)] = Boolean;350 TypeEnumMap[&typeid(std::vector<double>)] = ListOfDoubles; 348 351 TypeEnumMap[&typeid(std::string)] = String; 352 TypeEnumMap[&typeid(std::vector<std::string>)] = ListOfStrings; 353 TypeEnumMap[&typeid(VectorValue)] = Vector; 354 TypeEnumMap[&typeid(BoxValue)] = Box; 355 TypeEnumMap[&typeid(molecule)] = Molecule; 356 TypeEnumMap[&typeid(std::vector<molecule *>)] = ListOfMolecules; 349 357 TypeEnumMap[&typeid(atom)] = Atom; 358 TypeEnumMap[&typeid(std::vector<atom *>)] = ListOfAtoms; 350 359 TypeEnumMap[&typeid(element)] = Element; 351 360 TypeEnumMap[&typeid(std::vector<element *>)] = ListOfElements; 352 TypeEnumMap[&typeid(molecule)] = Molecule;353 TypeEnumMap[&typeid(VectorValue)] = Vector;354 TypeEnumMap[&typeid(BoxValue)] = Box;355 356 361 357 362 // default values for any action that needs one (always string!) … … 580 585 } 581 586 587 void MapOfActions::queryCurrentValue(const char * name, std::vector<atom *>&_T) 588 { 589 int atomID = -1; 590 atom *Walker = NULL; 591 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 592 if (CurrentValue.find(name) == CurrentValue.end()) 593 throw MissingValueException(__FILE__, __LINE__); 594 std::istringstream stream(CurrentValue[name]); 595 CurrentValue.erase(name); 596 while (!stream.fail()) { 597 stream >> atomID; 598 Walker = World::getInstance().getAtom(AtomById(atomID)); 599 if (Walker != NULL) 600 _T.push_back(Walker); 601 } 602 } else 603 throw IllegalTypeException(__FILE__,__LINE__); 604 } 605 582 606 void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T) 583 607 { … … 599 623 } 600 624 601 void MapOfActions::queryCurrentValue(const char * name, std::vector<std::string>&_T) 602 { 603 std::string temp; 604 if (typeid( std::vector<std::string> ) == *TypeMap[name]) { 625 void MapOfActions::queryCurrentValue(const char * name, std::vector<molecule *>&_T) 626 { 627 int molID = -1; 628 molecule *mol = NULL; 629 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 605 630 if (CurrentValue.find(name) == CurrentValue.end()) 606 631 throw MissingValueException(__FILE__, __LINE__); … … 608 633 CurrentValue.erase(name); 609 634 while (!stream.fail()) { 610 stream >> temp >> ws; 611 _T.push_back(temp); 635 stream >> molID; 636 mol = World::getInstance().getMolecule(MoleculeById(molID)); 637 if (mol != NULL) 638 _T.push_back(mol); 612 639 } 613 640 } else … … 674 701 } 675 702 703 void MapOfActions::setCurrentValue(const char * name, std::vector<atom *>&_T) 704 { 705 if (typeid( std::vector<atom *> ) == *TypeMap[name]) { 706 std::ostringstream stream; 707 for (std::vector<atom *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 708 stream << (*iter)->getId() << " "; 709 } 710 CurrentValue[name] = stream.str(); 711 } else 712 throw IllegalTypeException(__FILE__,__LINE__); 713 } 714 676 715 void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T) 677 716 { … … 679 718 std::ostringstream stream; 680 719 for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 681 stream << (*iter)->Z ;720 stream << (*iter)->Z << " "; 682 721 } 683 722 CurrentValue[name] = stream.str(); … … 686 725 } 687 726 688 void MapOfActions::setCurrentValue(const char * name, std::vector< std::string>&_T)689 { 690 if (typeid( std::vector< std::string> ) == *TypeMap[name]) {727 void MapOfActions::setCurrentValue(const char * name, std::vector<molecule *>&_T) 728 { 729 if (typeid( std::vector<molecule *> ) == *TypeMap[name]) { 691 730 std::ostringstream stream; 692 for (std::vector< std::string>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {693 stream << (*iter) ;731 for (std::vector<molecule *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 732 stream << (*iter)->getId() << " "; 694 733 } 695 734 CurrentValue[name] = stream.str(); … … 765 804 for (set<string>::iterator OptionRunner = ListRunner->first->begin(); OptionRunner != ListRunner->first->end(); ++OptionRunner) { 766 805 if (hasValue(*OptionRunner)) { 767 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]<< " to CommandLineParser." << endl);806 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " with type " << TypeMap[*OptionRunner]->name() << " to CommandLineParser." << endl); 768 807 switch(TypeEnumMap[TypeMap[*OptionRunner]]) { 769 808 default: … … 798 837 ; 799 838 break; 800 case ListOfInt s:839 case ListOfIntegers: 801 840 ListRunner->second->add_options() 802 841 (getKeyAndShortForm(*OptionRunner).c_str(), … … 830 869 ; 831 870 break; 832 case ListOfString :871 case ListOfStrings: 833 872 ListRunner->second->add_options() 834 873 (getKeyAndShortForm(*OptionRunner).c_str(), … … 837 876 ; 838 877 break; 839 case Axis: 878 case Vector: 879 ListRunner->second->add_options() 880 (getKeyAndShortForm(*OptionRunner).c_str(), 881 po::value<VectorValue>(), 882 getDescription(*OptionRunner).c_str()) 883 ; 884 break; 885 case ListOfVectors: 886 ListRunner->second->add_options() 887 (getKeyAndShortForm(*OptionRunner).c_str(), 888 po::value< vector<VectorValue> >()->multitoken(), 889 getDescription(*OptionRunner).c_str()) 890 ; 891 break; 892 case Molecule: 840 893 ListRunner->second->add_options() 841 894 (getKeyAndShortForm(*OptionRunner).c_str(), … … 846 899 ; 847 900 break; 848 case Vector:849 ListRunner->second->add_options() 850 (getKeyAndShortForm(*OptionRunner).c_str(), 851 po::value< VectorValue>(),852 getDescription(*OptionRunner).c_str()) 853 ; 854 break; 855 case Molecule:901 case ListOfMolecules: 902 ListRunner->second->add_options() 903 (getKeyAndShortForm(*OptionRunner).c_str(), 904 po::value< vector<int> >()->multitoken(), 905 getDescription(*OptionRunner).c_str()) 906 ; 907 break; 908 case Atom: 856 909 ListRunner->second->add_options() 857 910 (getKeyAndShortForm(*OptionRunner).c_str(), … … 862 915 ; 863 916 break; 864 case ListOfMolecules:865 ListRunner->second->add_options()866 (getKeyAndShortForm(*OptionRunner).c_str(),867 po::value< vector<int> >()->multitoken(),868 getDescription(*OptionRunner).c_str())869 ;870 break;871 case Atom:872 ListRunner->second->add_options()873 (getKeyAndShortForm(*OptionRunner).c_str(),874 CurrentValue.find(*OptionRunner) != CurrentValue.end() ?875 po::value< int >()->default_value(atoi(CurrentValue[*OptionRunner].c_str())) :876 po::value< int >(),877 getDescription(*OptionRunner).c_str())878 ;879 break;880 917 case ListOfAtoms: 881 918 ListRunner->second->add_options() … … 901 938 } 902 939 } else { 903 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl);940 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to CommandLineParser." << endl); 904 941 ListRunner->second->add_options() 905 942 (getKeyAndShortForm(*OptionRunner).c_str(), getDescription(*OptionRunner).c_str()) … … 910 947 // add positional arguments 911 948 for (set<string>::iterator OptionRunner = inputfile.begin(); OptionRunner != inputfile.end(); ++OptionRunner) { 912 DoLog( 0) && (Log() << Verbose(0) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl);949 DoLog(3) && (Log() << Verbose(3) << "Adding option " << *OptionRunner << " to positional CommandLineParser." << endl); 913 950 CommandLineParser::getInstance().inputfile.add((*OptionRunner).c_str(), -1); 914 951 } -
src/Actions/MapOfActions.hpp
rdde125 r0b0a20 135 135 friend class MapOfActionsTest; 136 136 public: 137 enum OptionTypes { None, Boolean, Integer, ListOfInt s, Double, ListOfDoubles, String, ListOfString, Axis, Vector, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements };137 enum OptionTypes { None, Boolean, Integer, ListOfIntegers, Double, ListOfDoubles, String, ListOfStrings, Vector, ListOfVectors, Box, Molecule, ListOfMolecules, Atom, ListOfAtoms, Element, ListOfElements }; 138 138 139 139 // getter for the action descriptions and short forms … … 167 167 void queryCurrentValue(const char * name, class Box &_T); 168 168 void queryCurrentValue(const char * name, class Vector &_T); 169 void queryCurrentValue(const char * name, std::vector<atom *>&_T); 169 170 void queryCurrentValue(const char * name, std::vector<element *>&_T); 170 void queryCurrentValue(const char * name, std::vector< std::string>&_T);171 void queryCurrentValue(const char * name, std::vector<molecule *>&_T); 171 172 template<typename T> void queryCurrentValue(const char * name, T &_T) 172 173 { … … 179 180 throw IllegalTypeException(__FILE__,__LINE__); 180 181 } 182 template<typename T> void queryCurrentValue(const char * name, std::vector<T> &_T) 183 { 184 T temp; 185 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 186 if (CurrentValue.find(name) == CurrentValue.end()) 187 throw MissingValueException(__FILE__, __LINE__); 188 std::istringstream stream(CurrentValue[name]); 189 CurrentValue.erase(name); 190 while (!stream.fail()) { 191 stream >> temp >> std::ws; 192 _T.push_back(temp); 193 } 194 } else 195 throw IllegalTypeException(__FILE__,__LINE__); 196 } 181 197 182 198 void setCurrentValue(const char * name, class atom * &_T); … … 185 201 void setCurrentValue(const char * name, class Box &_T); 186 202 void setCurrentValue(const char * name, class Vector &_T); 203 void setCurrentValue(const char * name, std::vector<atom *>&_T); 187 204 void setCurrentValue(const char * name, std::vector<element *>&_T); 188 void setCurrentValue(const char * name, std::vector< std::string>&_T);205 void setCurrentValue(const char * name, std::vector<molecule *>&_T); 189 206 template<class T> void setCurrentValue(const char * name, T &_T) 190 207 { … … 192 209 if (typeid( T ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 193 210 stream << _T; 211 CurrentValue[name] = stream.str(); 212 } else 213 throw IllegalTypeException(__FILE__,__LINE__); 214 } 215 template<class T> void setCurrentValue(const char * name, std::vector<T> &_T) 216 { 217 std::ostringstream stream; 218 if (typeid( std::vector<T> ) == *TypeMap[name]) { // constructor of type_info is private, hence can only store by ref or ptr 219 std::ostringstream stream; 220 for (std::vector<std::string>::iterator iter = _T.begin(); iter != _T.end(); ++iter) { 221 stream << (*iter) << " "; 222 } 194 223 CurrentValue[name] = stream.str(); 195 224 } else
Note:
See TracChangeset
for help on using the changeset viewer.