1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef SUIT_OPERATION_H
23 #define SUIT_OPERATION_H
31 class SUIT_Application;
35 * \brief Base class for all operations
37 * Base class for all operations. If you perform an action it is reasonable to create
38 * operation intended for this. This is a base class for all operations which provides
39 * mechanism for correct starting operations, starting operations above already started
40 * ones, committing operations and so on. To create own operation it is reasonable to
41 * inherit it from this class and redefines virtual methods to provide own behavior
42 * Main virtual methods are
43 * - virtual bool isReadyToStart();
44 * - virtual void startOperation();
45 * - virtual void abortOperation();
46 * - virtual void commitOperation();
47 * - virtual void resumeOperation();
48 * - virtual void suspendOperation();
51 #pragma warning( disable:4251 )
54 class SUIT_EXPORT SUIT_Operation : public QObject
59 /*! Enum describes state of operation */
62 Waiting, //!< Operation is not used (it is not run or suspended)
63 Running, //!< Operation is started
64 Suspended //!< Operation is started but suspended (other operation is performed above it)
68 * Enum describes execution status of operation. Execution status often used after
69 * ending work of operation which was started from this one. In this case this
70 * operation can ask previously started operation whether it finished successfully.
74 Rejected, //!< Operation has not performed any action (modification of data model for example)
75 Accepted //!< Operation has performed an actions and must be stopped
79 * Enum describes setting of the operation.
83 None = 0x00, //!< None options
84 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
88 SUIT_Operation( SUIT_Application* );
89 virtual ~SUIT_Operation();
91 OperationState state() const;
92 bool isActive() const;
93 bool isRunning() const;
95 SUIT_Study* study() const;
96 virtual void setStudy( SUIT_Study* theStudy );
98 SUIT_Application* application() const;
99 virtual void setApplication( SUIT_Application* theApp );
101 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
102 virtual bool isGranted() const;
104 bool setSlot( const QObject* theReceiver, const char* theSlot );
106 void setFlags( const int );
107 void clearFlags( const int );
108 bool testFlags( const int ) const;
110 virtual QString operationName() const;
112 int execStatus() const;
115 void started( SUIT_Operation* );
116 void aborted( SUIT_Operation* );
117 void committed( SUIT_Operation* );
119 void stopped( SUIT_Operation* );
120 void resumed( SUIT_Operation* );
121 void suspended( SUIT_Operation* );
133 virtual bool isReadyToStart() const;
135 virtual void stopOperation();
136 virtual void startOperation();
137 virtual void abortOperation();
138 virtual void commitOperation();
139 virtual void resumeOperation();
140 virtual void suspendOperation();
142 virtual bool openTransaction();
143 virtual bool abortTransaction();
144 virtual bool hasTransaction() const;
145 virtual bool commitTransaction( const QString& = QString() );
147 void setExecStatus( const int );
149 void setState( const OperationState );
151 void start( SUIT_Operation*, const bool = false );
154 typedef QPointer<SUIT_Study> StudyPtr;
157 SUIT_Application* myApp; //!< application for this operation
158 int myFlags; //!< operation flags
159 StudyPtr myStudy; //!< study for this operation
160 OperationState myState; //!< Operation state
161 ExecStatus myExecStatus; //!< Execution status
163 friend class SUIT_Study;
167 #pragma warning( default:4251 )