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_Desktop.h"
17 #include "SUIT_MessageBox.h"
18 #include "SUIT_Application.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 )
34 myFlags( Transaction )
41 SUIT_Operation::~SUIT_Operation()
46 * \brief Returns operation study
47 * \return Pointer to study
49 * Get study corresponding to this operation i.e. study which starts this operation.
51 SUIT_Study* SUIT_Operation::study() const
57 * \brief Sets operation study
58 * \param theStudy - study corresponding to this operation
60 * Sets study corresponding to this operation i.e. study which starts this operation.
62 void SUIT_Operation::setStudy( SUIT_Study* theStudy )
68 * \brief Gets application
69 * \return Pointer to application
71 * Gets application for this operation
73 SUIT_Application* SUIT_Operation::application() const
79 * \brief Sets application
80 * \param theApp - application for this operation
82 * Gets application for this operation
84 void SUIT_Operation::setApplication( SUIT_Application* theApp )
90 * \brief Gets state of operation
91 * \return Value from OperationState enumeration
93 * Gets state of operation (see OperationState enumeration)
95 SUIT_Operation::OperationState SUIT_Operation::state() const
101 * \brief Sets state of operation
102 * \param theState - state of operation to be set
104 * Sets state of operation (see OperationState enumeration)
106 void SUIT_Operation::setState( const SUIT_Operation::OperationState theState )
112 * \brief Sets the flags of operation
113 * \param f - flags of operation to be set
115 * Sets flags of operation (see Flags enumeration)
117 void SUIT_Operation::setFlags( const int f )
119 myFlags = myFlags | f;
123 * \brief Clears the flags of operation
124 * \param f - flags of operation to be cleared
126 * Clears flags of operation (see Flags enumeration)
128 void SUIT_Operation::clearFlags( const int f )
130 myFlags = myFlags & ~f;
134 * \brief Test the flags of operation
135 * \param f - flags of operation to be tested
137 * Returns TRUE if the specified flags setted in the operation (see Flags enumeration)
139 bool SUIT_Operation::testFlags( const int f ) const
141 return ( myFlags & f ) == f;
145 * \brief Name of the operation
147 * Returns string name of the operation. This name will be used for
148 * automatically commited transaction.
150 QString SUIT_Operation::operationName() const
152 return QString::null;
156 * \brief Starts operation
158 * Public slot. Verifies whether operation can be started and starts operation.
159 * This slot is not virtual and cannot be redefined. Redefine startOperation method
160 * to change behavior of operation. There is no point in using this method. It would
161 * be better to inherit own operator from base one and redefine startOperation method
164 void SUIT_Operation::start()
167 study()->start( this );
171 emit started( this );
176 * \brief Aborts operation
178 * Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
179 * Redefine abortOperation method to change behavior of operation instead
181 void SUIT_Operation::abort()
184 study()->abort( this );
189 emit aborted( this );
192 emit stopped( this );
197 * \brief Commits operation
199 * Public slot. Commits operation. This slot is not virtual and cannot be redefined.
200 * Redefine commitOperation method to change behavior of operation instead
202 void SUIT_Operation::commit()
205 study()->commit( this );
210 emit committed( this );
213 emit stopped( this );
218 * \brief Resumes operation
220 * Public slot. Resumes operation. This slot is called when operation is resumed after
221 * previous suspending. This slot is not virtual and cannot be redefined. Redefine
222 * resumeOperation method to change behavior of operation instead
224 void SUIT_Operation::resume()
227 study()->resume( this );
232 emit resumed( this );
237 * \brief Suspend operation.
239 * Public slot. Suspend operation. This slot is called when operation is suspended
240 * (for starting other one, for example) This slot is not virtual and cannot be
241 * redefined. Redefine suspendOperation method to change behavior of operation instead
243 void SUIT_Operation::suspend()
246 study()->suspend( this );
251 emit suspended( this );
256 * \brief Verifies whether operator is ready to start.
257 * \return TRUE if operation is ready to start
259 * Default implementation returns TRUE. Redefine this method to add own verifications
261 bool SUIT_Operation::isReadyToStart() const
267 * \brief Virtual method called when operation is started
269 * Virtual method called when operation started (see start() method for more description)
271 void SUIT_Operation::startOperation()
278 * \brief Virtual method called when operation is started
280 * Virtual method called when operation stopped - comitted or aborted.
282 void SUIT_Operation::stopOperation()
287 * \brief Virtual method called when operation aborted
289 * Virtual method called when operation aborted (see abort() method for more description)
291 void SUIT_Operation::abortOperation()
296 * \brief Virtual method called when operation resumed
298 * Virtual method called when operation resumed (see resume() method for more description)
300 void SUIT_Operation::resumeOperation()
305 * \brief Virtual method called when operation suspended
307 * Virtual method called when operation suspended (see suspend() method for more description)
309 void SUIT_Operation::suspendOperation()
314 * \brief Virtual method called when operation committed
316 * Virtual method called when operation committed (see commit() method for more description)
318 void SUIT_Operation::commitOperation()
323 * \brief Sets slot which is called when operation is started
324 * \param theReceiver - object containing slot
325 * \param theSlot - slot of theReceiver object
326 * \return TR if slot was connected successfully, FALSE otherwise
328 * Sets slot which is called when operation is started. There is no point in
329 * using this method. It would be better to inherit own operator from base
330 * one and redefine startOperation method
332 bool SUIT_Operation::setSlot( const QObject* theReceiver, const char* theSlot )
334 return connect( this, SIGNAL( callSlot() ), theReceiver, theSlot );
338 * \brief Verifies whether given operator is valid for this one
339 * \param theOtherOp - other operation
340 * \return Returns TRUE if the given operator is valid for this one
342 * Verifies whether given operator is valid for this one (i.e. can be started "above"
345 bool SUIT_Operation::isValid( SUIT_Operation* ) const
351 * \brief Verifies whether this operator can be always started above any already runnig one
352 * \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
354 * This method must be redefined in derived operation if operation of derived class
355 * must be always can start above any launched one. Default implementation returns FALSE,
356 * so it is being checked for IsValid, but some operations may overload IsGranted()
357 * In this case they will always start, no matter what operation is running.
359 bool SUIT_Operation::isGranted() const
365 * \brief Verifies whether operation is an runned one (state()==Running)
366 * \return TRUE if operation is active, FALSE otherwise
368 * Verifies whether operation is an running. Returns TRUE if state of operator
371 bool SUIT_Operation::isRunning() const
373 return state() == Running;
377 * \brief Verifies whether operation is an active for study.
378 * \return TRUE if operation is active, FALSE otherwise
380 * Verifies whether operation is an active on. Returns TRUE if this operator
381 * is active for study
383 bool SUIT_Operation::isActive() const
385 return study() ? study()->activeOperation() == this : false;
389 * \brief Starts operator above this one
390 * \param theOp - operation to be started
392 * Start operator above this one. Use this method if you want to call other operator
395 void SUIT_Operation::start( SUIT_Operation* op, const bool check )
401 study()->start( op, false );
404 connect( this, SIGNAL( stopped( SUIT_Operation* ) ), op, SLOT( abort() ) );
410 * \brief Sets execution status
411 * \param theStatus - execution status
413 * Sets myExecStatus to the given value
415 void SUIT_Operation::setExecStatus( const int theVal )
417 myExecStatus = (ExecStatus)theVal;
421 * \brief Gets execution status
422 * \return Execution status
424 * Gets execution status
426 int SUIT_Operation::execStatus() const
432 * \brief Opens transaction for data modifications.
434 bool SUIT_Operation::openTransaction()
439 return study()->openTransaction();
443 * \brief Aborts transaction and all performed data modifications.
445 bool SUIT_Operation::abortTransaction()
450 return study()->abortTransaction();
454 * \brief Commits transaction and all performed data modifications.
456 bool SUIT_Operation::commitTransaction( const QString& name )
461 return study()->commitTransaction( name );
465 * \brief Returns TRUE if transaction is opened.
467 bool SUIT_Operation::hasTransaction() const
472 return study()->hasTransaction();