1 // File: XGUI_OperationMgr.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef XGUI_OperationMgr_H
6 #define XGUI_OperationMgr_H
10 #include <ModuleBase_Operation.h>
15 /**\class XGUI_OperationMgr
17 * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
18 * of started operations. In simple case, if only one operration is started, the stack contains
19 * one operation. It is possible for some kind of operations to start them above already
20 * started one. In that case, the previous active operation becames suspended, a new one - active.
21 * The new operation is added to the top of the stack. Then it is finished, it is removed from
22 * the stack and the previous operation is activated.
24 class XGUI_EXPORT XGUI_OperationMgr : public QObject
29 /// \param theParent the parent
30 XGUI_OperationMgr(QObject* theParent);
32 virtual ~XGUI_OperationMgr();
34 /// Returns the current operation or NULL
35 /// \return the current operation
36 ModuleBase_Operation* currentOperation() const;
37 /// Sets the current operation or NULL
38 /// \return the current operation
39 bool startOperation(ModuleBase_Operation* theOperation);
42 /// Signal about an operation is started. It is emitted after the start() of operation is done.
43 void operationStarted();
44 /// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
45 /// \param theOperation a stopped operation
46 void operationStopped(ModuleBase_Operation* theOperation);
49 /// Returns whether the operation can be started. Check if there is already started operation and
50 /// the granted parameter of the launched operation
51 /// \param theOperation an operation to check
52 bool canStartOperation(ModuleBase_Operation* theOperation);
55 /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
56 /// If there is a suspended operation, restart it.
57 void onOperationStopped();
60 typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
61 Operations myOperations; ///< a stack of started operations. The active operation is on top,
62 // others are suspended and started by the active is finished