Changeset 29b52b


Ignore:
Timestamp:
Sep 12, 2014, 8:00:16 AM (10 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:
8859b5
Parents:
9bdcc9
Message:

Made ActionQueue observable.

  • has channel ActionQueued.
  • this is preparatory to know about most used Actions.
Location:
src/Actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.cpp

    r9bdcc9 r29b52b  
    5555using namespace MoleCuilder;
    5656
     57const Action* ActionQueue::_lastchangedaction = NULL;
     58
    5759ActionQueue::ActionQueue() :
     60    Observable("ActionQueue"),
    5861    AR(new ActionRegistry()),
    5962    history(new ActionHistory),
     
    6669    run_thread_isIdle(true)
    6770#endif
    68 {}
     71{
     72  // channels of observable
     73  Channels *OurChannel = new Channels;
     74  NotificationChannels.insert( std::make_pair(static_cast<Observable *>(this), OurChannel) );
     75  // add instance for each notification type
     76  for (size_t type = 0; type < NotificationType_MAX; ++type)
     77    OurChannel->addChannel(type);
     78}
    6979
    7080ActionQueue::~ActionQueue()
     
    91101void ActionQueue::queueAction(Action *_action, enum Action::QueryOptions state)
    92102{
     103  OBSERVE;
     104  NOTIFY(ActionQueued);
    93105  Action *newaction = _action->clone(state);
    94106  newaction->prepare(state);
     
    116128  mtx_queue.unlock();
    117129#endif
     130  _lastchangedaction = newaction;
    118131}
    119132
  • src/Actions/ActionQueue.hpp

    r9bdcc9 r29b52b  
    1616#include "CodePatterns/Singleton.hpp"
    1717
     18#include "CodePatterns/Observer/Channels.hpp"
     19#include "CodePatterns/Observer/Observable.hpp"
    1820
    1921#ifdef HAVE_ACTION_THREAD
     
    3638class ActionRegistry;
    3739class ActionTrait;
     40
     41namespace Queuedetail {
     42  template <class T> const T* lastChanged()
     43  {
     44    ASSERT(0, "Queuedetail::lastChanged() - only specializations may be used.");
     45    return NULL;
     46  }
     47}
    3848
    3949/** This class combines the whole handling of Actions into a single class.
     
    4252 * automatically queued and placed into a History after execution.
    4353 */
    44 class ActionQueue : public Singleton<ActionQueue>
     54class ActionQueue : public Singleton<ActionQueue>, public Observable
    4555{
    4656  friend class Singleton<ActionQueue>;
     
    4959  typedef std::vector< Action * > ActionQueue_t;
    5060
     61  //!> channels for this observable
     62  enum NotificationType {
     63    ActionQueued,  // new action was queued
     64    NotificationType_MAX  // denotes the maximum of available notification types
     65  };
     66
     67  //>! access to last changed element (atom or molecule)
     68  template <class T> const T* lastChanged() const
     69  { return Queuedetail::lastChanged<T>(); }
     70
    5171  /** Queues the Action with \a name to be called.
    5272   *
     
    213233  ~ActionQueue();
    214234
     235private:
     236  friend const Action *Queuedetail::lastChanged<Action>();
     237  static const Action *_lastchangedaction;
     238
    215239  //!> ActionRegistry to spawn new actions
    216240  ActionRegistry *AR;
Note: See TracChangeset for help on using the changeset viewer.