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/
22 * Copyright (C) 2005 CEA/DEN, EDF R&D
26 * File : SUIT_Operation.h
31 #ifndef SUIT_OPERATION_H
32 #define SUIT_OPERATION_H
37 #include <qguardedptr.h>
40 class SUIT_Application;
43 * \brief Base class for all operations
45 * Base class for all operations. If you perform an action it is reasonable to create
46 * operation intended for this. This is a base class for all operations which provides
47 * mechanism for correct starting operations, starting operations above already started
48 * ones, committing operations and so on. To create own operation it is reasonable to
49 * inherit it from this class and redefines virtual methods to provide own behavior
50 * Main virtual methods are
51 * - virtual bool isReadyToStart();
52 * - virtual void startOperation();
53 * - virtual void abortOperation();
54 * - virtual void commitOperation();
55 * - virtual void resumeOperation();
56 * - virtual void suspendOperation();
59 #pragma warning( disable:4251 )
62 class SUIT_EXPORT SUIT_Operation : public QObject
67 /*! Enum describes state of operation */
70 Waiting, //!< Operation is not used (it is not run or suspended)
71 Running, //!< Operation is started
72 Suspended //!< Operation is started but suspended (other operation is performed above it)
76 * Enum describes execution status of operation. Execution status often used after
77 * ending work of operation which was started from this one. In this case this
78 * operation can ask previously started operation whether it finished successfully.
82 Rejected, //!< Operation has not performed any action (modification of data model for example)
83 Accepted //!< Operation has performed an actions and must be stopped
87 * Enum describes setting of the operation.
91 None = 0x00, //!< None options
92 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
96 SUIT_Operation( SUIT_Application* );
97 virtual ~SUIT_Operation();
99 OperationState state() const;
100 bool isActive() const;
101 bool isRunning() const;
103 SUIT_Study* study() const;
104 virtual void setStudy( SUIT_Study* theStudy );
106 SUIT_Application* application() const;
107 virtual void setApplication( SUIT_Application* theApp );
109 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
110 virtual bool isGranted() const;
112 bool setSlot( const QObject* theReceiver, const char* theSlot );
114 void setFlags( const int );
115 void clearFlags( const int );
116 bool testFlags( const int ) const;
118 virtual QString operationName() const;
121 void started( SUIT_Operation* );
122 void aborted( SUIT_Operation* );
123 void committed( SUIT_Operation* );
125 void stopped( SUIT_Operation* );
126 void resumed( SUIT_Operation* );
127 void suspended( SUIT_Operation* );
139 virtual bool isReadyToStart() const;
141 virtual void stopOperation();
142 virtual void startOperation();
143 virtual void abortOperation();
144 virtual void commitOperation();
145 virtual void resumeOperation();
146 virtual void suspendOperation();
148 virtual bool openTransaction();
149 virtual bool abortTransaction();
150 virtual bool hasTransaction() const;
151 virtual bool commitTransaction( const QString& = QString::null );
153 int execStatus() const;
154 void setExecStatus( const int );
156 void setState( const OperationState );
158 void start( SUIT_Operation*, const bool = false );
161 typedef QGuardedPtr<SUIT_Study> StudyPtr;
164 SUIT_Application* myApp; //!< application for this operation
165 int myFlags; //!< operation flags
166 StudyPtr myStudy; //!< study for this operation
167 OperationState myState; //!< Operation state
168 ExecStatus myExecStatus; //!< Execution status
170 friend class SUIT_Study;
174 #pragma warning( default:4251 )