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
39 class SUIT_Application;
42 * \brief Base class for all operations
44 * Base class for all operations. If you perform an action it is reasonable to create
45 * operation intended for this. This is a base class for all operations which provides
46 * mechanism for correct starting operations, starting operations above already started
47 * ones, committing operations and so on. To create own operation it is reasonable to
48 * inherit it from this class and redefines virtual methods to provide own behavior
49 * Main virtual methods are
50 * - virtual bool isReadyToStart();
51 * - virtual void startOperation();
52 * - virtual void abortOperation();
53 * - virtual void commitOperation();
54 * - virtual void resumeOperation();
55 * - virtual void suspendOperation();
57 class SUIT_EXPORT SUIT_Operation : public QObject
62 /*! Enum describes state of operation */
65 Waiting, //!< Operation is not used (it is not run or suspended)
66 Running, //!< Operation is started
67 Suspended //!< Operation is started but suspended (other operation is performed above it)
71 * Enum describes execution status of operation. Execution status often used after
72 * ending work of operation which was started from this one. In this case this
73 * operation can ask previously started operation whether it finished successfully.
77 Rejected, //!< Operation has not performed any action (modification of data model for example)
78 Accepted //!< Operation has performed an actions and must be stopped
82 * Enum describes setting of the operation.
86 None = 0x00, //!< None options
87 Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
91 SUIT_Operation( SUIT_Application* );
92 virtual ~SUIT_Operation();
94 OperationState state() const;
95 bool isActive() const;
96 bool isRunning() const;
98 SUIT_Study* study() const;
99 virtual void setStudy( SUIT_Study* theStudy );
101 SUIT_Application* application() const;
102 virtual void setApplication( SUIT_Application* theApp );
104 virtual bool isValid( SUIT_Operation* theOtherOp ) const;
105 virtual bool isGranted() const;
107 bool setSlot( const QObject* theReceiver, const char* theSlot );
109 void setFlags( const int );
110 void clearFlags( const int );
111 bool testFlags( const int ) const;
113 virtual QString operationName() 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::null );
148 int execStatus() const;
149 void setExecStatus( const int );
151 void setState( const OperationState );
153 void start( SUIT_Operation*, const bool = false );
156 SUIT_Application* myApp; //!< application for this operation
157 int myFlags; //!< operation flags
158 SUIT_Study* myStudy; //!< study for this operation
159 OperationState myState; //!< Operation state
160 ExecStatus myExecStatus; //!< Execution status
162 friend class SUIT_Study;