Back to index

salome-gui  6.5.0
SUIT_Operation.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef SUIT_OPERATION_H
00024 #define SUIT_OPERATION_H
00025 
00026 #include "SUIT.h"
00027 
00028 #include <QObject>
00029 #include <QPointer>
00030 
00031 class SUIT_Study;
00032 class SUIT_Application;
00033 
00051 #ifdef WIN32
00052 #pragma warning( disable:4251 )
00053 #endif
00054 
00055 class SUIT_EXPORT SUIT_Operation : public QObject
00056 {
00057   Q_OBJECT
00058 
00059 public:
00061   enum OperationState
00062   {
00063     Waiting,  
00064     Running,  
00065     Suspended 
00066   };
00067 
00073   enum ExecStatus
00074   {
00075     Rejected, 
00076     Accepted  
00077   };
00078 
00082   enum Flags
00083   {
00084     None        = 0x00, 
00085     Transaction = 0x01  
00086   };
00087 
00088 public:
00089   SUIT_Operation( SUIT_Application* );
00090   virtual ~SUIT_Operation();
00091 
00092   OperationState    state() const;
00093   bool              isActive() const;
00094   bool              isRunning() const;
00095 
00096   SUIT_Study*       study() const;
00097   virtual void      setStudy( SUIT_Study* theStudy );
00098   
00099   SUIT_Application* application() const;
00100   virtual void      setApplication( SUIT_Application* theApp );
00101 
00102   virtual bool      isValid( SUIT_Operation* theOtherOp ) const;
00103   virtual bool      isGranted() const;
00104 
00105   bool              setSlot( const QObject* theReceiver, const char* theSlot );
00106 
00107   void              setFlags( const int );
00108   void              clearFlags( const int );
00109   bool              testFlags( const int ) const;
00110 
00111   virtual QString   operationName() const;
00112 
00113   int               execStatus() const;
00114 
00115 signals:
00116   void              started( SUIT_Operation* );
00117   void              aborted( SUIT_Operation* );
00118   void              committed( SUIT_Operation* );
00119 
00120   void              stopped( SUIT_Operation* );
00121   void              resumed( SUIT_Operation* );
00122   void              suspended( SUIT_Operation* );
00123 
00124   void              callSlot();
00125 
00126 public slots:
00127   void              start();
00128   void              abort();
00129   void              commit();
00130   void              resume();
00131   void              suspend();
00132 
00133 protected:
00134   virtual bool      isReadyToStart() const;
00135 
00136   virtual void      stopOperation();
00137   virtual void      startOperation();
00138   virtual void      abortOperation();
00139   virtual void      commitOperation();
00140   virtual void      resumeOperation();
00141   virtual void      suspendOperation();
00142 
00143   virtual bool      openTransaction();
00144   virtual bool      abortTransaction();
00145   virtual bool      hasTransaction() const;
00146   virtual bool      commitTransaction( const QString& = QString() );
00147 
00148   void              setExecStatus( const int );
00149 
00150   void              setState( const OperationState );
00151 
00152   void              start( SUIT_Operation*, const bool = false );
00153 
00154 private:
00155   typedef QPointer<SUIT_Study> StudyPtr;
00156 
00157 private:
00158   SUIT_Application* myApp;        
00159   int               myFlags;      
00160   StudyPtr          myStudy;      
00161   OperationState    myState;      
00162   ExecStatus        myExecStatus; 
00163 
00164   friend class SUIT_Study;
00165 };
00166 
00167 #ifdef WIN32
00168 #pragma warning( default:4251 )
00169 #endif
00170 
00171 #endif