Changeset 765f16 for src/Parser/FormatParserStorage.cpp
- Timestamp:
- Oct 14, 2011, 3:15:30 PM (13 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:
- d3d6c6
- Parents:
- 9a6b76e
- git-author:
- Frederik Heber <heber@…> (09/27/11 19:04:36)
- git-committer:
- Frederik Heber <heber@…> (10/14/11 15:15:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/FormatParserStorage.cpp
r9a6b76e r765f16 23 23 #include <fstream> 24 24 25 #include "Parser/FormatParserStorage.hpp" 26 25 #include <boost/preprocessor/iteration/local.hpp> 26 27 #include "CodePatterns/Assert.hpp" 27 28 #include "CodePatterns/Log.hpp" 28 #include "CodePatterns/Verbose.hpp"29 30 #include "CodePatterns/Assert.hpp"31 29 32 30 #include "molecule.hpp" 31 #include "FormatParserStorage.hpp" 32 #include "ParserTypes.hpp" 33 34 #include "MpqcParser.hpp" 35 #include "PcpParser.hpp" 36 #include "PdbParser.hpp" 37 #include "TremoloParser.hpp" 38 #include "XyzParser.hpp" 33 39 34 40 #include "CodePatterns/Singleton_impl.hpp" 35 41 36 template <> enum ParserTypes getPType<MpqcParser>() { return (enum ParserTypes)mpqc; }37 template <> enum ParserTypes getPType<PcpParser>() { return (enum ParserTypes)pcp; }38 template <> enum ParserTypes getPType<PdbParser>() { return (enum ParserTypes)pdb; }39 template <> enum ParserTypes getPType<TremoloParser>() { return (enum ParserTypes)tremolo; }40 template <> enum ParserTypes getPType<XyzParser>() { return (enum ParserTypes)xyz; }41 42 /** Increment operator for the enumeration ParserTypes to allow loops.43 * \param &type value44 * \return value incremented by one45 */46 ParserTypes &operator++(ParserTypes &type)47 {48 return type = ParserTypes(type+1);49 }50 42 51 43 /** Constructor of class FormatParserStorage. … … 57 49 ParserPresent.resize(ParserTypes_end, false); 58 50 59 ParserNames[mpqc] = "mpqc"; 60 ParserNames[pcp] = "pcp"; 61 ParserNames[pdb] = "pdb"; 62 ParserNames[tremolo] = "tremolo"; 63 ParserNames[xyz] = "xyz"; 51 #include "ParserTypes.def" 52 53 #define insert_print(z,n,seq,map, before, after) \ 54 map .insert( std::make_pair( \ 55 BOOST_PP_SEQ_ELEM(n, seq) \ 56 , before < \ 57 BOOST_PP_SEQ_ELEM(n, seq) \ 58 > after \ 59 ) ); 64 60 65 for (std::map<ParserTypes, std::string>::const_iterator it = ParserNames.begin(); it != ParserNames.end(); ++it) 66 ParserLookupNames.insert(pair<std::string, ParserTypes>(it->second,it->first) ); 67 68 ParserSuffixes[mpqc] = "in"; 69 ParserSuffixes[pcp] = "conf"; 70 ParserSuffixes[pdb] = "pdb"; 71 ParserSuffixes[tremolo] = "data"; 72 ParserSuffixes[xyz] = "xyz"; 73 74 for (std::map<ParserTypes, std::string>::const_iterator it = ParserSuffixes.begin(); it != ParserSuffixes.end(); ++it) 75 ParserLookupSuffixes.insert(pair<std::string, ParserTypes>(it->second,it->first) ); 76 77 ParserAddFunction[mpqc] = &FormatParserStorage::addParser<MpqcParser>; 78 ParserAddFunction[pcp] = &FormatParserStorage::addParser<PcpParser>; 79 ParserAddFunction[pdb] = &FormatParserStorage::addParser<PdbParser>; 80 ParserAddFunction[tremolo] = &FormatParserStorage::addParser<TremoloParser>; 81 ParserAddFunction[xyz] = &FormatParserStorage::addParser<XyzParser>; 61 #define insert_invert_print(z,n,seq,map, before, after) \ 62 map .insert( std::make_pair( before < \ 63 BOOST_PP_SEQ_ELEM(n, seq) \ 64 > after, \ 65 BOOST_PP_SEQ_ELEM(n, seq) \ 66 ) ); 67 68 // fill ParserNames 69 #if defined ParserTypes_END // do we have parameters at all? 70 #define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserNames, FormatParserTrait, ::name) 71 #define BOOST_PP_LOCAL_LIMITS (0, ParserTypes_END-1) 72 #include BOOST_PP_LOCAL_ITERATE() 73 #endif 74 75 // fill ParserLookupNames 76 #if defined ParserTypes_END // do we have parameters at all? 77 #define BOOST_PP_LOCAL_MACRO(n) insert_invert_print(~, n, PARSERSEQUENCE, ParserLookupNames, FormatParserTrait, ::name) 78 #define BOOST_PP_LOCAL_LIMITS (0, ParserTypes_END-1) 79 #include BOOST_PP_LOCAL_ITERATE() 80 #endif 81 82 // fill ParserSuffixes 83 #if defined ParserTypes_END // do we have parameters at all? 84 #define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserSuffixes, FormatParserTrait, ::suffix) 85 #define BOOST_PP_LOCAL_LIMITS (0, ParserTypes_END-1) 86 #include BOOST_PP_LOCAL_ITERATE() 87 #endif 88 89 // fill ParserLookupSuffixes 90 #if defined ParserTypes_END // do we have parameters at all? 91 #define BOOST_PP_LOCAL_MACRO(n) insert_invert_print(~, n, PARSERSEQUENCE, ParserLookupSuffixes, FormatParserTrait, ::suffix) 92 #define BOOST_PP_LOCAL_LIMITS (0, ParserTypes_END-1) 93 #include BOOST_PP_LOCAL_ITERATE() 94 #endif 95 96 // fill ParserAddFunction 97 #if defined ParserTypes_END // do we have parameters at all? 98 #define BOOST_PP_LOCAL_MACRO(n) insert_print(~, n, PARSERSEQUENCE, ParserAddFunction, &FormatParserStorage::addParser, ) 99 #define BOOST_PP_LOCAL_LIMITS (0, ParserTypes_END-1) 100 #include BOOST_PP_LOCAL_ITERATE() 101 #endif 102 103 #undef insert_print 104 #undef insert_invert_print 105 #include "ParserTypes.undef" 106 107 //std::cout << "ParserNames:" << std::endl << ParserNames << std::endl; 108 //std::cout << "ParserSuffixes:" << std::endl << ParserSuffixes << std::endl; 109 //std::cout << "ParserLookupNames:" << std::endl << ParserLookupNames << std::endl; 110 //std::cout << "ParserLookupSuffixes:" << std::endl << ParserLookupSuffixes << std::endl; 111 //std::cout << "ParserAddFunction:" << std::endl << ParserAddFunction << std::endl; 112 82 113 } 83 114 … … 142 173 if (ptype != ParserTypes_end) { 143 174 if (ParserAddFunction.find(ptype) != ParserAddFunction.end()) { 144 DoLog(0) && (Log() << Verbose(0) << "Adding " << ParserNames[ptype] << " type to output." << endl);175 LOG(0, "STATUS: Adding " << ParserNames[ptype] << " type to output."); 145 176 (getInstance().*(ParserAddFunction[ptype]))(); // we still need an object to work on ... 146 177 return true; 147 178 } else { 148 DoeLog(1) && (eLog() << Verbose(1) << "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?" << endl);179 ELOG(1, "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?"); 149 180 return false; 150 181 } … … 156 187 bool FormatParserStorage::add(std::string type) 157 188 { 158 return add(getTypeFromName(type)); 189 enum ParserTypes Ptype = getTypeFromName(type); 190 return add(Ptype); 159 191 } 160 192 … … 246 278 * \return reference to the output FormatParser with desired type 247 279 */ 248 FormatParser &FormatParserStorage::get(ParserTypes _type)280 FormatParserInterface &FormatParserStorage::get(ParserTypes _type) 249 281 { 250 282 if (!ParserPresent[_type]) {
Note:
See TracChangeset
for help on using the changeset viewer.