Changeset 7188b1 for src/World.hpp


Ignore:
Timestamp:
Oct 6, 2011, 4:06:10 PM (13 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:
db7e6d
Parents:
e638f9
git-author:
Frederik Heber <heber@…> (09/01/11 13:49:14)
git-committer:
Frederik Heber <heber@…> (10/06/11 16:06:10)
Message:

Introduced atom_observables and GLWorldView observes World, GLMoleculeObject_atom observes its atom.

Observer changes:

  • new Channels pattern required from CodePatterns 1.1.5 and that Observable signing on and off is now with const instance possible.
  • class atom is now observable, encapsulated in class AtomObservable:
    • enums have notification types
    • we use NotificationChannels of Observable to emit these distinct types.
  • atominfo, particleinfo, bondedparticleinfo all have OBSERVE and NOTIFY(..) in their setter functions (thx encapsulation).
  • class GLMoleculeObject_atom signs on to atom to changes to position, element, and index.
  • World equally has notifications for atom (new,remove) and molecules (new, remove).
  • GLWorldView now observes World for these changes.

Other changes:

  • removed additional hierarchy level for GLWidget of molecules (i.e. GLMoleculeScene removed and incorporated into GLWorldScene).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.hpp

    re638f9 r7188b1  
    5555/********************************************** Class World *******************************/
    5656
     57namespace detail {
     58  template <class T> const T* lastChanged()
     59  {
     60    ASSERT(0, "detail::lastChanged() - only specializations may be used.");
     61    return NULL;
     62  }
     63}
     64
    5765class World : public Singleton<World>, public Observable
    5866{
     
    8492  typedef ATOMSET(std::vector) AtomComposite;
    8593
    86   /***** getter and setter *****/
     94    /******* Notifications *******/
     95
     96  //!> enumeration of present notification types
     97  enum NotificationType {
     98    AtomInserted,
     99    AtomRemoved,
     100    AtomChanged,
     101    MoleculeInserted,
     102    MoleculeRemoved,
     103    MoleculeChanged,
     104    NotificationType_MAX
     105  };
     106
     107  //>! access to last changed element (atom or molecule)
     108  template <class T> const T* lastChanged() const
     109  { return detail::lastChanged<T>(); }
     110
     111    /***** getter and setter *****/
    87112  // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object
    88113  /**
     
    106131   */
    107132  config *&getConfig();
     133
     134  /** Returns a notification_ptr for a specific type.
     135   *
     136   * @param type request type
     137   * @return reference to instance
     138   */
     139  Notification_ptr getNotification(enum NotificationType type) const;
    108140
    109141  /**
     
    385417  void defragMoleculeIdPool();
    386418
     419  friend const atom *detail::lastChanged<atom>();
     420  friend const molecule *detail::lastChanged<molecule>();
     421  static atom *_lastchangedatom;
     422  static molecule*_lastchangedmol;
     423
    387424  BondGraph *BG;
    388425  periodentafel *periode;
     
    442479};
    443480
     481/** Externalized stuff as member functions cannot be specialized without
     482 *  specializing the class, too.
     483 */
     484namespace detail {
     485  template <>       inline  const atom* lastChanged<atom>() { return World::_lastchangedatom; }
     486  template <>       inline  const molecule* lastChanged<molecule>() { return World::_lastchangedmol; }
     487}
     488
     489
    444490#endif /* WORLD_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.