Ignore:
Timestamp:
Oct 6, 2011, 4:06:10 PM (14 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, Candidate_v1.7.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:
37b2575
Parents:
7188b1
git-author:
Frederik Heber <heber@…> (09/01/11 16:25:34)
git-committer:
Frederik Heber <heber@…> (10/06/11 16:06:10)
Message:

BondedParticle:: register and unregister are private.

  • adding and removing bonds is possible via addBond(), removeBond().
  • this wat we encapsulate the register and unregister and make sure that never a lone bond remains at one side.
  • adapted:
  • Register and UnregisterBond are OBSERVEd.
  • bond::Contains() is const member function now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom_bondedparticle.cpp

    r7188b1 rdb7e6d  
    2727#include "CodePatterns/Verbose.hpp"
    2828#include "element.hpp"
     29#include "WorldTime.hpp"
    2930
    3031/** Constructor of class BondedParticle.
     
    9394
    9495/**
    95  * Adds a bond between this bonded particle and another. Does nothing if this
     96 * Adds a bond between this bonded particle and another. Returns present instance if this
    9697 * bond already exists.
    9798 *
    9899 * @param _step time step to access
    99  * \param bonding partner
    100  */
    101 void BondedParticle::addBond(const unsigned int _step, BondedParticle* Partner) {
    102   if (IsBondedTo(_step, Partner)) {
    103     return;
     100 * @param bonding partner
     101 * @return const reference to created bond or to already present bonds
     102 */
     103const bond * BondedParticle::addBond(const unsigned int _step, BondedParticle* Partner)
     104{
     105  const BondList &bondlist = getListOfBondsAtStep(_step);
     106  for (BondList::const_iterator runner = bondlist.begin();
     107      runner != bondlist.end();
     108      runner++) {
     109    if ((*runner)->Contains(Partner))
     110      return *runner;
    104111  }
    105112
     
    107114  RegisterBond(_step, newBond);
    108115  Partner->RegisterBond(_step, newBond);
     116
     117  return newBond;
     118}
     119
     120/** Removes a bond for this atom.
     121 *
     122 * @param Binder bond to remove
     123 */
     124void BondedParticle::removeBond(bond * binder)
     125{
     126  UnregisterBond(binder);
    109127}
    110128
     
    115133bool BondedParticle::RegisterBond(const unsigned int _step, bond *Binder)
    116134{
     135  OBSERVE;
    117136  bool status = false;
    118137  if (Binder != NULL) {
    119138    if (Binder->Contains(this)) {
     139      if (WorldTime::getTime() == _step)
     140        NOTIFY(AtomObservable::BondsChanged);
    120141      //LOG(3,"INFO: Registering bond "<< *Binder << " with atom " << *this << " at step " << _step);
    121142      BondList& ListOfBonds = getListOfBondsAtStep(_step);
     
    137158bool BondedParticle::UnregisterBond(bond *Binder)
    138159{
     160  OBSERVE;
    139161  bool status = false;
    140162  ASSERT(Binder != NULL, "BondedParticle::UnregisterBond() - Binder is NULL.");
    141163  const int step = ContainsBondAtStep(Binder);
    142164  if (step != -1) {
     165    NOTIFY(AtomObservable::BondsChanged);
    143166    //LOG(3,"INFO: Unregistering bond "<< *Binder << " from list " << &ListOfBonds << " of atom " << *this << " at step " << step);
    144167    ListOfBonds[step].remove(Binder);
     
    164187void BondedParticle::ClearBondsAtStep(const unsigned int _step)
    165188{
     189  OBSERVE;
     190  if (WorldTime::getTime() == _step)
     191    NOTIFY(AtomObservable::BondsChanged);
    166192  //LOG(3,"INFO: Clearing all bonds of " << *this << ": " << ListOfBonds[_step]);
    167193  for (BondList::iterator iter = (ListOfBonds[_step]).begin();
     
    178204 * @return >=0 - first time step where bond appears, -1 - bond not present in lists
    179205 */
    180 int BondedParticle::ContainsBondAtStep(bond *Binder)
     206int BondedParticle::ContainsBondAtStep(bond *Binder) const
    181207{
    182208  int step = -1;
     
    205231int BondedParticle::CorrectBondDegree()
    206232{
     233  OBSERVE;
     234  NOTIFY(AtomObservable::BondsChanged);
    207235  int NoBonds = 0;
    208236  int OtherNoBonds = 0;
Note: See TracChangeset for help on using the changeset viewer.