1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
20 #ifndef SUIT_OPERATION_H
21 #define SUIT_OPERATION_H
26 #include <qguardedptr.h>
29 class SUIT_Application;
33 * \brief Base class for all operations
35 * Base class for all operations. If you perform an action it is reasonable to create
36 * operation intended for this. This is a base class for all operations which provides
37 * mechanism for correct starting operations, starting operations above already started
38 * ones, committing operations and so on. To create own operation it is reasonable to
39 * inherit it from this class and redefines virtual methods to provide own behavior
40 * Main virtual methods are
41 * - virtual bool isReadyToStart();
42 * - virtual void startOperation();
43 * - virtual void abortOperation();
44 * - virtual void commitOperation();
45 * - virtual void resumeOperation();
46 * - virtual void suspendOperation();
49 #pragma warning( disable:4251 )
52 class SUIT_EXPORT SUIT_Operation : public QObject
57 /*! Enum describes state of operation */
60 Waiting, //!< Operation is not used (it is not run or suspended)
61 Running, //!< Operation is started
62 Suspended //!< Operation is started but suspended (other operation is performed above it)
66 * Enum describes execution status of operation. Execution status often used after
67 * ending work of operation which was started from this one. In this case this
68 * operation can ask previously started operation whether it finished successfully.
72 Rejected, //!< Operation has not performed any action (modification of data model for example)
73 Accepted //!< Operation has performed an actions and must be stopped
77 * Enum describes setting of the operation.
81 None = 0x00, //!< None options
82 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
86 SUIT_Operation( SUIT_Application* );
87 virtual ~SUIT_Operation();
89 OperationState state() const;
90 bool isActive() const;
91 bool isRunning() const;
93 SUIT_Study* study() const;
94 virtual void setStudy( SUIT_Study* theStudy );
96 SUIT_Application* application() const;
97 virtual void setApplication( SUIT_Application* theApp );
99 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
100 virtual bool isGranted() const;
102 bool setSlot( const QObject* theReceiver, const char* theSlot );
104 void setFlags( const int );
105 void clearFlags( const int );
106 bool testFlags( const int ) const;
108 virtual QString operationName() const;
111 void started( SUIT_Operation* );
112 void aborted( SUIT_Operation* );
113 void committed( SUIT_Operation* );
115 void stopped( SUIT_Operation* );
116 void resumed( SUIT_Operation* );
117 void suspended( SUIT_Operation* );
129 virtual bool isReadyToStart() const;
131 virtual void stopOperation();
132 virtual void startOperation();
133 virtual void abortOperation();
134 virtual void commitOperation();
135 virtual void resumeOperation();
136 virtual void suspendOperation();
138 virtual bool openTransaction();
139 virtual bool abortTransaction();
140 virtual bool hasTransaction() const;
141 virtual bool commitTransaction( const QString& = QString::null );
143 int execStatus() const;
144 void setExecStatus( const int );
146 void setState( const OperationState );
148 void start( SUIT_Operation*, const bool = false );
151 typedef QGuardedPtr<SUIT_Study> StudyPtr;
154 SUIT_Application* myApp; //!< application for this operation
155 int myFlags; //!< operation flags
156 StudyPtr myStudy; //!< study for this operation
157 OperationState myState; //!< Operation state
158 ExecStatus myExecStatus; //!< Execution status
160 friend class SUIT_Study;
164 #pragma warning( default:4251 )