1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
5    Copyright (C) 2011-2012 Planets Communications B.V.
6    Copyright (C) 2013-2019 Bareos GmbH & Co. KG
7 
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    Affero General Public License for more details.
17 
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22 */
23 
24 #ifndef BAREOS_DIRD_SCHEDULER_H_
25 #define BAREOS_DIRD_SCHEDULER_H_
26 
27 #include <memory>
28 #include <functional>
29 
30 class JobControlRecord;
31 
32 namespace directordaemon {
33 
34 class JobResource;
35 class SchedulerTimeAdapter;
36 class SchedulerPrivate;
37 
38 class Scheduler {
39  public:
40   Scheduler() noexcept;
41   Scheduler(std::unique_ptr<SchedulerTimeAdapter> time_adapter,
42             std::function<void(JobControlRecord*)> ExecuteJob) noexcept;
43   ~Scheduler();
44 
45   void Run();
46   void Terminate();
47   void ClearQueue();
48   void AddJobWithNoRunResourceToQueue(JobResource* job);
49   static Scheduler& GetMainScheduler() noexcept;
50 
51  private:
52   std::unique_ptr<SchedulerPrivate> impl_;
53 };
54 
55 } /* namespace directordaemon */
56 
57 #endif  // BAREOS_DIRD_SCHEDULER_H_
58