casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSThread.qo.h
Go to the documentation of this file.
1 //# PlotMSThread.qo.h: Threading classes for PlotMS.
2 //# Copyright (C) 2009
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTMSTHREAD_QO_H_
28 #define PLOTMSTHREAD_QO_H_
29 
31 #include <QObject>
32 
33 namespace casa {
34 
35 class QtProgressWidget;
36 
37 // Abstract class to control a threaded operation from the GUI.
38 // Classes that want to run PlotMSThreads should:
39 // 1) Provide a QtProgressWidget in the main (GUI) thread.
40 // 2) Connect the finishedOperation() signal to a slot as needed.
41 // 3) Call startOperation() to start the thread.
42 // 4) Call the post-thread method after completion, if there is one.
43 
44 class PlotMSThread : public QObject, public ThreadController {
45  Q_OBJECT
46 
47 public:
48  // Constructor which takes the progress widget to use, and an optional
49  // post-thread method that should be called when the thread is finished.
50  PlotMSThread( QtProgressWidget* progress,
52  PMSPTObject postThreadObject = NULL);
53 
54  // Destructor.
55  virtual ~PlotMSThread();
56 
57 
58  // ABSTRACT METHODS //
59 
60  // Abstract method which does the operation. IMPORTANT: subclasses MUST
61  // emit the finished() signal when finished.
62  virtual void startOperation() = 0;
63 
64 
65  // IMPLEMENTED METHODS //
66  virtual void finished();
67 
68  //Overridden from BackgroundThread in order to update the progress
69  //widget on the GUI thread.
70  virtual void initializeProgress(const casacore::String& operationName);
71  virtual void setProgress(unsigned int progress, const casacore::String& status);
72  virtual void finishProgress();
73 
74  int getId();
75  virtual QString getName() const = 0;
76  virtual bool isCacheThread() const;
77 
78 signals:
79  // This signal MUST be emitted after start() has been called, and when the
80  // operation has finished. The thread parameter points to the thread that
81  // has just completed.
82  void finishedOperation(PlotMSThread* thread);
83  void updateProgress(unsigned int value, const QString& statusStr );
84  void initProgress(const QString& operationName );
85  void finalizeProgress();
86 
87 protected:
88  //Allows subclasses to override and do any clean-up they need to
89  //once the background thread has completed.
90  virtual void threadFinished(){}
91  //Signal that clean-up and thread work is done.
92  void signalFinishedOperation( PlotMSThread* thread );
93 
94 protected slots:
95  // For when the user requests "cancel" for the thread.
96  void cancelThread();
97 
98 private slots:
99  // For when the user requests "background" for the thread.
100  void backgroundThread();
101 
102  // For when the user requests "pause" for the thread.
103  void pauseThread();
104 
105  // For when the user requests "resume" for the thread.
106  void resumeThread();
107 
108 private:
109  int id;
110 
111 };
112 }
113 
114 #endif /* PLOTMSTHREAD_QO_H_ */
void initProgress(const QString &operationName)
void resumeThread()
For when the user requests &quot;resume&quot; for the thread.
virtual bool isCacheThread() const
virtual void postThreadMethod()
Executes the post-thread method as needed.
virtual void finishProgress()
PlotMSThread(QtProgressWidget *progress, PMSPTMethod postThreadMethod=NULL, PMSPTObject postThreadObject=NULL)
Constructor which takes the progress widget to use, and an optional post-thread method that should be...
virtual QString getName() const =0
virtual void setProgress(unsigned int progress, const casacore::String &status)
void * PMSPTObject
Typedefs for using post-thread methods.
virtual void finished()
IMPLEMENTED METHODS //.
void pauseThread()
For when the user requests &quot;pause&quot; for the thread.
virtual void threadFinished()
Allows subclasses to override and do any clean-up they need to once the background thread has complet...
Abstract class to control a threaded operation from the GUI.
void PMSPTMethod(PMSPTObject, bool)
virtual void startOperation()=0
ABSTRACT METHODS //.
virtual ~PlotMSThread()
Destructor.
virtual void initializeProgress(const casacore::String &operationName)
Overridden from BackgroundThread in order to update the progress widget on the GUI thread...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void cancelThread()
For when the user requests &quot;cancel&quot; for the thread.
GUI for displaying progress information.
void finishedOperation(PlotMSThread *thread)
This signal MUST be emitted after start() has been called, and when the operation has finished...
void backgroundThread()
For when the user requests &quot;background&quot; for the thread.
void signalFinishedOperation(PlotMSThread *thread)
Signal that clean-up and thread work is done.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void updateProgress(unsigned int value, const QString &statusStr)