FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
base_runner.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (30 Mar. 2015)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 #include "progress.h"
19 #include "base_runner_signals.h"
20 
21 #include <functional>
22 
23 namespace qttask {
24 
25 class Manager;
26 
32 {
33 public:
34  virtual ~BaseRunner();
35 
36  quint64 taskId() const;
37 
38  const QString& taskTitle() const;
39  void setTaskTitle(const QString& title);
40 
41  Progress& progress();
42  const Progress& progress() const;
43 
44  void run(std::function<void()>&& func);
45 
46 protected:
47  BaseRunner(const Manager* mgr);
48 
50 
51  void execRunnableFunc();
52 
53  virtual bool isAbortRequested();
54  virtual void requestAbort();
55  virtual void launch();
56  virtual void destroy();
57 
58 private:
59  friend class BaseRunnerSignals;
60  friend class Manager;
61  friend class Progress;
62 
63  const Manager* m_mgr;
64  quint64 m_taskId;
65  QString m_taskTitle;
66  std::function<void()> m_func;
67 
68  BaseRunnerSignals m_signals;
69  Progress m_progress;
70 };
71 
72 template<typename SELECTOR>
73 class Runner : public BaseRunner
74 { };
75 
76 } // namespace qttask
virtual bool isAbortRequested()
Definition: base_runner.cpp:79
Base class for all runner objects.
Definition: base_runner.h:31
BaseRunner(const Manager *mgr)
Definition: base_runner.cpp:22
Definition: base_runner.h:73
quint64 taskId() const
Definition: base_runner.cpp:32
virtual void launch()
Definition: base_runner.cpp:87
virtual void requestAbort()
Definition: base_runner.cpp:84
virtual ~BaseRunner()
Definition: base_runner.cpp:29
const QString & taskTitle() const
Definition: base_runner.cpp:37
Provides feedback on the progress of an executing operation.
Definition: progress.h:29
BaseRunnerSignals * qtSignals()
Definition: base_runner.cpp:66
Central class providing management of tasks and notifications.
Definition: manager.h:32
Provides task Qt signals, to be forwarded to the Manager object.
Definition: base_runner_signals.h:30
void run(std::function< void()> &&func)
Definition: base_runner.cpp:57
void execRunnableFunc()
Definition: base_runner.cpp:71
virtual void destroy()
Definition: base_runner.cpp:90
void setTaskTitle(const QString &title)
Definition: base_runner.cpp:42
Definition: base_runner.cpp:20
Progress & progress()
Definition: base_runner.cpp:47