Receptacle
 All Classes Files Functions Variables Pages
util_worker.h
1 /*
2 
3 Copyright 2014 William Wedler
4 
5 This file is part of Receptacle
6 
7 Receptacle is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Receptacle is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Receptacle. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 
23 /*
24  Plugin interface
25  See example at:
26  http://qt-project.org/doc/qt-5.1/qtwidgets/tools-plugandpaint.html
27 http://michael-stengel.com/blog/?p=4
28 https://qt-project.org/doc/qt-5.0/qtwidgets/tools-plugandpaintplugins-basictools.html
29 
30 Object Factory with plugins:
31 http://stackoverflow.com/questions/9070817/qobject-factory-in-qt-pluginnon-creator
32  */
33 
34 #ifndef UTIL_WORKER_H
35 #define UTIL_WORKER_H
36 
37 #include <QObject>
38 #include <QHash>
39 #include <QString>
40 
41 class UtilWorker : public QObject
42 {
43  Q_OBJECT
44  public:
45  UtilWorker(int argc=0, char *argv[]=NULL, QObject* parent=0) : QObject( parent ), meta_hash(), \
47  virtual ~UtilWorker(){}
48  virtual void init(){}
49  virtual bool is_valid(){return true;}
50  virtual void start(){emit complete(0);}
51  virtual void cleanup(){}
52  virtual QString meta_lookup(const QString &key){
53  return (meta_hash.contains(key)) ? meta_hash.value(key, QString()) : QString();
54  }
55  virtual QObject* get_widget(){return NULL;}
56 public slots:
60  virtual void exit_early(){is_terminate_requested = true;}
61  signals:
62  // notify when we're done
63  void complete(int result=0);
64  protected:
65  QHash<QString, QString> meta_hash;
66 
71 };
72 
73 #endif //UTIL_WORKER_H
74 
bool is_terminate_requested
is_terminate_requested flags the worker that early exit has been requested when set to True ...
Definition: util_worker.h:70
Definition: util_worker.h:41
virtual void exit_early()
exit_early indicates that a cancel request has been made.
Definition: util_worker.h:60