4 * Copyright (C) 2005 CEA/DEN, EDF R&D
8 * File : SUIT_Operation.h
13 #include "SUIT_Operation.h"
15 #include "SUIT_Study.h"
16 #include "SUIT_Application.h"
17 #include "SUIT_MessageBox.h"
18 #include "SUIT_Desktop.h"
22 * \param SUIT_Application - application for this operation
24 * Constructs an empty operation. Constructor should work very fast because many
25 * operators may be created after starting application but only several from them
26 * may be used. As result this constructor stores given application in myApp field
27 * and set Waiting status.
29 SUIT_Operation::SUIT_Operation( SUIT_Application* app )
40 SUIT_Operation::~SUIT_Operation()
45 * \brief Returns operation study
46 * \return Pointer to study
48 * Get study corresponding to this operation i.e. study which starts this operation.
50 SUIT_Study* SUIT_Operation::study() const
56 * \brief Sets operation study
57 * \param theStudy - study corresponding to this operation
59 * Sets study corresponding to this operation i.e. study which starts this operation.
61 void SUIT_Operation::setStudy( SUIT_Study* theStudy )
67 * \brief Gets application
68 * \return Pointer to application
70 * Gets application for this operation
72 SUIT_Application* SUIT_Operation::application() const
78 * \brief Sets application
79 * \param theApp - application for this operation
81 * Gets application for this operation
83 void SUIT_Operation::setApplication( SUIT_Application* theApp )
89 * \brief Gets state of operation
90 * \return Value from OperationState enumeration
92 * Gets state of operation (see OperationState enumeration)
94 SUIT_Operation::OperationState SUIT_Operation::state() const
100 * \brief Sets state of operation
101 * \param theState - state of operation to be set
103 * Sets state of operation (see OperationState enumeration)
105 void SUIT_Operation::setState( const SUIT_Operation::OperationState theState )
111 * \brief Starts operation
113 * Public slot. Verifies whether operation can be started and starts operation.
114 * This slot is not virtual and cannot be redefined. Redefine startOperation method
115 * to change behavior of operation. There is no point in using this method. It would
116 * be better to inherit own operator from base one and redefine startOperation method
119 void SUIT_Operation::start()
122 study()->start( this );
126 emit started( this );
131 * \brief Aborts operation
133 * Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
134 * Redefine abortOperation method to change behavior of operation instead
136 void SUIT_Operation::abort()
139 study()->abort( this );
144 emit aborted( this );
145 emit stopped( this );
150 * \brief Commits operation
152 * Public slot. Commits operation. This slot is not virtual and cannot be redefined.
153 * Redefine commitOperation method to change behavior of operation instead
155 void SUIT_Operation::commit()
158 study()->commit( this );
163 emit committed( this );
164 emit stopped( this );
169 * \brief Resumes operation
171 * Public slot. Resumes operation. This slot is called when operation is resumed after
172 * previous suspending. This slot is not virtual and cannot be redefined. Redefine
173 * resumeOperation method to change behavior of operation instead
175 void SUIT_Operation::resume()
178 study()->resume( this );
183 emit resumed( this );
188 * \brief Suspend operation.
190 * Public slot. Suspend operation. This slot is called when operation is suspended
191 * (for starting other one, for example) This slot is not virtual and cannot be
192 * redefined. Redefine suspendOperation method to change behavior of operation instead
194 void SUIT_Operation::suspend()
197 study()->suspend( this );
202 emit suspended( this );
207 * \brief Verifies whether operator is ready to start.
208 * \return TRUE if operation is ready to start
210 * Default implementation returns TRUE. Redefine this method to add own verifications
212 bool SUIT_Operation::isReadyToStart() const
218 * \brief Virtual method called when operation is started
220 * Virtual method called when operation started (see start() method for more description)
222 void SUIT_Operation::startOperation()
229 * \brief Virtual method called when operation aborted
231 * Virtual method called when operation aborted (see abort() method for more description)
233 void SUIT_Operation::abortOperation()
238 * \brief Virtual method called when operation resumed
240 * Virtual method called when operation resumed (see resume() method for more description)
242 void SUIT_Operation::resumeOperation()
247 * \brief Virtual method called when operation suspended
249 * Virtual method called when operation suspended (see suspend() method for more description)
251 void SUIT_Operation::suspendOperation()
256 * \brief Virtual method called when operation committed
258 * Virtual method called when operation committed (see commit() method for more description)
260 void SUIT_Operation::commitOperation()
265 * \brief Sets slot which is called when operation is started
266 * \param theReceiver - object containing slot
267 * \param theSlot - slot of theReceiver object
268 * \return TR if slot was connected successfully, FALSE otherwise
270 * Sets slot which is called when operation is started. There is no point in
271 * using this method. It would be better to inherit own operator from base
272 * one and redefine startOperation method
274 bool SUIT_Operation::setSlot( const QObject* theReceiver, const char* theSlot )
276 return connect( this, SIGNAL( callSlot() ), theReceiver, theSlot );
280 * \brief Verifies whether given operator is valid for this one
281 * \param theOtherOp - other operation
282 * \return Returns TRUE if the given operator is valid for this one
284 * Verifies whether given operator is valid for this one (i.e. can be started "above"
287 bool SUIT_Operation::isValid( SUIT_Operation* ) const
293 * \brief Verifies whether this operator can be always started above any already runnig one
294 * \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
296 * This method must be redefined in derived operation if operation of derived class
297 * must be always can start above any launched one. Default implementation returns FALSE,
298 * so it is being checked for IsValid, but some operations may overload IsGranted()
299 * In this case they will always start, no matter what operation is running.
301 bool SUIT_Operation::isGranted() const
307 * \brief Verifies whether operation is an active one (state()==Running)
308 * \return TRUE if operation is active, FALSE otherwise
310 * Verifies whether operation is an active on. Returns TRUE if state of operator
313 bool SUIT_Operation::isActive() const
315 return state()==Running;
319 * \brief Starts operator above this one
320 * \param theOp - operation to be started
322 * Start operator above this one. Use this method if you want to call other operator
325 void SUIT_Operation::start( SUIT_Operation* op )
331 study()->start( op, false );
334 connect( this, SIGNAL( stopped( SUIT_Operation* ) ), op, SLOT( abort() ) );
340 * \brief Sets execution status
341 * \param theStatus - execution status
343 * Sets myExecStatus to the given value
345 void SUIT_Operation::setExecStatus( const int theVal )
347 myExecStatus = (ExecStatus)theVal;
351 * \brief Gets execution status
352 * \return Execution status
354 * Gets execution status
356 int SUIT_Operation::execStatus() const