Debian Codegraph @

include/jobs/job.h

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2020 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #ifndef H_FREAC_JOB
14 #define H_FREAC_JOB
15
16 #include <boca.h>
17
18 using namespace smooth;
19 using namespace smooth::GUI;
20
21 namespace freac
22 {
23 abstract class Job : public ListEntry
24 {
25 private:
26 Text *progressLabel;
27 Progressbar *progress;
28 EditBox *progressValue;
29
30 Text *timeLabel;
31 EditBox *timeValue;
32
33 Hotspot *closeHotspot;
34
35 UnsignedInt64 startTicks;
36 Int previousSecondsLeft;
37
38 static Array<Job *> scheduled;
39 static Array<Job *> planned;
40 static Array<Job *> running;
41
42 static Array<Job *> all;
43
44 static Threads::Mutex mutex;
45 protected:
46 BoCA::Config *configuration;
47
48 Array<String> errors;
49 Array<String> warnings;
50
51 Bool waiting;
52 Bool abort;
53 public:
54 Job();
55 virtual ~Job();
56
57 static String SecondsToString(UnsignedInt);
58
59 virtual Int Paint(Int);
60
61 Int Schedule();
62
63 Int RunPrecheck();
64 Int Run();
65
66 Int RequestAbort();
67
68 /* Overwrite Precheck to run checks before
69 * the job is actually scheduled.
70 */
71 virtual Error Precheck();
72
73 /* Overwrite ReadyToRun to check conditions
74 * before running the job.
75 */
76 virtual Bool ReadyToRun();
77
78 /* Implement your actual job in Perform.
79 */
80 virtual Error Perform() = 0;
81 accessors:
82 Int SetText(const String &);
83
84 Int SetProgress(Int);
85 Int GetProgress() const;
86
87 Bool IsWaiting() const { return waiting; }
88
89 const Array<String> &GetErrors() const { return errors; }
90 const Array<String> &GetWarnings() const { return warnings; }
91
92 static const Array<Job *> &GetScheduledJobs() { return scheduled; }
93 static const Array<Job *> &GetPlannedJobs() { return planned; }
94 static const Array<Job *> &GetRunningJobs() { return running; }
95
96 static const Array<Job *> &GetAllJobs() { return all; }
97 slots:
98 Void OnChangeSize(const Size &);
99
100 Void OnDoubleClick();
101 Void OnClickToClose();
102 signals:
103 static Signal0<Void> onChange;
104
105 Signal0<Void> onRun;
106 Signal0<Void> onFinish;
107
108 static Signal1<Void, Job *> onPlanJob;
109 static Signal1<Void, Job *> onRunJob;
110 static Signal1<Void, Job *> onFinishJob;
111 };
112 };
113
114 #endif