Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUIT_Operation.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef SUIT_OPERATION_H
24 #define SUIT_OPERATION_H
25 
26 #include "SUIT.h"
27 
28 #include <QObject>
29 #include <QPointer>
30 
31 class SUIT_Study;
32 class SUIT_Application;
33 
51 #ifdef WIN32
52 #pragma warning( disable:4251 )
53 #endif
54 
56 {
57  Q_OBJECT
58 
59 public:
62  {
65  Suspended
66  };
67 
74  {
76  Accepted
77  };
78 
82  enum Flags
83  {
84  None = 0x00,
85  Transaction = 0x01
86  };
87 
88 public:
90  virtual ~SUIT_Operation();
91 
92  OperationState state() const;
93  bool isActive() const;
94  bool isRunning() const;
95 
96  SUIT_Study* study() const;
97  virtual void setStudy( SUIT_Study* theStudy );
98 
99  SUIT_Application* application() const;
100  virtual void setApplication( SUIT_Application* theApp );
101 
102  virtual bool isValid( SUIT_Operation* theOtherOp ) const;
103  virtual bool isGranted() const;
104 
105  bool setSlot( const QObject* theReceiver, const char* theSlot );
106 
107  void setFlags( const int );
108  void clearFlags( const int );
109  bool testFlags( const int ) const;
110 
111  virtual QString operationName() const;
112 
113  int execStatus() const;
114 
115 signals:
116  void started( SUIT_Operation* );
117  void aborted( SUIT_Operation* );
118  void committed( SUIT_Operation* );
119 
120  void stopped( SUIT_Operation* );
121  void resumed( SUIT_Operation* );
122  void suspended( SUIT_Operation* );
123 
124  void callSlot();
125 
126 public slots:
127  void start();
128  void abort();
129  void commit();
130  void resume();
131  void suspend();
132 
133 protected:
134  virtual bool isReadyToStart() const;
135 
136  virtual void stopOperation();
137  virtual void startOperation();
138  virtual void abortOperation();
139  virtual void commitOperation();
140  virtual void resumeOperation();
141  virtual void suspendOperation();
142 
143  virtual bool openTransaction();
144  virtual bool abortTransaction();
145  virtual bool hasTransaction() const;
146  virtual bool commitTransaction( const QString& = QString() );
147 
148  void setExecStatus( const int );
149 
150  void setState( const OperationState );
151 
152  void start( SUIT_Operation*, const bool = false );
153 
154 private:
155  typedef QPointer<SUIT_Study> StudyPtr;
156 
157 private:
159  int myFlags;
163 
164  friend class SUIT_Study;
165 };
166 
167 #ifdef WIN32
168 #pragma warning( default:4251 )
169 #endif
170 
171 #endif