source: src/Parser/FormatParser.cpp@ bcedf7

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
Last change on this file since bcedf7 was c1db05, checked in by Frederik Heber <heber@…>, 13 years ago

Abstracted FormatParser_Parameters and made it "Clone"able.

  • this is preparatory for having an undoable LoadAction.
  • is so far only used by MpqcParser_Parameters.
  • FormatParser_Parameters::clone() clones the instance (uses CodePattern's Clone pattern).
  • FormatParser has pointer to FormatParser_Parameters.
  • MpqcParser now has parameters as inheritance from FormatParser, allocates in cstor, removes in dstor.
  • new function MpqcParser_Parameters::makeClone() sets instance to be a copy of the given one.
  • MpqcParser: replaced direct access to params by getParams().
  • added ParameterCloneTest to ParserMpqcUnitTest.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * FormatParser.cpp
10 *
11 * Created on: Mar 1, 2010
12 * Author: metzler
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "FormatParser.hpp"
23#include <iostream>
24
25using namespace std;
26
27/**
28 * Constructor.
29 */
30FormatParser::FormatParser() :
31 Observer("FormatParser"),
32 parameters(NULL),
33 saveStream(NULL)
34{
35 ChangeTracker::getInstance().signOn(this);
36 World::getInstance().signOn(this, World::getInstance().getChannel(World::AtomInserted));
37 World::getInstance().signOn(this, World::getInstance().getChannel(World::AtomRemoved));
38}
39
40/**
41 * Destructor.
42 */
43FormatParser::~FormatParser() {
44 ChangeTracker::getInstance().signOff(this);
45 World::getInstance().signOff(this, World::getInstance().getChannel(World::AtomInserted));
46 World::getInstance().signOff(this, World::getInstance().getChannel(World::AtomRemoved));
47}
48
49/**
50 * Update operation which can be invoked by the observable (which should be the
51 * change tracker here).
52 */
53void FormatParser::update(Observable *publisher) {
54 if (!saveStream) {
55 cerr << "Please invoke setOstream() so the parser knows where to save the World's data." << endl;
56 return;
57 }
58
59 std::vector<atom *> atoms = World::getInstance().getAllAtoms();
60 save(saveStream, atoms);
61}
62
63/**
64 * With this, each format parser is informed about specific changes in the World.
65 */
66void FormatParser::recieveNotification(Observable *publisher, Notification_ptr notification) {
67 switch (notification->getChannelNo()) {
68 case World::AtomInserted:
69 AtomInserted(World::getInstance().lastChanged<atom>()->getId());
70 break;
71 case World::AtomRemoved:
72 AtomRemoved(World::getInstance().lastChanged<atom>()->getId());
73 break;
74 default:
75 ASSERT(0,
76 "FormatParser::recieveNotification() - unknown notification "
77 +toString(notification->getChannelNo())+" received.");
78 break;
79 }
80}
81
82/**
83 * The observable can tell when it dies.
84 */
85void FormatParser::subjectKilled(Observable *publisher) {}
86
87
88/**
89 * Sets the output stream for save, so the save() method can be invoked on update
90 * automatically.
91 *
92 * \param ostream where to save the World's state
93 */
94void FormatParser::setOstream(ostream* output) {
95 saveStream = output;
96}
Note: See TracBrowser for help on using the repository browser.