Changeset bfd5d5f for src/UIElements


Ignore:
Timestamp:
Mar 24, 2016, 2:23:19 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:
6a7353
Parents:
1e1893
git-author:
Frederik Heber <heber@…> (03/16/16 10:20:09)
git-committer:
Frederik Heber <heber@…> (03/24/16 14:23:19)
Message:

QtObservedAtom and ..Molecule now have internal selfref.

  • this can be used to convert a ptr to the instance into a shared_ptr that can be sent around easily and safely.
  • QtObservedInstanceBoard is factory of QtObserved... and assigns them their self reference right after instantiation.
Location:
src/UIElements/Qt4/InstanceBoard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r1e1893 rbfd5d5f  
    5454  //!> typedef for instance wrapped in shared ptr
    5555  typedef boost::shared_ptr<QtObservedAtom> ptr;
     56
     57  //!> typedef for instance wrapped in weak shared ptr
     58  typedef boost::weak_ptr<QtObservedAtom> weak_ptr;
    5659
    5760private:
     
    246249
    247250private:
     251
     252  /** Internal setter for the weak shared_ptr instance that we sometimes
     253   * need to convert the ref to this instance into an shared ptr instance that
     254   * is safe to hand around.
     255   *
     256   * \param _selfref ref to shared ptr instance that is internally stored
     257   */
     258  void setSelfRef(const weak_ptr &_selfref)
     259  { const_cast<weak_ptr &>(selfref) = _selfref; }
     260
     261  //!> reference to this instance wrapped in a shared ptr for handing around
     262  const weak_ptr selfref;
     263
     264public:
     265
     266  /** Getter for this instance safely wrapped in a shared ptr instance for
     267   * handing arount.
     268   *
     269   * \return shared ptr of this instance
     270   */
     271  ptr getRef() const
     272  { return ptr(selfref); }
     273
     274private:
    248275  //!> contains still the old id after the index of the atom changed
    249276  atomId_t oldId;
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r1e1893 rbfd5d5f  
    140140                  _molecule,
    141141                  *this));
     142          observedmolecule->setSelfRef(observedmolecule);
    142143          moleculeObservedValues.insert(_id, observedmolecule);
    143144          // we need to check for index changes
     
    165166          QtObservedAtom::ptr observedatom(
    166167              new QtObservedAtom(_id, _atom, *this));
     168          observedatom->setSelfRef(observedatom);
    167169          atomObservedValues.insert(_id, observedatom);
    168170          // we need to check for index changes
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    r1e1893 rbfd5d5f  
    5151  //!> typedef for instance wrapped in shared ptr
    5252  typedef boost::shared_ptr<QtObservedMolecule> ptr;
     53
     54  //!> typedef for instance wrapped in shared ptr
     55  typedef boost::weak_ptr<QtObservedMolecule> weak_ptr;
    5356
    5457private:
     
    269272
    270273private:
     274
     275  /** Internal setter for the weak shared_ptr instance that we sometimes
     276   * need to convert the ref to this instance into an shared ptr instance that
     277   * is safe to hand around.
     278   *
     279   * \param _selfref ref to shared ptr instance that is internally stored
     280   */
     281  void setSelfRef(const weak_ptr &_selfref)
     282  { const_cast<weak_ptr &>(selfref) = _selfref; }
     283
     284  //!> reference to this instance wrapped in a shared ptr for handing around
     285  const weak_ptr selfref;
     286
     287public:
     288
     289  /** Getter for this instance safely wrapped in a shared ptr instance for
     290   * handing arount.
     291   *
     292   * \return shared ptr of this instance
     293   */
     294  ptr getRef() const
     295  { return ptr(selfref); }
     296
     297private:
    271298  //!> contains still the old index after the index changed
    272299  moleculeId_t oldId;
Note: See TracChangeset for help on using the changeset viewer.