Ignore:
Timestamp:
Oct 10, 2011, 2:27:06 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:
4151b0
Parents:
e611dc
git-author:
Frederik Heber <heber@…> (09/06/11 08:45:22)
git-committer:
Frederik Heber <heber@…> (10/10/11 14:27:06)
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser.cpp

    re611dc rc1db05  
    2525
    2626#include "MpqcParser.hpp"
     27#include "MpqcParser_Parameters.hpp"
    2728
    2829#include "atom.hpp"
     
    4243 */
    4344MpqcParser::MpqcParser()
    44 {}
     45{
     46  parameters = new MpqcParser_Parameters();
     47}
    4548
    4649/** Destructor of MpqcParser.
     
    4851 */
    4952MpqcParser::~MpqcParser()
    50 {}
     53{
     54  delete parameters;
     55}
    5156
    5257/** Load an MPQC config file into the World.
     
    123128        std::string value(*tok_iter);
    124129        std::stringstream linestream("theory = "+value);
    125         linestream >> params;
     130        linestream >> getParams();
    126131      } else if (linestring.find("integrals<") != string::npos) { // get theory
    127132        tokenizer tokens(linestring, angularsep);
     
    132137        std::string value(*tok_iter);
    133138        std::stringstream linestream("integration = "+value);
    134         linestream >> params;
     139        linestream >> getParams();
    135140      } else if ((linestring.find("molecule") == string::npos) && (linestring.find("basis") == string::npos)){
    136141        // molecule and basis must not be parsed in this section
     
    142147        std::string key;
    143148        whitespacefilter >> ws >> key;
    144         if (params.haveParam(key)) {
     149        if (getParams().haveParam(key)) {
    145150          std::stringstream linestream(linestring);
    146           linestream >> params;
     151          linestream >> getParams();
    147152        } else { // unknown keys are simply ignored as long as parser is incomplete
    148153          DoLog(2) && (Log() << Verbose(2) << "INFO: '"+key+"' is unknown and ignored." << std::endl);
     
    165170      if (key == "name") {
    166171        std::stringstream linestream("basis = "+value);
    167         linestream >> params;
     172        linestream >> getParams();
    168173      }
    169174    }
     
    183188      if (key == "name") {
    184189        std::stringstream linestream("aux_basis = "+value);
    185         linestream >> params;
     190        linestream >> getParams();
    186191      }
    187192    }
     
    227232    *file << "% Created by MoleCuilder" << endl;
    228233    *file << "mpqc: (" << endl;
    229     *file << "\tsavestate = " << params.getString(MpqcParser_Parameters::savestateParam) << endl;
    230     *file << "\tdo_gradient = " << params.getString(MpqcParser_Parameters::do_gradientParam) << endl;
    231     if (params.getBool(MpqcParser_Parameters::hessianParam)) {
     234    *file << "\tsavestate = " << getParams().getString(MpqcParser_Parameters::savestateParam) << endl;
     235    *file << "\tdo_gradient = " << getParams().getString(MpqcParser_Parameters::do_gradientParam) << endl;
     236    if (getParams().getBool(MpqcParser_Parameters::hessianParam)) {
    232237      *file << "\tfreq<MolecularFrequencies>: (" << endl;
    233238      *file << "\t\tmolecule=$:molecule" << endl;
    234239      *file << "\t)" << endl;
    235240    }
    236     switch (params.getTheory()) {
     241    switch (getParams().getTheory()) {
    237242      case MpqcParser_Parameters::CLHF:
    238         *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     243        *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    239244        *file << "\t\tmolecule = $:molecule" << endl;
    240245        *file << "\t\tbasis = $:basis" << endl;
    241         *file << "\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    242         *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     246        *file << "\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
     247        *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    243248        *file << "\t)" << endl;
    244249        break;
    245250      case MpqcParser_Parameters::CLKS:
    246         *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     251        *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    247252        *file << "\t\tfunctional<StdDenFunctional>:(name=B3LYP)" << endl;
    248253        *file << "\t\tmolecule = $:molecule" << endl;
    249254        *file << "\t\tbasis = $:basis" << endl;
    250         *file << "\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    251         *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     255        *file << "\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
     256        *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    252257        *file << "\t)" << endl;
    253258        break;
    254259      case MpqcParser_Parameters::MBPT2:
    255         *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     260        *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    256261        *file << "\t\tbasis = $:basis" << endl;
    257262        *file << "\t\tmolecule = $:molecule" << endl;
    258         *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     263        *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    259264        *file << "\t\treference<CLHF>: (" << endl;
    260         *file << "\t\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam))<< endl;
     265        *file << "\t\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam))<< endl;
    261266        *file << "\t\t\tbasis = $:basis" << endl;
    262267        *file << "\t\t\tmolecule = $:molecule" << endl;
    263         *file << "\t\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     268        *file << "\t\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    264269        *file << "\t\t)" << endl;
    265270        *file << "\t)" << endl;
    266271        break;
    267272      case MpqcParser_Parameters::MBPT2_R12:
    268         *file << "\tmole<" << params.getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
     273        *file << "\tmole<" << getParams().getString(MpqcParser_Parameters::theoryParam) << ">: (" << endl;
    269274        *file << "\t\tmolecule = $:molecule" << endl;
    270275        *file << "\t\tbasis = $:basis" << endl;
    271276        *file << "\t\taux_basis = $:abasis" << endl;
    272         *file << "\t\tstdapprox = \"" << params.getString(MpqcParser_Parameters::stdapproxParam) << "\"" << endl;
    273         *file << "\t\tnfzc = " << toString(params.getInt(MpqcParser_Parameters::nfzcParam)) << endl;
    274         *file << "\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
     277        *file << "\t\tstdapprox = \"" << getParams().getString(MpqcParser_Parameters::stdapproxParam) << "\"" << endl;
     278        *file << "\t\tnfzc = " << toString(getParams().getInt(MpqcParser_Parameters::nfzcParam)) << endl;
     279        *file << "\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
    275280        *file << "\t\tintegrals<IntegralCints>:()" << endl;
    276281        *file << "\t\treference<CLHF>: (" << endl;
    277282        *file << "\t\t\tmolecule = $:molecule" << endl;
    278283        *file << "\t\t\tbasis = $:basis" << endl;
    279         *file << "\t\t\tmaxiter = " << toString(params.getInt(MpqcParser_Parameters::maxiterParam)) << endl;
    280         *file << "\t\t\tmemory = " << toString(params.getInt(MpqcParser_Parameters::memoryParam)) << endl;
    281         *file << "\t\t\tintegrals<" << params.getString(MpqcParser_Parameters::integrationParam) << ">:()" << endl;
     284        *file << "\t\t\tmaxiter = " << toString(getParams().getInt(MpqcParser_Parameters::maxiterParam)) << endl;
     285        *file << "\t\t\tmemory = " << toString(getParams().getInt(MpqcParser_Parameters::memoryParam)) << endl;
     286        *file << "\t\t\tintegrals<" << getParams().getString(MpqcParser_Parameters::integrationParam) << ">:()" << endl;
    282287        *file << "\t\t)" << endl;
    283288        *file << "\t)" << endl;
     
    299304    *file << ")" << endl;
    300305    *file << "basis<GaussianBasisSet>: (" << endl;
    301     *file << "\tname = \"" << params.getString(MpqcParser_Parameters::basisParam) << "\"" << endl;
     306    *file << "\tname = \"" << getParams().getString(MpqcParser_Parameters::basisParam) << "\"" << endl;
    302307    *file << "\tmolecule = $:molecule" << endl;
    303308    *file << ")" << endl;
    304     if (params.getTheory() == MpqcParser_Parameters::MBPT2_R12) {
     309    if (getParams().getTheory() == MpqcParser_Parameters::MBPT2_R12) {
    305310      *file << "% auxiliary basis set specification" << endl;
    306311      *file << "\tabasis<GaussianBasisSet>: (" << endl;
    307       *file << "\tname = \"" << params.getString(MpqcParser_Parameters::aux_basisParam) << "\"" << endl;
     312      *file << "\tname = \"" << getParams().getString(MpqcParser_Parameters::aux_basisParam) << "\"" << endl;
    308313      *file << "\tmolecule = $:molecule" << endl;
    309314      *file << ")" << endl;
     
    312317}
    313318
    314 MpqcParser_Parameters & MpqcParser::getParams()
    315 {
    316   return params;
    317 }
    318 
     319
Note: See TracChangeset for help on using the changeset viewer.