Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.hpp

    r601ef8 r11d433  
    1616#include "CodePatterns/Singleton.hpp"
    1717
    18 #include "CodePatterns/Observer/Channels.hpp"
    19 #include "CodePatterns/Observer/Observable.hpp"
    2018
    2119#ifdef HAVE_ACTION_THREAD
     
    4038class ActionRegistry;
    4139class ActionTrait;
    42 
    43 namespace Queuedetail {
    44   template <class T> const T* lastChanged()
    45   {
    46     ASSERT(0, "Queuedetail::lastChanged() - only specializations may be used.");
    47     return NULL;
    48   }
    49 }
    5040
    5141/** This class combines the whole handling of Actions into a single class.
     
    5444 * automatically queued and placed into a History after execution.
    5545 */
    56 class ActionQueue : public Singleton<ActionQueue>, public Observable
     46class ActionQueue : public Singleton<ActionQueue>
    5747{
    5848  friend class Singleton<ActionQueue>;
     
    6151  typedef std::vector< Action * > ActionQueue_t;
    6252
    63   //!> channels for this observable
    64   enum NotificationType {
    65     ActionQueued,  // new action was queued
    66     NotificationType_MAX  // denotes the maximum of available notification types
    67   };
    68 
    69   //>! access to last changed element (atom or molecule)
    70   template <class T> const T* lastChanged() const
    71   { return Queuedetail::lastChanged<T>(); }
    72 
    7353  /** Queues the Action with \a name to be called.
    7454   *
     
    144124   */
    145125  void redoLast();
    146 
    147   /** Checks whether there is one completed Action stored in ActionHistory in the past.
    148    *
    149    * @return true - at least one Action to undo present, false - else
    150    */
    151   bool canUndo() const;
    152 
    153   /** Checks whether there is one completed Action stored in ActionHistory in the future.
    154    *
    155    * @return true - at least one Action to redo present, false - else
    156    */
    157   bool canRedo() const;
    158126
    159127  /** Return status of last executed action.
     
    202170  void clear();
    203171
    204   /** Clears all actions present in the actionqueues from \a _fromAction.
    205    *
    206    * @param _fromAction 0 if all Actions to clear or else
    207    */
    208   void clearQueue(const size_t _fromAction = 0);
    209 
    210 #ifdef HAVE_ACTION_THREAD
    211 
    212   /** Clears the temporary queue.
    213    *
    214    */
    215   void clearTempQueue();
    216 
    217   /** Sets the run_thread_isIdle flag.
    218    *
    219    * @param _flag state to set to
    220    */
    221   void setRunThreadIdle(const bool _flag);
    222 
     172  /** Clears all actions currently present in the actionqueues.
     173   *
     174   */
     175  void clearQueue();
     176
     177#ifdef HAVE_ACTION_THREAD
    223178  /** Runs the ActionQueue.
    224179   *
     
    239194   */
    240195  void wait();
    241 
    242   /** Moves all action from tempqueue into real queue.
    243    *
    244    */
    245   void insertTempQueue();
    246 
    247196#endif
    248197
     
    255204  void insertAction(Action *_action, enum Action::QueryOptions state);
    256205
     206  /** Moves all action from tempqueue into real queue.
     207   *
     208   */
     209  void insertTempQueue();
     210
    257211private:
    258212  /** Private cstor for ActionQueue.
     
    268222  ~ActionQueue();
    269223
    270 private:
    271   friend const Action *Queuedetail::lastChanged<Action>();
    272   static const Action *_lastchangedaction;
    273 
    274224  //!> ActionRegistry to spawn new actions
    275225  ActionRegistry *AR;
     
    281231  ActionQueue_t actionqueue;
    282232
     233  //!> point to current action in actionqueue
     234  size_t CurrentAction;
     235
     236  //!> internal temporary actionqueue of actions used by insertAction()
     237  ActionQueue_t tempqueue;
     238
    283239  //!> indicates that the last action has failed
    284240  bool lastActionOk;
    285241
    286242#ifdef HAVE_ACTION_THREAD
    287   //!> point to current action in actionqueue
    288   size_t CurrentAction;
    289 
    290   //!> internal temporary actionqueue of actions used by insertAction()
    291   ActionQueue_t tempqueue;
    292 
    293243  //!> internal thread to call Actions
    294244  boost::thread run_thread;
     
    310260  ActionStatusList StatusList;
    311261};
    312 namespace Queuedetail {
    313   template <>       inline  const Action* lastChanged<Action>() { return ActionQueue::_lastchangedaction; }
    314 }
    315262
    316263};
Note: See TracChangeset for help on using the changeset viewer.