Ignore:
Timestamp:
Aug 28, 2010, 1:45:13 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, Candidate_v1.7.0, 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:
6c438f
Parents:
8fd934 (diff), 653542 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into StructureRefactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/FormatParserStorage.cpp

    r8fd934 rfd4905  
    2828#include "Parser/MpqcParser.hpp"
    2929#include "Parser/PcpParser.hpp"
     30#include "Parser/PdbParser.hpp"
    3031#include "Parser/TremoloParser.hpp"
    3132#include "Parser/XyzParser.hpp"
     
    5657  ParserSuffix.resize(ParserTypes_end, "");
    5758
     59  ParserNames[mpqc] = "mpqc";
     60  ParserNames[pcp] = "pcp";
     61  ParserNames[pdb] = "pdb";
     62  ParserNames[tremolo] = "tremolo";
     63  ParserNames[xyz] = "xyz";
     64
     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
    5868  ParserSuffix[mpqc] = "in";
    5969  ParserSuffix[pcp] = "conf";
     70  ParserSuffix[pdb] = "pdb";
    6071  ParserSuffix[tremolo] = "data";
    6172  ParserSuffix[xyz] = "xyz";
     73
     74  ParserAddFunction[mpqc] = &FormatParserStorage::addMpqc;
     75  ParserAddFunction[pcp] = &FormatParserStorage::addPcp;
     76  ParserAddFunction[pdb] = &FormatParserStorage::addPdb;
     77  ParserAddFunction[tremolo] = &FormatParserStorage::addTremolo;
     78  ParserAddFunction[xyz] = &FormatParserStorage::addXyz;
    6279}
    6380
     
    112129}
    113130
     131
    114132/** Adds an PcpParser to the storage.
    115133 */
     
    124142
    125143
     144/** Adds an PdbParser to the storage.
     145 */
     146void FormatParserStorage::addPdb()
     147{
     148  if (!ParserPresent[pdb]) {
     149    ParserList[pdb] = new PdbParser();
     150    ParserPresent[pdb] = true;
     151  } else
     152    DoeLog(1) && (eLog() << Verbose(1) << "Parser pdb is already present." << endl);
     153}
     154
     155
    126156/** Adds an TremoloParser to the storage.
    127157 */
     
    146176    DoeLog(1) && (eLog() << Verbose(1) << "Parser xyz is already present." << endl);
    147177}
     178
     179ParserTypes FormatParserStorage::getType(std::string type)
     180{
     181  if (ParserLookupNames.find(type) == ParserLookupNames.end()) {
     182    DoeLog(1) && (eLog() << Verbose(1) << "Unknown type " << type << "." << endl);
     183    return ParserTypes_end;
     184  } else
     185    return ParserLookupNames[type];
     186}
     187
     188bool FormatParserStorage::add(ParserTypes ptype)
     189{
     190  if (ptype != ParserTypes_end) {
     191    if (ParserAddFunction.find(ptype) != ParserAddFunction.end()) {
     192      DoLog(0) && (Log() << Verbose(0) << "Adding " << ParserNames[ptype] << " type to output." << endl);
     193      (getInstance().*(ParserAddFunction[ptype]))(); // we still need an object to work on ...
     194      return true;
     195    } else {
     196      DoeLog(1) && (eLog() << Verbose(1) << "No parser to add for this known type " << ParserNames[ptype] << ", not implemented?" << endl);
     197      return false;
     198    }
     199  } else {
     200    return false;
     201  }
     202}
     203
     204bool FormatParserStorage::add(std::string type)
     205{
     206  return add(getType(type));
     207}
     208
    148209
    149210/** Parses an istream depending on its suffix
     
    158219  } else if (suffix == ParserSuffix[pcp]) {
    159220    getPcp().load(&input);
     221  } else if (suffix == ParserSuffix[pdb]) {
     222    getPdb().load(&input);
    160223  } else if (suffix == ParserSuffix[tremolo]) {
    161224    getTremolo().load(&input);
     
    163226    getXyz().load(&input);
    164227  } else {
    165     DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix to for FormatParserStorage::get()." << endl);
     228    DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix " << suffix << " to for FormatParserStorage::get()." << endl);
    166229    return false;
    167230  }
     
    189252}
    190253
     254/** Returns reference to the output PdbParser, adds if not present.
     255 * \return reference to the output PdbParser
     256 */
     257PdbParser &FormatParserStorage::getPdb()
     258{
     259  if (!ParserPresent[pdb])
     260    addPdb();
     261  return dynamic_cast<PdbParser &>(*ParserList[pdb]);
     262}
     263
    191264/** Returns reference to the output TremoloParser, adds if not present.
    192265 * \return reference to the output TremoloParser
Note: See TracChangeset for help on using the changeset viewer.