Changeset 091838 for src/Parser


Ignore:
Timestamp:
Oct 26, 2011, 12:31:00 PM (13 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:
babcc1
Parents:
3a9091
git-author:
Frederik Heber <heber@…> (10/20/11 23:48:40)
git-committer:
Frederik Heber <heber@…> (10/26/11 12:31:00)
Message:

FormatParserStorage now explicitly needs to know which formats to store automatically.

  • new functions FormatParserStorage::setOutputFormat() for giving this info.
  • FormatParserStorage::SaveAll() only calls setOstream if the format is desired.
  • FIX: FormatParser_common::FormatParser_common() forget to initialize saveStream.
  • FormatParser_common::update() only stores when saveStream is not NULL, i.e. set.
  • SetOutputFormatsAction now uses add and setOutputFormat().
  • InputAction also adds the format of the input file.

Note that this is needed to allow various output formats for BondFragments in
Fragmentation without these formats eventually also being used for the writing
of the main input file.

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/FormatParserStorage.cpp

    r3a9091 r091838  
    4949  ParserStream.resize(ParserTypes_end, NULL);
    5050  ParserPresent.resize(ParserTypes_end, false);
     51  ParserDesiredOutputFormat.resize(ParserTypes_end, false);
    5152
    5253#include "ParserTypes.def"
     
    122123  for (ParserTypes iter = ParserTypes_begin; iter < ParserTypes_end; ++iter)
    123124    if (ParserPresent[iter]) {
    124       if (ParserStream[iter]->is_open())
    125         ParserStream[iter]->close();
    126       delete ParserStream[iter];
     125      if (ParserStream[iter] != NULL) {
     126        if (ParserStream[iter]->is_open())
     127          ParserStream[iter]->close();
     128        delete ParserStream[iter];
     129      }
    127130      delete ParserList[iter];
    128131    }
     
    137140};
    138141
    139 
     142/** Sets \a type as a format to be stored on call of SaveAll.
     143 *
     144 * @param type type to add to desired output formats
     145 */
     146void FormatParserStorage::setOutputFormat(ParserTypes type)
     147{
     148  LOG(0, "STATUS: Adding " << ParserNames[type] << " type to output.");
     149  ParserDesiredOutputFormat[type] = true;
     150}
     151
     152/** Sets \a type as a format to be stored on call of SaveAll.
     153 *
     154 * @param type type to add to desired output formats
     155 */
     156void FormatParserStorage::setOutputFormat(std::string type)
     157{
     158  std::map<std::string, ParserTypes>::const_iterator iter = ParserLookupNames.find(type);
     159  ASSERT(iter != ParserLookupNames.end(),
     160      "FormatParserStorage::setOutputFormat() - output format "+type+" is unknown.");
     161  setOutputFormat(iter->second);
     162}
     163
     164/** Saves the world in the desired output formats.
     165 *
     166 */
    140167void FormatParserStorage::SaveAll()
    141168{
    142169  std::string filename;
    143170  for (ParserTypes iter = ParserTypes_begin; iter < ParserTypes_end; ++iter)
    144     if (ParserPresent[iter]) {
     171    if (ParserPresent[iter] && ParserDesiredOutputFormat[iter]) {
    145172      filename = prefix;
    146173      filename += ".";
     
    174201  if (ptype != ParserTypes_end) {
    175202    if (ParserAddFunction.find(ptype) != ParserAddFunction.end()) {
    176       LOG(0, "STATUS: Adding " << ParserNames[ptype] << " type to output.");
    177203      (getInstance().*(ParserAddFunction[ptype]))(); // we still need an object to work on ...
    178204      return true;
  • src/Parser/FormatParserStorage.hpp

    r3a9091 r091838  
    4141  bool saveSelectedMolecules(std::ostream &output, std::string suffix);
    4242  bool saveWorld(std::ostream &output, std::string suffix);
     43
     44  void setOutputFormat(ParserTypes type);
     45  void setOutputFormat(std::string type);
    4346 
    4447  FormatParserInterface &get(ParserTypes _type);
     
    6366  // which parser is already present
    6467  std::vector<bool> ParserPresent;
     68
     69  // which parser is already present
     70  std::vector<bool> ParserDesiredOutputFormat;
    6571
    6672  // default suffix of each parser type
  • src/Parser/FormatParser_common.cpp

    r3a9091 r091838  
    3333 */
    3434FormatParser_common::FormatParser_common(FormatParser_Parameters *_parameters) :
    35   Observer("FormatParser_common")
     35  Observer("FormatParser_common"),
     36  saveStream(NULL)
    3637{
    3738  parameters = _parameters;
     
    5859 */
    5960void FormatParser_common::update(Observable *publisher) {
    60   if (!saveStream) {
    61     cerr << "Please invoke setOstream() so the parser knows where to save the World's data." << endl;
    62     return;
     61  if (saveStream != NULL) { // only store when a saveStream is given
     62    std::vector<atom *> atoms = World::getInstance().getAllAtoms();
     63    save(saveStream, atoms);
    6364  }
    64 
    65   std::vector<atom *> atoms = World::getInstance().getAllAtoms();
    66   save(saveStream, atoms);
    6765}
    6866
Note: See TracChangeset for help on using the changeset viewer.