Changeset 5c6946
- Timestamp:
- Aug 28, 2010, 12:57:56 AM (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:
- bb6193
- Parents:
- 3ae731
- git-author:
- Frederik Heber <heber@…> (08/27/10 10:25:55)
- git-committer:
- Frederik Heber <heber@…> (08/28/10 00:57:56)
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/SetOutputFormatsAction.cpp
r3ae731 r5c6946 42 42 43 43 for (vector<std::string>::iterator iter = params.FormatList.begin(); iter != params.FormatList.end(); ++iter) { 44 if (*iter == "mpqc") { 45 FormatParserStorage::getInstance().addMpqc(); 46 DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl); 47 } else if (*iter == "pcp") { 48 FormatParserStorage::getInstance().addPcp(); 49 DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl); 50 } else if (*iter == "tremolo") { 51 FormatParserStorage::getInstance().addTremolo(); 52 DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl); 53 } else if (*iter == "xyz") { 54 FormatParserStorage::getInstance().addXyz(); 55 DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl); 56 } else { 57 DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl); 44 if (!FormatParserStorage::getInstance().add(*iter)) { 45 DoeLog(1) && (eLog() << Verbose(1) << "Unknown parser format in WorldSetOutputFormatsAction:" << *iter << endl); 58 46 } 59 47 } -
src/Parser/FormatParserStorage.cpp
r3ae731 r5c6946 56 56 ParserSuffix.resize(ParserTypes_end, ""); 57 57 58 ParserNames[mpqc] = "mpqc"; 59 ParserNames[pcp] = "pcp"; 60 ParserNames[tremolo] = "tremolo"; 61 ParserNames[xyz] = "xyz"; 62 63 for (std::map<ParserTypes, std::string>::const_iterator it = ParserNames.begin(); it != ParserNames.end(); ++it) 64 ParserLookupNames.insert(pair<std::string, ParserTypes>(it->second,it->first) ); 65 58 66 ParserSuffix[mpqc] = "in"; 59 67 ParserSuffix[pcp] = "conf"; 60 68 ParserSuffix[tremolo] = "data"; 61 69 ParserSuffix[xyz] = "xyz"; 70 71 ParserAddFunction[mpqc] = &FormatParserStorage::addMpqc; 72 ParserAddFunction[pcp] = &FormatParserStorage::addPcp; 73 ParserAddFunction[tremolo] = &FormatParserStorage::addTremolo; 74 ParserAddFunction[xyz] = &FormatParserStorage::addXyz; 62 75 } 63 76 … … 112 125 } 113 126 127 114 128 /** Adds an PcpParser to the storage. 115 129 */ … … 146 160 DoeLog(1) && (eLog() << Verbose(1) << "Parser xyz is already present." << endl); 147 161 } 162 163 ParserTypes FormatParserStorage::getType(std::string type) 164 { 165 if (ParserLookupNames.find(type) == ParserLookupNames.end()) { 166 DoeLog(1) && (eLog() << Verbose(1) << "Unknown type " << type << "." << endl); 167 return ParserTypes_end; 168 } else 169 return ParserLookupNames[type]; 170 } 171 172 bool FormatParserStorage::add(ParserTypes ptype) 173 { 174 if (ptype != ParserTypes_end) { 175 if (ParserAddFunction.find(ptype) != ParserAddFunction.end()) { 176 DoLog(0) && (Log() << Verbose(0) << "Adding " << ParserNames[ptype] << " type to output." << endl); 177 (getInstance().*(ParserAddFunction[ptype]))(); // we still need an object to work on ... 178 return true; 179 } else { 180 DoeLog(1) && (eLog() << Verbose(1) << "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?" << endl); 181 return false; 182 } 183 } else { 184 return false; 185 } 186 } 187 188 bool FormatParserStorage::add(std::string type) 189 { 190 return add(getType(type)); 191 } 192 148 193 149 194 /** Parses an istream depending on its suffix … … 163 208 getXyz().load(&input); 164 209 } else { 165 DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix to for FormatParserStorage::get()." << endl);210 DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::get()." << endl); 166 211 return false; 167 212 } -
src/Parser/FormatParserStorage.hpp
r3ae731 r5c6946 17 17 18 18 #include <string> 19 #include <map> 19 20 #include <vector> 20 21 … … 35 36 public: 36 37 37 38 38 void addMpqc(); 39 39 void addPcp(); 40 40 void addTremolo(); 41 41 void addXyz(); 42 bool add(std::string type); 43 bool add(ParserTypes type); 42 44 43 45 bool get(std::istream &input, std::string suffix); … … 46 48 TremoloParser &getTremolo(); 47 49 XyzParser &getXyz(); 50 51 ParserTypes getType(std::string type); 48 52 49 53 void SetOutputPrefixForAll(std::string &_prefix); … … 67 71 std::vector<std::string> ParserSuffix; 68 72 73 // function pointers to each add...() 74 std::map< ParserTypes, void (FormatParserStorage::*)() > ParserAddFunction; 75 76 // type name of each parser type and reverse lookup 77 std::map<ParserTypes, std::string> ParserNames; 78 std::map<std::string, ParserTypes> ParserLookupNames; 79 80 69 81 // prefix of the filenames to use on save 70 82 std::string prefix;
Note:
See TracChangeset
for help on using the changeset viewer.