Ignore:
Timestamp:
Feb 12, 2016, 11:15:24 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:
68418e
Parents:
494478
git-author:
Frederik Heber <heber@…> (01/25/16 14:07:59)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:24)
Message:

Moved countSubjectKilled related code from QtObservedInstanceBoard into ObservedValuesContainer.

  • this avoids some more duplicated code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r494478 r90821d  
    5656  atomObservedValues("atom", *this),
    5757  moleculeObservedValues("molecule", *this),
    58   atomSubjectKilled(
    59       boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1)),
    60   moleculeSubjectKilled(
    61       boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1)),
    6258  lastremovedatom((atomId_t)-1),
    6359  lastremovedatomsmolecule( std::make_pair((moleculeId_t)-1,(atomId_t)-1) ),
    6460  lastremovedmolecule((moleculeId_t)-1)
    6561{
     62  boost::function<void (const atomId_t _id)> atomfctor =
     63      boost::bind(&QtObservedInstanceBoard::atomcountsubjectKilled, this, _1);
     64  atomSubjectKilled =
     65      boost::bind(&ObservedValuesContainer<QtObservedAtom, atomId_t>::countsubjectKilled,
     66          boost::ref(atomObservedValues),
     67          _1,
     68          atomfctor
     69          );
     70  boost::function<void (const moleculeId_t _id)> molfctor =
     71      boost::bind(&QtObservedInstanceBoard::moleculecountsubjectKilled, this, _1);
     72  moleculeSubjectKilled =
     73      boost::bind(&ObservedValuesContainer<QtObservedMolecule, moleculeId_t>::countsubjectKilled,
     74          boost::ref(moleculeObservedValues),
     75          _1,
     76          molfctor
     77          );
     78
    6679  // be first (besides ObservedValues to know about new insertions)
    6780  World::getInstance().signOn(this, World::AtomInserted, GlobalObservableInfo::PriorityLevel(int(-10)));
     
    294307void QtObservedInstanceBoard::atomcountsubjectKilled(const atomId_t _atomid)
    295308{
    296   LOG(3, "DEBUG: InformationBoard got subjectKilled() for a value of atom " << _atomid);
    297   atomsubjectKilledCount_t::iterator iter = atomsubjectKilledCount.find(_atomid);
    298   if (iter == atomsubjectKilledCount.end()) {
    299     std::pair<atomsubjectKilledCount_t::iterator, bool> inserter =
    300         atomsubjectKilledCount.insert( std::make_pair(_atomid, 0) );
    301     iter = inserter.first;
    302   }
    303   ++(iter->second);
    304 
    305   if (iter->second > QtObservedAtom::MAX_ObservedTypes) {
    306     ASSERT( atomObservedValues.getRefCount(_atomid) == 0,
    307         "QtObservedInstanceBoard::atomcountsubjectKilled() - observed Values for atom "
    308         +toString(_atomid)+" are still being held somewhere.");
    309     if (_atomid == lastremovedatomsmolecule.second)
    310       emit atomRemoved(lastremovedatomsmolecule.first, lastremovedatomsmolecule.second);
    311     else
    312       ELOG(2, "QtObservedInstanceBoard::atomcountsubjectKilled() - id " << _atomid
    313           << " not fitting with " << lastremovedatomsmolecule);
    314     atomsubjectKilledCount.erase(iter);
    315   }
     309  if (_atomid == lastremovedatomsmolecule.second)
     310    emit atomRemoved(lastremovedatomsmolecule.first, lastremovedatomsmolecule.second);
     311  else
     312    ELOG(2, "QtObservedInstanceBoard::atomcountsubjectKilled() - id " << _atomid
     313        << " not fitting with " << lastremovedatomsmolecule);
    316314}
    317315
    318316void QtObservedInstanceBoard::moleculecountsubjectKilled(const moleculeId_t _molid)
    319317{
    320   LOG(3, "DEBUG: InformationBoard got subjectKilled() for a value of molecule " << _molid);
    321   moleculesubjectKilledCount_t::iterator iter = moleculesubjectKilledCount.find(_molid);
    322   if (iter == moleculesubjectKilledCount.end()) {
    323     std::pair<moleculesubjectKilledCount_t::iterator, bool> inserter =
    324         moleculesubjectKilledCount.insert( std::make_pair(_molid, 0) );
    325     iter = inserter.first;
    326   }
    327   ++(iter->second);
    328 
    329   if (iter->second > QtObservedMolecule::MAX_ObservedTypes) {
    330     ASSERT( moleculeObservedValues.getRefCount(_molid) == 0,
    331         "QtObservedInstanceBoard::moleculecountsubjectKilled() - observed Values for molecule "
    332         +toString(_molid)+" are still being held somewhere.");
    333     // then free the instance
    334     emit moleculeRemoved(_molid);
    335     moleculesubjectKilledCount.erase(iter);
    336   }
     318  emit moleculeRemoved(_molid);
    337319}
    338320
Note: See TracChangeset for help on using the changeset viewer.