1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2019-2019 Bareos GmbH & Co. KG 5 6 This program is Free Software; you can redistribute it and/or 7 modify it under the terms of version three of the GNU Affero General Public 8 License as published by the Free Software Foundation, which is 9 listed in the file LICENSE. 10 11 This program is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301, USA. 20 */ 21 22 #ifndef BAREOS_SRC_DIRD_SCHEDULER_TIME_ADAPTER_H_ 23 #define BAREOS_SRC_DIRD_SCHEDULER_TIME_ADAPTER_H_ 24 25 #include "include/bareos.h" 26 27 namespace directordaemon { 28 29 class TimeSource { 30 public: 31 virtual time_t SystemTime() = 0; 32 virtual void SleepFor(std::chrono::seconds wait_interval) = 0; 33 virtual void Terminate() = 0; 34 virtual ~TimeSource() = default; 35 }; 36 37 class SchedulerTimeAdapter { 38 public: 39 std::unique_ptr<TimeSource> time_source_; 40 time_t default_wait_interval_{60}; 41 virtual ~SchedulerTimeAdapter() = default; 42 43 protected: SchedulerTimeAdapter(std::unique_ptr<TimeSource> time_source)44 SchedulerTimeAdapter(std::unique_ptr<TimeSource> time_source) 45 : time_source_(std::move(time_source)) 46 { 47 } 48 }; 49 50 } /* namespace directordaemon */ 51 52 #endif // BAREOS_SRC_DIRD_SCHEDULER_TIME_ADAPTER_H_ 53