Ignore:
Timestamp:
Feb 12, 2016, 11:15:04 PM (9 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:
2831b3
Parents:
e25448
git-author:
Frederik Heber <heber@…> (10/16/15 11:51:16)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:04)
Message:

FIX: All ObservedValue's of GLMoleculeObject_atom/bond/molecule wrapped into vector.

  • the idea is that a GLMoleculeObject may only remove itself _after_ each and every contained Observer has gotten the subjectKilled() signal from the Observables. Only then will destroying the Object and its members thereby not cause any signOff() which try to access Observables or their channels which are no longer present. This can be imagined as a graph where we have to start destroying object at the very bottom.
  • This is the avoid the following conflict: A superior object gets note of a molecule to be removed. It sends the visual representation a signal to remove itself, which causes it to use signOff(). On a parallel track (in another thread) we have the observed object calling subjectKilled() to inform any Observer about its immediate destruction. These two tracks collide. Now, we let first pass all subjectKilled() and when the last Observable has gotten its signal, we begin destroying the visual rep.
  • rerouted signal/slots accordingly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp

    re25448 r7c7c4a  
    1515
    1616#include "GLMoleculeObject.hpp"
     17
     18#include <vector>
     19#include <boost/any.hpp>
    1720
    1821#include "CodePatterns/Observer/Observer.hpp"
     
    7073
    7174private:
    72   /** This must be called from subjectKilled() only.
    73    *
    74    * We remove from all other Observables in a controlled manner.
    75    *
    76    * removeBond(), and removeChannels() must have been called before (or one of
    77    * the subjects has been killed).
    78    *
    79    */
    80   void removeMe();
    8175  void removeChannels();
    8276
     
    10599  const enum SideOfBond BondSide;
    106100
    107   ObservedValue<Vector> leftPosition;
    108   ObservedValue<Vector> rightPosition;
    109   ObservedValue<atomicNumber_t> leftElement;
    110   ObservedValue<atomicNumber_t> rightElement;
    111   ObservedValue<int> Degree;
     101
     102private:
     103  /** Observed Values **/
     104
     105  //!> enumeration of observed values to match with entries in ObservedValues
     106  enum ObservedTypes {
     107    //!> contains the position of the left atom
     108    leftPosition,
     109    //!> contains the position of the right atom
     110    rightPosition,
     111    //!> contains the element of the left atom
     112    leftElement,
     113    //!> contains the element of the right atom
     114    rightElement,
     115    //!> contains the degree of the bond
     116    Degree,
     117    //!> gives the size of the enumeration
     118    MAX_ObservedTypes
     119  };
     120
     121  //!> vector with all observed values
     122  std::vector<boost::any> ObservedValues;
     123
     124  /** Initializes all \a ObservedValues entries.
     125   *
     126   */
     127  void initObservedValues();
     128
     129  /** Destroys all \a ObservedValues entries.
     130   *
     131   */
     132  void destroyObservedValues();
     133
     134  /** Getter to left atom's position contained in \a ObservedValues.
     135   *
     136   * \return left atom's position
     137   */
     138  Vector getleftPosition() const;
     139
     140  /** Getter to right atom's position contained in \a ObservedValues.
     141   *
     142   * \return right atom's position
     143   */
     144  Vector getrightPosition() const;
     145
     146  /** Getter to left atom's element contained in \a ObservedValues.
     147   *
     148   * \return left atom's element
     149   */
     150  atomicNumber_t getleftElement() const;
     151
     152  /** Getter to rightatom's element contained in \a ObservedValues.
     153   *
     154   * \return right atom's element
     155   */
     156  atomicNumber_t getrightElement() const;
     157
     158  /** Getter to bond's degree contained in \a ObservedValues.
     159   *
     160   * \return bond's degree
     161   */
     162  int getDegree() const;
     163
     164  /** Counts how many ObservedValues got subjectKilled.
     165   *
     166   * This is used to give InstanceRemoved() signal only when each and every
     167   * ObservedValue (and the instance itself) has been subjectKilled by the
     168   * monitored Observable. Only then can we safely remove the instance.
     169   *
     170   */
     171  void countsubjectKilled();
     172
     173  //!> counts how many ObservedValues have already been subjectKilled()
     174  mutable size_t subjectKilledCount;
     175
     176private:
    112177
    113178  //!> indicate whether we are signed in to leftobservable
Note: See TracChangeset for help on using the changeset viewer.