4 * Copyright (C) 2005 CEA/DEN, EDF R&D
8 * File : SUIT_Operation.h
13 #ifndef SUIT_OPERATION_H
14 #define SUIT_OPERATION_H
21 class SUIT_Application;
24 * \brief Base class for all operations
26 * Base class for all operations. If you perform an action it is reasonable to create
27 * operation intended for this. This is a base class for all operations which provides
28 * mechanism for correct starting operations, starting operations above already started
29 * ones, committing operations and so on. To create own operation it is reasonable to
30 * inherit it from this class and redefines virtual methods to provide own behavior
31 * Main virtual methods are
32 * - virtual bool isReadyToStart();
33 * - virtual void startOperation();
34 * - virtual void abortOperation();
35 * - virtual void commitOperation();
36 * - virtual void resumeOperation();
37 * - virtual void suspendOperation();
39 class SUIT_EXPORT SUIT_Operation : public QObject
44 /*! Enum describes state of operation */
47 Waiting, //!< Operation is not used (it is not run or suspended)
48 Running, //!< Operation is started
49 Suspended //!< Operation is started but suspended (other operation is performed above it)
53 * Enum describes execution status of operation. Execution status often used after
54 * ending work of operation which was started from this one. In this case this
55 * operation can ask previously started operation whether it finished successfully.
59 Rejected, //!< Operation has not performed any action (modification of data model for example)
60 Accepted //!< Operation has performed an actions and must be stopped
64 * Enum describes setting of the operation.
68 None = 0x00, //!< None options
69 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
73 SUIT_Operation( SUIT_Application* );
74 virtual ~SUIT_Operation();
76 OperationState state() const;
77 bool isActive() const;
78 bool isRunning() const;
80 SUIT_Study* study() const;
81 virtual void setStudy( SUIT_Study* theStudy );
83 SUIT_Application* application() const;
84 virtual void setApplication( SUIT_Application* theApp );
86 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
87 virtual bool isGranted() const;
89 bool setSlot( const QObject* theReceiver, const char* theSlot );
91 void setFlags( const int );
92 void clearFlags( const int );
93 bool testFlags( const int ) const;
95 virtual QString operationName() const;
98 void started( SUIT_Operation* );
99 void aborted( SUIT_Operation* );
100 void committed( SUIT_Operation* );
102 void stopped( SUIT_Operation* );
103 void resumed( SUIT_Operation* );
104 void suspended( SUIT_Operation* );
116 virtual bool isReadyToStart() const;
118 virtual void stopOperation();
119 virtual void startOperation();
120 virtual void abortOperation();
121 virtual void commitOperation();
122 virtual void resumeOperation();
123 virtual void suspendOperation();
125 virtual bool openTransaction();
126 virtual bool abortTransaction();
127 virtual bool hasTransaction() const;
128 virtual bool commitTransaction( const QString& = QString::null );
130 int execStatus() const;
131 void setExecStatus( const int );
133 void setState( const OperationState );
135 void start( SUIT_Operation*, const bool = false );
138 SUIT_Application* myApp; //!< application for this operation
139 int myFlags; //!< operation flags
140 SUIT_Study* myStudy; //!< study for this operation
141 OperationState myState; //!< Operation state
142 ExecStatus myExecStatus; //!< Execution status
144 friend class SUIT_Study;