Changeset d48a16
- Timestamp:
- Apr 20, 2016, 11:04:53 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:
- e4b13a
- Parents:
- 96f14a
- git-author:
- Frederik Heber <heber@…> (03/23/16 10:02:43)
- git-committer:
- Frederik Heber <heber@…> (04/20/16 23:04:53)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/ObservedValue_wCallback.hpp
r96f14a rd48a16 38 38 const T &_initialvalue, 39 39 const Observable::channels_t &_channels, 40 const boost::function<void(const id)> &_callback, 41 const boost::function<const id()> &_getId) : 40 const boost::function<void()> &_callback) : 42 41 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels), 43 42 signedOnChannels(std::max((size_t)1,_channels.size())), 44 43 callback(_callback), 45 CallbackIsGone(false), 46 getId(_getId) 44 CallbackIsGone(false) 47 45 {} 48 46 virtual ~ObservedValue_wCallback() … … 64 62 ObservedValue<T>::subjectKilled(publisher); 65 63 if (!CallbackIsGone) 66 callback( getId());64 callback(); 67 65 } 68 66 } … … 72 70 size_t signedOnChannels; 73 71 //!> callback function to tell other entity about subjectKilled 74 const boost::function<void( const id)> callback;72 const boost::function<void()> callback; 75 73 //!> is callback still alive or not 76 74 bool CallbackIsGone; 77 //!> callback function to get id78 const boost::function<const id()> getId;79 };80 81 /** Specialization of ObservedValue_wCallback for the index ObservedValue.82 *83 * The index serves as the unique identifier for the object instance whose84 * properties are monitored in ObservedValue. Hence, how to give a subjectKilled()85 * with an external getId() function? For the index the ObservedValue::get() is86 * the getId() we need to call! Hence, we may simply connect these internally87 * in this partial template specialization.88 *89 * Because atomicNumber_t, atomId_t and moleculeId_t are not unique types but90 * -- at the writing of this class -- just typedefs, we have to resort to the91 * trick with two constructors, one taking an external getId(), the other92 * routing the getId() internally by binding to ObservedValue<T>::get().93 */94 template <class T>95 class ObservedValue_wCallback<T,T> : public ObservedValue<T>96 {97 public:98 ObservedValue_wCallback(99 const Observable * const _owner,100 const boost::function<T()> &_recalcMethod,101 const std::string &_name,102 const T &_initialvalue,103 const Observable::channels_t &_channels,104 const boost::function<void(const T)> &_callback,105 const boost::function<const T()> &_getId) :106 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels),107 signedOnChannels(std::max((size_t)1,_channels.size())),108 callback(_callback),109 CallbackIsGone(false),110 getId(_getId)111 {}112 ObservedValue_wCallback(113 const Observable * const _owner,114 const boost::function<T()> &_recalcMethod,115 const std::string &_name,116 const T &_initialvalue,117 const Observable::channels_t &_channels,118 const boost::function<void(const T)> &_callback) :119 ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels),120 signedOnChannels(std::max((size_t)1,_channels.size())),121 callback(_callback),122 CallbackIsGone(false),123 getId(boost::bind(&ObservedValue<T>::get, this))124 {}125 virtual ~ObservedValue_wCallback()126 {}127 128 /** Function is called by callback owner to inform about its destruction.129 *130 * \note callback must not be used after this131 */132 void noteCallBackIsGone()133 { CallbackIsGone = true; }134 135 protected:136 virtual void subjectKilled(Observable *publisher)137 {138 ObservedValue<T>::subjectKilled(publisher);139 ASSERT(signedOnChannels > 0,140 "ObservedValue_wCallback::subjectKilled() - signedOnChannels is already zero.");141 if ((--signedOnChannels) == 0)142 ObservedValue<T>::subjectKilled(publisher);143 if (!CallbackIsGone)144 callback(getId());145 }146 147 private:148 //!> if we are signOn() to multiple channels, count down before callback149 size_t signedOnChannels;150 //!> callback function to tell other entity about subjectKilled151 const boost::function<void(const T)> callback;152 //!> is callback still alive or not153 bool CallbackIsGone;154 //!> callback function to get id155 const boost::function<const T()> getId;156 75 }; 157 76 -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
r96f14a rd48a16 106 106 ObservedValues(QtObservedAtom::MAX_ObservedTypes) 107 107 { 108 boost::function<void ( ObservedValue_Index_t)> atomSubjectKilled(108 boost::function<void ()> atomSubjectKilled( 109 109 boost::bind(&QtObservedAtom::countValuesSubjectKilled, 110 110 boost::ref(*this), … … 332 332 const atomId_t _id, 333 333 const atom * const _atomref, 334 const boost::function<void( ObservedValue_Index_t)> &_subjectKilled)334 const boost::function<void()> &_subjectKilled) 335 335 { 336 336 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 337 337 "QtObservedAtom::initObservedValues() - given ObservedValues has not correct size."); 338 339 // fill ObservedValues: index first340 const boost::function<ObservedValue_Index_t ()> IndexGetter =341 boost::bind(&QtObservedAtom::getIndex,342 boost::cref(*this));343 338 344 339 // fill ObservedValues: then all the other that need index … … 364 359 _id, 365 360 AtomIndexChannels, 366 _subjectKilled, 367 IndexGetter); 361 _subjectKilled); 368 362 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t>( 369 363 _atomref, … … 372 366 AtomBondsUpdater(), 373 367 AtomBondsChannels, 374 _subjectKilled, 375 IndexGetter); 368 _subjectKilled); 376 369 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>( 377 370 _atomref, … … 380 373 AtomElementUpdater(), 381 374 AtomElementChannels, 382 _subjectKilled, 383 IndexGetter); 375 _subjectKilled); 384 376 _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t>( 385 377 _atomref, … … 388 380 AtomMoleculeUpdater(), 389 381 AtomMoleculeChannels, 390 _subjectKilled, 391 IndexGetter); 382 _subjectKilled); 392 383 _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>( 393 384 _atomref, … … 396 387 AtomNameUpdater(), 397 388 AtomNameChannels, 398 _subjectKilled, 399 IndexGetter); 389 _subjectKilled); 400 390 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>( 401 391 _atomref, … … 404 394 AtomPositionUpdater(), 405 395 AtomPositionChannels, 406 _subjectKilled, 407 IndexGetter); 396 _subjectKilled); 408 397 _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>( 409 398 _atomref, … … 412 401 AtomSelectedUpdater(), 413 402 AtomSelectedChannels, 414 _subjectKilled, 415 IndexGetter); 403 _subjectKilled); 416 404 } 417 405 -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
r96f14a rd48a16 207 207 const atomId_t _id, 208 208 const atom * const _atomref, 209 const boost::function<void( ObservedValue_Index_t)> &_subjectKilled);209 const boost::function<void()> &_subjectKilled); 210 210 211 211 /** Destroys all \a ObservedValues entries. -
src/UIElements/Qt4/InstanceBoard/QtObservedBond.cpp
r96f14a rd48a16 128 128 boost::ref(subjectKilledCount), _1); 129 129 130 const boost::function<void ( const ObservedValue_Index_t)> bondSubjectKilled(130 const boost::function<void ()> bondSubjectKilled( 131 131 boost::bind(&QtObservedBond::countValuesSubjectKilled, 132 132 boost::ref(*this), … … 134 134 boost::bind(accessor, 135 135 getObservable(_bond.get())))); 136 const boost::function<void ( const ObservedValue_Index_t)> leftatomSubjectKilled(136 const boost::function<void ()> leftatomSubjectKilled( 137 137 boost::bind(&QtObservedBond::countValuesSubjectKilled, 138 138 boost::ref(*this), … … 140 140 boost::bind(accessor, 141 141 getObservable(_bond->leftatom)))); 142 const boost::function<void ( const ObservedValue_Index_t)> rightatomSubjectKilled(142 const boost::function<void ()> rightatomSubjectKilled( 143 143 boost::bind(&QtObservedBond::countValuesSubjectKilled, 144 144 boost::ref(*this), … … 146 146 boost::bind(accessor, 147 147 getObservable(_bond->rightatom)))); 148 const boost::function<void ( const ObservedValue_Index_t)> moleculeSubjectKilled(148 const boost::function<void ()> moleculeSubjectKilled( 149 149 boost::bind(&QtObservedBond::countValuesSubjectKilled, 150 150 boost::ref(*this), … … 588 588 const bondId_t _id, 589 589 const bond::ptr _bondref, 590 const boost::function<void( const ObservedValue_Index_t)> &_bondsubjectKilled,591 const boost::function<void( const ObservedValue_Index_t)> &_leftatomsubjectKilled,592 const boost::function<void( const ObservedValue_Index_t)> &_rightatomsubjectKilled,593 const boost::function<void( const ObservedValue_Index_t)> &_moleculesubjectKilled)590 const boost::function<void()> &_bondsubjectKilled, 591 const boost::function<void()> &_leftatomsubjectKilled, 592 const boost::function<void()> &_rightatomsubjectKilled, 593 const boost::function<void()> &_moleculesubjectKilled) 594 594 { 595 595 // fill ObservedValues: index first … … 622 622 BondDegreeUpdater(), 623 623 BondDegreeChannels, 624 _bondsubjectKilled, 625 BondIndexGetter); 624 _bondsubjectKilled); 626 625 _ObservedValues[leftAtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>( 627 626 _bondref->leftatom, … … 630 629 leftAtomIndexUpdater(), 631 630 Observable::channels_t(1, AtomObservable::IndexChanged), 632 _leftatomsubjectKilled, 633 BondIndexGetter); 631 _leftatomsubjectKilled); 634 632 _ObservedValues[leftAtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>( 635 633 _bondref->leftatom, … … 638 636 leftAtomElementUpdater(), 639 637 Observable::channels_t(1, AtomObservable::ElementChanged), 640 _leftatomsubjectKilled, 641 BondIndexGetter); 638 _leftatomsubjectKilled); 642 639 _ObservedValues[leftAtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>( 643 640 _bondref->leftatom, … … 646 643 leftAtomPositionUpdater(), 647 644 Observable::channels_t(1, AtomObservable::PositionChanged), 648 _leftatomsubjectKilled, 649 BondIndexGetter); 645 _leftatomsubjectKilled); 650 646 _ObservedValues[rightAtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>( 651 647 _bondref->rightatom, … … 654 650 rightAtomIndexUpdater(), 655 651 Observable::channels_t(1, AtomObservable::IndexChanged), 656 _rightatomsubjectKilled, 657 BondIndexGetter); 652 _rightatomsubjectKilled); 658 653 _ObservedValues[rightAtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>( 659 654 _bondref->rightatom, … … 662 657 rightAtomElementUpdater(), 663 658 Observable::channels_t(1, AtomObservable::ElementChanged), 664 _rightatomsubjectKilled, 665 BondIndexGetter); 659 _rightatomsubjectKilled); 666 660 _ObservedValues[rightAtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>( 667 661 _bondref->rightatom, … … 670 664 rightAtomPositionUpdater(), 671 665 Observable::channels_t(1, AtomObservable::PositionChanged), 672 _rightatomsubjectKilled, 673 BondIndexGetter); 666 _rightatomsubjectKilled); 674 667 _ObservedValues[moleculeIndex] = new ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t>( 675 668 _bondref->leftatom->getMolecule(), … … 678 671 MoleculeIndexUpdater(), 679 672 Observable::channels_t(1, AtomObservable::PositionChanged), 680 _moleculesubjectKilled, 681 BondIndexGetter); 673 _moleculesubjectKilled); 682 674 } 683 675 -
src/UIElements/Qt4/InstanceBoard/QtObservedBond.hpp
r96f14a rd48a16 231 231 const bondId_t _id, 232 232 const bond::ptr _bondref, 233 const boost::function<void( const ObservedValue_Index_t)> &_bondsubjectKilled,234 const boost::function<void( const ObservedValue_Index_t)> &_leftatomsubjectKilled,235 const boost::function<void( const ObservedValue_Index_t)> &_rightatomsubjectKilled,236 const boost::function<void( const ObservedValue_Index_t)> &_moleculesubjectKilled);233 const boost::function<void()> &_bondsubjectKilled, 234 const boost::function<void()> &_leftatomsubjectKilled, 235 const boost::function<void()> &_rightatomsubjectKilled, 236 const boost::function<void()> &_moleculesubjectKilled); 237 237 238 238 /** Destroys all \a ObservedValues entries. -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
r96f14a rd48a16 114 114 ObservedValues(QtObservedMolecule::MAX_ObservedTypes) 115 115 { 116 boost::function<void ( ObservedValue_Index_t)> moleculeSubjectKilled(116 boost::function<void ()> moleculeSubjectKilled( 117 117 boost::bind(&QtObservedMolecule::countValuesSubjectKilled, 118 118 boost::ref(*this), … … 321 321 const moleculeId_t _molid, 322 322 const molecule * const _molref, 323 const boost::function<void( ObservedValue_Index_t)> &_subjectKilled)323 const boost::function<void()> &_subjectKilled) 324 324 { 325 325 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 326 326 "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size."); 327 328 // fill ObservedValues: index first329 const boost::function<ObservedValue_Index_t ()> MolIndexGetter =330 boost::bind(&QtObservedMolecule::getIndex,331 boost::cref(*this));332 327 333 328 // fill ObservedValues: then all the other that need index … … 357 352 _molid, 358 353 IndexChannels, 359 _subjectKilled, 360 MolIndexGetter); 354 _subjectKilled); 361 355 _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>( 362 356 _molref, … … 365 359 AtomCountUpdater(), 366 360 AtomCountChannels, 367 _subjectKilled, 368 MolIndexGetter); 361 _subjectKilled); 369 362 _ObservedValues[BondCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>( 370 363 _molref, … … 373 366 BondCountUpdater(), 374 367 BondCountChannels, 375 _subjectKilled, 376 MolIndexGetter); 368 _subjectKilled); 377 369 _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t>( 378 370 _molref, … … 381 373 initBoundingBox(), 382 374 BoundingBoxChannels, 383 _subjectKilled, 384 MolIndexGetter); 375 _subjectKilled); 385 376 _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>( 386 377 _molref, … … 389 380 MolFormulaUpdater(), 390 381 FormulaStringChannels, 391 _subjectKilled, 392 MolIndexGetter); 382 _subjectKilled); 393 383 _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>( 394 384 _molref, … … 397 387 MolCenterUpdater(), 398 388 CenterChannels, 399 _subjectKilled, 400 MolIndexGetter); 389 _subjectKilled); 401 390 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>( 402 391 _molref, … … 405 394 MolNameUpdater(), 406 395 NameChannels, 407 _subjectKilled, 408 MolIndexGetter); 396 _subjectKilled); 409 397 _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>( 410 398 _molref, … … 413 401 NonHydrogenCountUpdater(), 414 402 NonHydrogenCountChannels, 415 _subjectKilled, 416 MolIndexGetter); 403 _subjectKilled); 417 404 _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>( 418 405 _molref, … … 421 408 SelectedUpdater(), 422 409 SelectedChannels, 423 _subjectKilled, 424 MolIndexGetter); 410 _subjectKilled); 425 411 } 426 412 -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
r96f14a rd48a16 244 244 const moleculeId_t _molid, 245 245 const molecule * const _molref, 246 const boost::function<void( ObservedValue_Index_t)> &_subjectKilled);246 const boost::function<void()> &_subjectKilled); 247 247 248 248 /** Destroys all \a ObservedValues entries.
Note:
See TracChangeset
for help on using the changeset viewer.