Changeset 559293


Ignore:
Timestamp:
Jun 20, 2018, 8:20:43 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, StoppableMakroAction
Children:
e3ce0e
Parents:
646f73
git-author:
Frederik Heber <frederik.heber@…> (09/13/17 17:19:58)
git-committer:
Frederik Heber <frederik.heber@…> (06/20/18 08:20:43)
Message:

ActionQueue has predicates to check if current Action is Process or MakroAction.

Location:
src/Actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.cpp

    r646f73 r559293  
    5252#include "Actions/ActionHistory.hpp"
    5353#include "Actions/ActionRegistry.hpp"
     54#include "Actions/MakroAction.hpp"
     55#include "Actions/Process.hpp"
    5456#include "World.hpp"
    5557
     
    160162  bool status = (CurrentAction == actionqueue.size());
    161163  return status;
     164}
     165
     166bool ActionQueue::isProcess() const
     167{
     168  if (isIdle())
     169    return false;
     170  const Process *possibleprocess = dynamic_cast<const Process *>(&getCurrentAction());
     171  if (possibleprocess == NULL)
     172    return false;
     173  else
     174    return true;
     175}
     176
     177bool ActionQueue::isMakroAction() const
     178{
     179  if (isIdle())
     180    return false;
     181  const MakroAction *possiblemakroaction = dynamic_cast<const MakroAction *>(&getCurrentAction());
     182  if (possiblemakroaction == NULL)
     183    return false;
     184  else
     185    return true;
     186}
     187
     188const Action& ActionQueue::getCurrentAction() const
     189{
     190  return *const_cast<const Action *>(actionqueue[CurrentAction]);
    162191}
    163192
  • src/Actions/ActionQueue.hpp

    r646f73 r559293  
    180180  bool isIdle() const;
    181181
     182  /** States whether the current Action in the ActionQueue is a Process.
     183   *
     184   * \return true - ActionQueue is currently executing a process.
     185   */
     186  bool isProcess() const;
     187
     188  /** States whether the current Action in the ActionQueue is a MakroAction.
     189   *
     190   * \return true - ActionQueue is currently executing a MakroAction.
     191   */
     192  bool isMakroAction() const;
     193
     194  /** Getter to the current Action.
     195   *
     196   * \note Using this ref is only useful during the execution of the Action, e.g.
     197   * when an Action inside the ActionSequence of a MakroAction needs access to the
     198   * MakroAction itself (to signal stop). \sa MoleCuilder::ForceAnnealingAction::performCall()
     199   *
     200   * \warning Due to the multi-threaded nature of the ActionQueue this is very
     201   * dangerous to use in other circumstances.
     202   *
     203   * \return const ref to the currently executed action
     204   */
     205  const Action& getCurrentAction() const;
     206
    182207private:
    183208  //!> grant Action access to internal history functions.
Note: See TracChangeset for help on using the changeset viewer.