Changeset a42054 for src


Ignore:
Timestamp:
Aug 28, 2010, 6:07:02 AM (15 years ago)
Author:
Frederik Heber <heber@…>
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:
eee966
Parents:
199763
Message:

Extended FormatParserStorage.

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/FormatParserStorage.cpp

    r199763 ra42054  
    5555  ParserStream.resize(ParserTypes_end, NULL);
    5656  ParserPresent.resize(ParserTypes_end, false);
    57   ParserSuffix.resize(ParserTypes_end, "");
    5857
    5958  ParserNames[mpqc] = "mpqc";
     
    6665    ParserLookupNames.insert(pair<std::string, ParserTypes>(it->second,it->first) );
    6766
    68   ParserSuffix[mpqc] = "in";
    69   ParserSuffix[pcp] = "conf";
    70   ParserSuffix[pdb] = "pdb";
    71   ParserSuffix[tremolo] = "data";
    72   ParserSuffix[xyz] = "xyz";
     67  ParserSuffixes[mpqc] = "in";
     68  ParserSuffixes[pcp] = "conf";
     69  ParserSuffixes[pdb] = "pdb";
     70  ParserSuffixes[tremolo] = "data";
     71  ParserSuffixes[xyz] = "xyz";
     72
     73  for (std::map<ParserTypes, std::string>::const_iterator it = ParserSuffixes.begin(); it != ParserSuffixes.end(); ++it)
     74    ParserLookupSuffixes.insert(pair<std::string, ParserTypes>(it->second,it->first) );
    7375
    7476  ParserAddFunction[mpqc] = &FormatParserStorage::addMpqc;
     
    110112      filename = prefix;
    111113      filename += ".";
    112       filename += ParserSuffix[iter];
     114      filename += ParserSuffixes[iter];
    113115      ParserStream[iter] = new std::ofstream(filename.c_str());
    114116      ParserList[iter]->setOstream((std::ostream *)ParserStream[iter]);
     
    177179}
    178180
    179 ParserTypes FormatParserStorage::getType(std::string type)
     181ParserTypes FormatParserStorage::getTypeFromName(std::string type)
    180182{
    181183  if (ParserLookupNames.find(type) == ParserLookupNames.end()) {
     
    184186  } else
    185187    return ParserLookupNames[type];
     188}
     189
     190ParserTypes FormatParserStorage::getTypeFromSuffix(std::string type)
     191{
     192  if (ParserLookupSuffixes.find(type) == ParserLookupSuffixes.end()) {
     193    DoeLog(1) && (eLog() << Verbose(1) << "Unknown type " << type << "." << endl);
     194    return ParserTypes_end;
     195  } else
     196    return ParserLookupSuffixes[type];
    186197}
    187198
     
    204215bool FormatParserStorage::add(std::string type)
    205216{
    206   return add(getType(type));
     217  return add(getTypeFromName(type));
    207218}
    208219
     
    215226bool FormatParserStorage::get(std::istream &input, std::string suffix)
    216227{
    217   if (suffix == ParserSuffix[mpqc]) {
     228  if (suffix == ParserSuffixes[mpqc]) {
    218229    getMpqc().load(&input);
    219   } else if (suffix == ParserSuffix[pcp]) {
     230  } else if (suffix == ParserSuffixes[pcp]) {
    220231    getPcp().load(&input);
    221   } else if (suffix == ParserSuffix[pdb]) {
     232  } else if (suffix == ParserSuffixes[pdb]) {
    222233    getPdb().load(&input);
    223   } else if (suffix == ParserSuffix[tremolo]) {
     234  } else if (suffix == ParserSuffixes[tremolo]) {
    224235    getTremolo().load(&input);
    225   } else if (suffix == ParserSuffix[xyz]) {
     236  } else if (suffix == ParserSuffixes[xyz]) {
    226237    getXyz().load(&input);
    227238  } else {
  • src/Parser/FormatParserStorage.hpp

    r199763 ra42054  
    5252  XyzParser &getXyz();
    5353
    54   ParserTypes getType(std::string type);
     54  ParserTypes getTypeFromName(std::string type);
     55  ParserTypes getTypeFromSuffix(std::string type);
    5556
    5657  void SetOutputPrefixForAll(std::string &_prefix);
     
    7273
    7374  // default suffix of each parser type
    74   std::vector<std::string> ParserSuffix;
     75  std::map<ParserTypes, std::string> ParserSuffixes;
     76  std::map<std::string, ParserTypes> ParserLookupSuffixes;
    7577
    7678  // function pointers to each add...()
Note: See TracChangeset for help on using the changeset viewer.