Salome HOME
b45b84d3c9163162024cf75c94bcec9a411301fd
[modules/shaper.git] / src / XGUI / XGUI_OperationMgr.h
1 #ifndef XGUI_OperationMgr_H
2 #define XGUI_OperationMgr_H
3
4 #include "XGUI.h"
5
6 #include <ModuleBase_Operation.h>
7
8 #include <QList>
9 #include <QObject>
10
11 /**\class XGUI_OperationMgr
12  * \ingroup GUI
13  * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
14  * of started operations. In simple case, if only one operration is started, the stack contains
15  * one operation. It is possible for some kind of operations to start them above already
16  * started one. In that case, the previous active operation becames suspended, a new one - active.
17  * The new operation is added to the top of the stack. Then it is finished, it is removed from
18  * the stack and the previous operation is activated.
19  */
20 class XGUI_EXPORT XGUI_OperationMgr : public QObject
21 {
22   Q_OBJECT
23 public:
24   /// Constructor
25   /// \param theParent the parent
26   XGUI_OperationMgr(QObject* theParent);
27   /// Destructor
28   virtual ~XGUI_OperationMgr();
29
30   /// Returns the current operation or NULL
31   /// \return the current operation
32   ModuleBase_Operation* currentOperation() const;
33   /// Sets the current operation or NULL
34   /// \return the current operation
35   bool startOperation(ModuleBase_Operation* theOperation);
36
37   void commitCurrentOperation();
38
39 signals:
40   void operationStarted();
41   void operationStopped(ModuleBase_Operation* theOperation);
42
43 protected:
44   bool canStartOperation(ModuleBase_Operation* theOperation);
45
46 protected slots:
47   void onOperationStopped();
48
49 private:
50   typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
51   Operations myOperations; ///< a stack of started operations. The active operation is on top,
52                            // others are suspended and started by the active is finished
53 };
54
55 #endif