Changeset d48a16


Ignore:
Timestamp:
Apr 20, 2016, 11:04:53 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:
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)
Message:

Removed partial specialization of ObservedValue_wCallback for index.

Location:
src/UIElements/Qt4/InstanceBoard
Files:
7 edited

Legend:

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

    r96f14a rd48a16  
    3838      const T &_initialvalue,
    3939      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) :
    4241        ObservedValue<T>(_owner, _recalcMethod, _name, _initialvalue, _channels),
    4342        signedOnChannels(std::max((size_t)1,_channels.size())),
    4443        callback(_callback),
    45         CallbackIsGone(false),
    46         getId(_getId)
     44        CallbackIsGone(false)
    4745  {}
    4846  virtual ~ObservedValue_wCallback()
     
    6462      ObservedValue<T>::subjectKilled(publisher);
    6563      if (!CallbackIsGone)
    66         callback(getId());
     64        callback();
    6765    }
    6866  }
     
    7270  size_t signedOnChannels;
    7371  //!> callback function to tell other entity about subjectKilled
    74   const boost::function<void(const id)> callback;
     72  const boost::function<void()> callback;
    7573  //!> is callback still alive or not
    7674  bool CallbackIsGone;
    77   //!> callback function to get id
    78   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 whose
    84  * properties are monitored in ObservedValue. Hence, how to give a subjectKilled()
    85  * with an external getId() function? For the index the ObservedValue::get() is
    86  * the getId() we need to call! Hence, we may simply connect these internally
    87  * in this partial template specialization.
    88  *
    89  * Because atomicNumber_t, atomId_t and moleculeId_t are not unique types but
    90  * -- at the writing of this class -- just typedefs, we have to resort to the
    91  * trick with two constructors, one taking an external getId(), the other
    92  * 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 this
    131    */
    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 callback
    149   size_t signedOnChannels;
    150   //!> callback function to tell other entity about subjectKilled
    151   const boost::function<void(const T)> callback;
    152   //!> is callback still alive or not
    153   bool CallbackIsGone;
    154   //!> callback function to get id
    155   const boost::function<const T()> getId;
    15675};
    15776
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r96f14a rd48a16  
    106106  ObservedValues(QtObservedAtom::MAX_ObservedTypes)
    107107{
    108   boost::function<void (ObservedValue_Index_t)> atomSubjectKilled(
     108  boost::function<void ()> atomSubjectKilled(
    109109      boost::bind(&QtObservedAtom::countValuesSubjectKilled,
    110110          boost::ref(*this),
     
    332332    const atomId_t _id,
    333333    const atom * const _atomref,
    334     const boost::function<void(ObservedValue_Index_t)> &_subjectKilled)
     334    const boost::function<void()> &_subjectKilled)
    335335{
    336336  ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
    337337      "QtObservedAtom::initObservedValues() - given ObservedValues has not correct size.");
    338 
    339   // fill ObservedValues: index first
    340   const boost::function<ObservedValue_Index_t ()> IndexGetter =
    341       boost::bind(&QtObservedAtom::getIndex,
    342           boost::cref(*this));
    343338
    344339  // fill ObservedValues: then all the other that need index
     
    364359      _id,
    365360      AtomIndexChannels,
    366       _subjectKilled,
    367       IndexGetter);
     361      _subjectKilled);
    368362  _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t>(
    369363      _atomref,
     
    372366      AtomBondsUpdater(),
    373367      AtomBondsChannels,
    374       _subjectKilled,
    375       IndexGetter);
     368      _subjectKilled);
    376369  _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>(
    377370      _atomref,
     
    380373      AtomElementUpdater(),
    381374      AtomElementChannels,
    382       _subjectKilled,
    383       IndexGetter);
     375      _subjectKilled);
    384376  _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t>(
    385377      _atomref,
     
    388380      AtomMoleculeUpdater(),
    389381      AtomMoleculeChannels,
    390       _subjectKilled,
    391       IndexGetter);
     382      _subjectKilled);
    392383  _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    393384      _atomref,
     
    396387      AtomNameUpdater(),
    397388      AtomNameChannels,
    398       _subjectKilled,
    399       IndexGetter);
     389      _subjectKilled);
    400390  _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    401391      _atomref,
     
    404394      AtomPositionUpdater(),
    405395      AtomPositionChannels,
    406       _subjectKilled,
    407       IndexGetter);
     396      _subjectKilled);
    408397  _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
    409398      _atomref,
     
    412401      AtomSelectedUpdater(),
    413402      AtomSelectedChannels,
    414       _subjectKilled,
    415       IndexGetter);
     403      _subjectKilled);
    416404}
    417405
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r96f14a rd48a16  
    207207      const atomId_t _id,
    208208      const atom * const _atomref,
    209       const boost::function<void(ObservedValue_Index_t)> &_subjectKilled);
     209      const boost::function<void()> &_subjectKilled);
    210210
    211211  /** Destroys all \a ObservedValues entries.
  • src/UIElements/Qt4/InstanceBoard/QtObservedBond.cpp

    r96f14a rd48a16  
    128128          boost::ref(subjectKilledCount), _1);
    129129
    130   const boost::function<void (const ObservedValue_Index_t)> bondSubjectKilled(
     130  const boost::function<void ()> bondSubjectKilled(
    131131      boost::bind(&QtObservedBond::countValuesSubjectKilled,
    132132          boost::ref(*this),
     
    134134          boost::bind(accessor,
    135135              getObservable(_bond.get()))));
    136   const boost::function<void (const ObservedValue_Index_t)> leftatomSubjectKilled(
     136  const boost::function<void ()> leftatomSubjectKilled(
    137137      boost::bind(&QtObservedBond::countValuesSubjectKilled,
    138138          boost::ref(*this),
     
    140140          boost::bind(accessor,
    141141              getObservable(_bond->leftatom))));
    142   const boost::function<void (const ObservedValue_Index_t)> rightatomSubjectKilled(
     142  const boost::function<void ()> rightatomSubjectKilled(
    143143      boost::bind(&QtObservedBond::countValuesSubjectKilled,
    144144          boost::ref(*this),
     
    146146          boost::bind(accessor,
    147147              getObservable(_bond->rightatom))));
    148   const boost::function<void (const ObservedValue_Index_t)> moleculeSubjectKilled(
     148  const boost::function<void ()> moleculeSubjectKilled(
    149149      boost::bind(&QtObservedBond::countValuesSubjectKilled,
    150150          boost::ref(*this),
     
    588588    const bondId_t _id,
    589589    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)
    594594{
    595595  // fill ObservedValues: index first
     
    622622      BondDegreeUpdater(),
    623623      BondDegreeChannels,
    624       _bondsubjectKilled,
    625       BondIndexGetter);
     624      _bondsubjectKilled);
    626625  _ObservedValues[leftAtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>(
    627626      _bondref->leftatom,
     
    630629      leftAtomIndexUpdater(),
    631630      Observable::channels_t(1, AtomObservable::IndexChanged),
    632       _leftatomsubjectKilled,
    633       BondIndexGetter);
     631      _leftatomsubjectKilled);
    634632  _ObservedValues[leftAtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>(
    635633      _bondref->leftatom,
     
    638636      leftAtomElementUpdater(),
    639637      Observable::channels_t(1, AtomObservable::ElementChanged),
    640       _leftatomsubjectKilled,
    641       BondIndexGetter);
     638      _leftatomsubjectKilled);
    642639  _ObservedValues[leftAtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    643640      _bondref->leftatom,
     
    646643      leftAtomPositionUpdater(),
    647644      Observable::channels_t(1, AtomObservable::PositionChanged),
    648       _leftatomsubjectKilled,
    649       BondIndexGetter);
     645      _leftatomsubjectKilled);
    650646  _ObservedValues[rightAtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>(
    651647      _bondref->rightatom,
     
    654650      rightAtomIndexUpdater(),
    655651      Observable::channels_t(1, AtomObservable::IndexChanged),
    656       _rightatomsubjectKilled,
    657       BondIndexGetter);
     652      _rightatomsubjectKilled);
    658653  _ObservedValues[rightAtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>(
    659654      _bondref->rightatom,
     
    662657      rightAtomElementUpdater(),
    663658      Observable::channels_t(1, AtomObservable::ElementChanged),
    664       _rightatomsubjectKilled,
    665       BondIndexGetter);
     659      _rightatomsubjectKilled);
    666660  _ObservedValues[rightAtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    667661      _bondref->rightatom,
     
    670664      rightAtomPositionUpdater(),
    671665      Observable::channels_t(1, AtomObservable::PositionChanged),
    672       _rightatomsubjectKilled,
    673       BondIndexGetter);
     666      _rightatomsubjectKilled);
    674667  _ObservedValues[moleculeIndex] = new ObservedValue_wCallback<moleculeId_t, ObservedValue_Index_t>(
    675668      _bondref->leftatom->getMolecule(),
     
    678671      MoleculeIndexUpdater(),
    679672      Observable::channels_t(1, AtomObservable::PositionChanged),
    680       _moleculesubjectKilled,
    681       BondIndexGetter);
     673      _moleculesubjectKilled);
    682674}
    683675
  • src/UIElements/Qt4/InstanceBoard/QtObservedBond.hpp

    r96f14a rd48a16  
    231231      const bondId_t _id,
    232232      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);
    237237
    238238  /** Destroys all \a ObservedValues entries.
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp

    r96f14a rd48a16  
    114114  ObservedValues(QtObservedMolecule::MAX_ObservedTypes)
    115115{
    116   boost::function<void (ObservedValue_Index_t)> moleculeSubjectKilled(
     116  boost::function<void ()> moleculeSubjectKilled(
    117117      boost::bind(&QtObservedMolecule::countValuesSubjectKilled,
    118118          boost::ref(*this),
     
    321321    const moleculeId_t _molid,
    322322    const molecule * const _molref,
    323     const boost::function<void(ObservedValue_Index_t)> &_subjectKilled)
     323    const boost::function<void()> &_subjectKilled)
    324324{
    325325  ASSERT( _ObservedValues.size() == MAX_ObservedTypes,
    326326      "QtObservedMolecule::initObservedValues() - given ObservedValues has not correct size.");
    327 
    328   // fill ObservedValues: index first
    329   const boost::function<ObservedValue_Index_t ()> MolIndexGetter =
    330       boost::bind(&QtObservedMolecule::getIndex,
    331           boost::cref(*this));
    332327
    333328  // fill ObservedValues: then all the other that need index
     
    357352        _molid,
    358353        IndexChannels,
    359         _subjectKilled,
    360         MolIndexGetter);
     354        _subjectKilled);
    361355  _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    362356      _molref,
     
    365359      AtomCountUpdater(),
    366360      AtomCountChannels,
    367       _subjectKilled,
    368       MolIndexGetter);
     361      _subjectKilled);
    369362  _ObservedValues[BondCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    370363      _molref,
     
    373366      BondCountUpdater(),
    374367      BondCountChannels,
    375       _subjectKilled,
    376       MolIndexGetter);
     368      _subjectKilled);
    377369  _ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo, ObservedValue_Index_t>(
    378370      _molref,
     
    381373      initBoundingBox(),
    382374      BoundingBoxChannels,
    383       _subjectKilled,
    384       MolIndexGetter);
     375      _subjectKilled);
    385376  _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    386377      _molref,
     
    389380      MolFormulaUpdater(),
    390381      FormulaStringChannels,
    391       _subjectKilled,
    392       MolIndexGetter);
     382      _subjectKilled);
    393383  _ObservedValues[MolCenter] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>(
    394384      _molref,
     
    397387      MolCenterUpdater(),
    398388      CenterChannels,
    399       _subjectKilled,
    400       MolIndexGetter);
     389      _subjectKilled);
    401390  _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>(
    402391      _molref,
     
    405394      MolNameUpdater(),
    406395      NameChannels,
    407       _subjectKilled,
    408       MolIndexGetter);
     396      _subjectKilled);
    409397  _ObservedValues[NonHydrogenCount] = new ObservedValue_wCallback<int, ObservedValue_Index_t>(
    410398      _molref,
     
    413401      NonHydrogenCountUpdater(),
    414402      NonHydrogenCountChannels,
    415       _subjectKilled,
    416       MolIndexGetter);
     403      _subjectKilled);
    417404  _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>(
    418405      _molref,
     
    421408      SelectedUpdater(),
    422409      SelectedChannels,
    423       _subjectKilled,
    424       MolIndexGetter);
     410      _subjectKilled);
    425411}
    426412
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    r96f14a rd48a16  
    244244      const moleculeId_t _molid,
    245245      const molecule * const _molref,
    246       const boost::function<void(ObservedValue_Index_t)> &_subjectKilled);
     246      const boost::function<void()> &_subjectKilled);
    247247
    248248  /** Destroys all \a ObservedValues entries.
Note: See TracChangeset for help on using the changeset viewer.