Changeset 04c3a3 for src/UIElements
- Timestamp:
- Feb 14, 2016, 12:33:42 PM (9 years ago)
- 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:
- 4e6ffe
- Parents:
- b2c2e4
- git-author:
- Frederik Heber <heber@…> (01/25/16 14:15:23)
- git-committer:
- Frederik Heber <heber@…> (02/14/16 12:33:42)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp
rb2c2e4 r04c3a3 43 43 signedOnChannels(std::max((size_t)1,_channels.size())), 44 44 callback(_callback), 45 CallbackIsGone(false), 45 46 getId(_getId) 46 47 {} … … 48 49 {} 49 50 51 /** Function is called by callback owner to inform about its destruction. 52 * 53 * \note callback must not be used after this 54 */ 55 void noteCallBackIsGone() 56 { CallbackIsGone = true; } 57 50 58 protected: 51 59 virtual void subjectKilled(Observable *publisher) 52 60 { 53 ObservedValue<T>::subjectKilled(publisher);54 61 ASSERT(signedOnChannels > 0, 55 62 "ObservedValue_wCallback::subjectKilled() - signedOnChannels is already zero."); 56 if ((--signedOnChannels) == 0) 57 callback(getId()); 63 if ((--signedOnChannels) == 0) { 64 ObservedValue<T>::subjectKilled(publisher); 65 if (!CallbackIsGone) 66 callback(getId()); 67 } 58 68 } 59 69 … … 63 73 //!> callback function to tell other entity about subjectKilled 64 74 const boost::function<void(const id)> callback; 75 //!> is callback still alive or not 76 bool CallbackIsGone; 77 //!> callback function to get id 65 78 const boost::function<const id()> getId; 66 79 }; … … 94 107 signedOnChannels(std::max((size_t)1,_channels.size())), 95 108 callback(_callback), 109 CallbackIsGone(false), 96 110 getId(_getId) 97 111 {} … … 106 120 signedOnChannels(std::max((size_t)1,_channels.size())), 107 121 callback(_callback), 122 CallbackIsGone(false), 108 123 getId(boost::bind(&ObservedValue<T>::get, this)) 109 124 {} 110 125 virtual ~ObservedValue_wCallback() 111 126 {} 127 128 /** Function is called by callback owner to inform about its destruction. 129 * 130 * \note callback must not be used after this 131 */ 132 void noteCallBackIsGone() 133 { CallbackIsGone = true; } 112 134 113 135 protected: … … 118 140 "ObservedValue_wCallback::subjectKilled() - signedOnChannels is already zero."); 119 141 if ((--signedOnChannels) == 0) 120 callback(getId()); 142 ObservedValue<T>::subjectKilled(publisher); 143 if (!CallbackIsGone) 144 callback(getId()); 121 145 } 122 146 … … 126 150 //!> callback function to tell other entity about subjectKilled 127 151 const boost::function<void(const T)> callback; 152 //!> is callback still alive or not 153 bool CallbackIsGone; 154 //!> callback function to get id 128 155 const boost::function<const T()> getId; 129 156 }; -
src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp
rb2c2e4 r04c3a3 48 48 QtObservedInstanceBoard &_board, 49 49 const onDestroy_t _onDestroy); 50 51 /** Destor of class ObservedValuesContainer. 52 * 53 */ 54 ~ObservedValuesContainer(); 50 55 51 56 /** Delivers the set of Observed value for the instance identified by \a _id. -
src/UIElements/Qt4/InstanceBoard/ObservedValuesContainer_impl.hpp
rb2c2e4 r04c3a3 28 28 onDestroy(_onDestroy) 29 29 {} 30 31 template <class T, typename id> 32 ObservedValuesContainer<T,id>::~ObservedValuesContainer() 33 { 34 for (typename CountedObservedValues_t::iterator iter = ObservedValues.begin(); 35 iter != ObservedValues.end(); ++iter) 36 iter->second.first->noteBoardIsGone(); 37 } 30 38 31 39 template <class T, typename id> -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
rb2c2e4 r04c3a3 98 98 owner(NULL), 99 99 board(_board), 100 BoardIsGone(false), 100 101 ObservedValues(_ObservedValues) 101 102 { … … 105 106 QtObservedAtom::~QtObservedAtom() 106 107 { 108 boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->noteCallBackIsGone(); 109 boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone(); 110 boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone(); 111 boost::any_cast<ObservedValue_wCallback<moleculeId_t, atomId_t> *>(ObservedValues[AtomMoleculeIndex])->noteCallBackIsGone(); 112 boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->noteCallBackIsGone(); 113 boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone(); 114 107 115 deactivateObserver(); 108 116 } … … 201 209 owner = NULL; 202 210 203 board.markObservedAtomAsDisconnected(getAtomIndex()); 211 if (!BoardIsGone) 212 board.markObservedAtomAsDisconnected(getAtomIndex()); 204 213 205 214 emit atomRemoved(); … … 246 255 iter != channels.end(); ++iter) 247 256 owner->signOn(this, *iter); 257 if (!BoardIsGone) 258 board.markObservedAtomAsConnected(getAtomIndex()); 248 259 } else 249 signedOffChannels = getAllObservedChannels().size();260 signedOffChannels = AllsignedOnChannels; 250 261 } 251 262 … … 260 271 owner = NULL; 261 272 signedOffChannels = AllsignedOnChannels; 262 board.markObservedAtomAsDisconnected(getAtomIndex()); 273 if (!BoardIsGone) 274 board.markObservedAtomAsDisconnected(getAtomIndex()); 263 275 } 264 276 } -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
rb2c2e4 r04c3a3 191 191 std::vector<boost::any> &_ObservedValues); 192 192 193 /** Function is called by InstanceBoard to inform about its destruction. 194 * 195 * \note callbacks must not be used after this 196 */ 197 void noteBoardIsGone() 198 { BoardIsGone = true; } 199 193 200 //!> counts how many ObservedValues have already been subjectKilled() 194 201 mutable size_t subjectKilledCount; … … 221 228 QtObservedInstanceBoard & board; 222 229 230 //!> is board still alive or not, impacts callbacks 231 bool BoardIsGone; 232 223 233 //!> internal reference to ObservedValues held by QtObservedInstanceBoard 224 234 ObservedValues_t ObservedValues; -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
rb2c2e4 r04c3a3 35 35 36 36 #include "QtObservedInstanceBoard.hpp" 37 38 #include <QtCore/QMetaType> 37 39 38 40 #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp" … … 76 78 lastremovedmolecule((moleculeId_t)-1) 77 79 { 80 qRegisterMetaType<QtObservedAtom::ptr>("QtObservedAtom::ptr"); 81 qRegisterMetaType<QtObservedMolecule::ptr>("QtObservedMolecule::ptr"); 82 78 83 // be first (besides ObservedValues to know about new insertions) 79 84 World::getInstance().signOn(this, World::AtomInserted, GlobalObservableInfo::PriorityLevel(int(-10))); -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
rb2c2e4 r04c3a3 108 108 owner(NULL), 109 109 board(_board), 110 BoardIsGone(false), 110 111 ObservedValues(_ObservedValues) 111 112 { … … 115 116 QtObservedMolecule::~QtObservedMolecule() 116 117 { 118 boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->noteCallBackIsGone(); 119 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->noteCallBackIsGone(); 120 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[BondCount])->noteCallBackIsGone(); 121 boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->noteCallBackIsGone(); 122 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->noteCallBackIsGone(); 123 boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(ObservedValues[MolCenter])->noteCallBackIsGone(); 124 boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->noteCallBackIsGone(); 125 boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone(); 126 117 127 deactivateObserver(); 118 128 } … … 127 137 owner = NULL; 128 138 signedOffChannels = AllsignedOnChannels; 129 board.markObservedMoleculeAsDisconnected(getMolIndex()); 139 if (!BoardIsGone) 140 board.markObservedMoleculeAsDisconnected(getMolIndex()); 130 141 } 131 142 } … … 141 152 iter != channels.end(); ++iter) 142 153 owner->signOn(this, *iter); 154 if (!BoardIsGone) 155 board.markObservedMoleculeAsConnected(getMolIndex()); 143 156 } else 144 157 signedOffChannels = AllsignedOnChannels; … … 159 172 owner = NULL; 160 173 161 board.markObservedMoleculeAsDisconnected(getMolIndex()); 174 if (!BoardIsGone) 175 board.markObservedMoleculeAsDisconnected(getMolIndex()); 162 176 163 177 emit moleculeRemoved(); … … 376 390 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]); 377 391 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[BondCount]); 392 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]); 378 393 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]); 379 394 delete boost::any_cast<ObservedValue_wCallback<Vector, moleculeId_t> *>(_ObservedValues[MolCenter]); 380 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);381 395 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]); 382 396 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]); -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
rb2c2e4 r04c3a3 188 188 //!> enumeration of observed values to match with entries in ObservedValues 189 189 enum ObservedTypes { 190 //!> contains the current molecule index 191 MolIndex, 190 192 //!> contains the current molecule's atom count 191 193 AtomCount, … … 198 200 //!> contains the current molecule's center 199 201 MolCenter, 200 //!> contains the current molecule index201 MolIndex,202 202 //!> contains the current molecule name 203 203 MolName, … … 228 228 std::vector<boost::any> &_ObservedValues); 229 229 230 /** Function is called by InstanceBoard to inform about its destruction. 231 * 232 * \note callbacks must not be used after this 233 */ 234 void noteBoardIsGone() 235 { BoardIsGone = true; } 236 230 237 //!> counts how many ObservedValues have already been subjectKilled() 231 238 mutable size_t subjectKilledCount; … … 245 252 QtObservedInstanceBoard & board; 246 253 254 //!> is board still alive or not, impacts callbacks 255 bool BoardIsGone; 256 247 257 //!> internal reference to ObservedValues held by QtObservedInstanceBoard 248 258 ObservedValues_t ObservedValues;
Note:
See TracChangeset
for help on using the changeset viewer.