/* fre:ac - free audio converter * Copyright (C) 2001-2020 Robert Kausch * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of * the License, or (at your option) any later version. * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef H_FREAC_JOB #define H_FREAC_JOB #include using namespace smooth; using namespace smooth::GUI; namespace freac { abstract class Job : public ListEntry { private: Text *progressLabel; Progressbar *progress; EditBox *progressValue; Text *timeLabel; EditBox *timeValue; Hotspot *closeHotspot; UnsignedInt64 startTicks; Int previousSecondsLeft; static Array scheduled; static Array planned; static Array running; static Array all; static Threads::Mutex mutex; protected: BoCA::Config *configuration; Array errors; Array warnings; Bool waiting; Bool abort; public: Job(); virtual ~Job(); static String SecondsToString(UnsignedInt); virtual Int Paint(Int); Int Schedule(); Int RunPrecheck(); Int Run(); Int RequestAbort(); /* Overwrite Precheck to run checks before * the job is actually scheduled. */ virtual Error Precheck(); /* Overwrite ReadyToRun to check conditions * before running the job. */ virtual Bool ReadyToRun(); /* Implement your actual job in Perform. */ virtual Error Perform() = 0; accessors: Int SetText(const String &); Int SetProgress(Int); Int GetProgress() const; Bool IsWaiting() const { return waiting; } const Array &GetErrors() const { return errors; } const Array &GetWarnings() const { return warnings; } static const Array &GetScheduledJobs() { return scheduled; } static const Array &GetPlannedJobs() { return planned; } static const Array &GetRunningJobs() { return running; } static const Array &GetAllJobs() { return all; } slots: Void OnChangeSize(const Size &); Void OnDoubleClick(); Void OnClickToClose(); signals: static Signal0 onChange; Signal0 onRun; Signal0 onFinish; static Signal1 onPlanJob; static Signal1 onRunJob; static Signal1 onFinishJob; }; }; #endif