Changeset f721c6


Ignore:
Timestamp:
Feb 2, 2010, 4:22:22 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
9ad391
Parents:
ac9b56
Message:

Made more methods of the molecule observable

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Observer.hpp

    rac9b56 rf721c6  
    2020 * Observation blocks from there, these functions wont trigger notifications. Only the end
    2121 * of the final observation block triggers the update of Observers.
     22 *
     23 * Returning from observed code should be done using the RETURN_OBSERVER() macro. This way the Observer mechanism
     24 * is notified that the method is left.
    2225 *
    2326 * Each observerable can have sub-observables. When one of these sub-observables changes and
     
    7881#define START_OBSERVER Observable::start_observer_internal(this);do{do{}while(0)
    7982#define FINISH_OBSERVER }while(0);Observable::finish_observer_internal(this)
     83#define RETURN_OBSERVER( retval ) do{Observable::finish_observer_internal(this); return (retval);}while(0)
    8084#endif /* OBSERVER_HPP_ */
  • src/molecule.cpp

    rac9b56 rf721c6  
    103103bool molecule::AddAtom(atom *pointer)
    104104{
     105  bool retval = false;
     106  START_OBSERVER;
    105107  if (pointer != NULL) {
    106108    pointer->sort = &pointer->nr;
     
    119121      }
    120122    }
    121     return add(pointer, end);
    122   } else
    123     return false;
     123    retval = add(pointer, end);
     124  }
     125  FINISH_OBSERVER;
     126  return retval;
    124127};
    125128
     
    131134atom * molecule::AddCopyAtom(atom *pointer)
    132135{
     136  atom *retval = NULL;
     137  START_OBSERVER;
    133138  if (pointer != NULL) {
    134139    atom *walker = new atom(pointer);
     
    140145      NoNonHydrogen++;
    141146    AtomCount++;
    142     return walker;
    143   } else
    144     return NULL;
     147    retval=walker;
     148  }
     149  FINISH_OBSERVER;
     150  return retval;
    145151};
    146152
     
    181187bool molecule::AddHydrogenReplacementAtom(bond *TopBond, atom *BottomOrigin, atom *TopOrigin, atom *TopReplacement, bool IsAngstroem)
    182188{
     189  bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
     190  START_OBSERVER;
    183191  double bondlength;  // bond length of the bond to be replaced/cut
    184192  double bondangle;  // bond angle of the bond to be replaced/cut
    185193  double BondRescale;   // rescale value for the hydrogen bond length
    186   bool AllWentWell = true;    // flag gathering the boolean return value of molecule::AddAtom and other functions, as return value on exit
    187194  bond *FirstBond = NULL, *SecondBond = NULL; // Other bonds in double bond case to determine "other" plane
    188195  atom *FirstOtherAtom = NULL, *SecondOtherAtom = NULL, *ThirdOtherAtom = NULL; // pointer to hydrogen atoms to be added
     
    228235  if (BondRescale == -1) {
    229236    eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
    230     return false;
     237    RETURN_OBSERVER(false);
    231238    BondRescale = bondlength;
    232239  } else {
     
    308315      if (bondangle == -1) {
    309316        eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
    310         return false;
     317        RETURN_OBSERVER(false);
    311318        bondangle = 0;
    312319      }
     
    435442  Free(&matrix);
    436443
     444  FINISH_OBSERVER;
    437445//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
    438446  return AllWentWell;
     
    446454bool molecule::AddXYZFile(string filename)
    447455{
     456
    448457  istringstream *input = NULL;
    449458  int NumberOfAtoms = 0; // atom number in xyz read
     
    459468    return false;
    460469
     470  START_OBSERVER;
    461471  getline(xyzfile,line,'\n'); // Read numer of atoms in file
    462472  input = new istringstream(line);
     
    499509  xyzfile.close();
    500510  delete(input);
     511  FINISH_OBSERVER;
    501512  return true;
    502513};
Note: See TracChangeset for help on using the changeset viewer.