1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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
23 #ifndef SUIT_OPERATION_H
24 #define SUIT_OPERATION_H
32 class SUIT_Application;
36 * \brief Base class for all operations
38 * Base class for all operations. If you perform an action it is reasonable to create
39 * operation intended for this. This is a base class for all operations which provides
40 * mechanism for correct starting operations, starting operations above already started
41 * ones, committing operations and so on. To create own operation it is reasonable to
42 * inherit it from this class and redefines virtual methods to provide own behavior
43 * Main virtual methods are
44 * - virtual bool isReadyToStart();
45 * - virtual void startOperation();
46 * - virtual void abortOperation();
47 * - virtual void commitOperation();
48 * - virtual void resumeOperation();
49 * - virtual void suspendOperation();
52 #pragma warning( disable:4251 )
55 class SUIT_EXPORT SUIT_Operation : public QObject
60 /*! Enum describes state of operation */
63 Waiting, //!< Operation is not used (it is not run or suspended)
64 Running, //!< Operation is started
65 Suspended //!< Operation is started but suspended (other operation is performed above it)
69 * Enum describes execution status of operation. Execution status often used after
70 * ending work of operation which was started from this one. In this case this
71 * operation can ask previously started operation whether it finished successfully.
75 Rejected, //!< Operation has not performed any action (modification of data model for example)
76 Accepted //!< Operation has performed an actions and must be stopped
80 * Enum describes setting of the operation.
84 None = 0x00, //!< None options
85 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
89 SUIT_Operation( SUIT_Application* );
90 virtual ~SUIT_Operation();
92 OperationState state() const;
93 bool isActive() const;
94 bool isRunning() const;
96 SUIT_Study* study() const;
97 virtual void setStudy( SUIT_Study* theStudy );
99 SUIT_Application* application() const;
100 virtual void setApplication( SUIT_Application* theApp );
102 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
103 virtual bool isGranted() const;
105 bool setSlot( const QObject* theReceiver, const char* theSlot );
107 void setFlags( const int );
108 void clearFlags( const int );
109 bool testFlags( const int ) const;
111 virtual QString operationName() const;
113 int execStatus() const;
116 void started( SUIT_Operation* );
117 void aborted( SUIT_Operation* );
118 void committed( SUIT_Operation* );
120 void stopped( SUIT_Operation* );
121 void resumed( SUIT_Operation* );
122 void suspended( SUIT_Operation* );
134 virtual bool isReadyToStart() const;
136 virtual void stopOperation();
137 virtual void startOperation();
138 virtual void abortOperation();
139 virtual void commitOperation();
140 virtual void resumeOperation();
141 virtual void suspendOperation();
143 virtual bool openTransaction();
144 virtual bool abortTransaction();
145 virtual bool hasTransaction() const;
146 virtual bool commitTransaction( const QString& = QString() );
148 void setExecStatus( const int );
150 void setState( const OperationState );
152 void start( SUIT_Operation*, const bool = false );
155 typedef QPointer<SUIT_Study> StudyPtr;
158 SUIT_Application* myApp; //!< application for this operation
159 int myFlags; //!< operation flags
160 StudyPtr myStudy; //!< study for this operation
161 OperationState myState; //!< Operation state
162 ExecStatus myExecStatus; //!< Execution status
164 friend class SUIT_Study;
168 #pragma warning( default:4251 )