2020-08-10 11:22:25 +01:00
|
|
|
/* Copyright 2020, Michele Santullo
|
|
|
|
* This file is part of orotool.
|
|
|
|
*
|
|
|
|
* Orotool 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Orotool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Orotool. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-08-10 03:01:54 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "eventia/private/context.hpp"
|
|
|
|
#include "eventia/timer.hpp"
|
|
|
|
|
|
|
|
namespace roar11 {
|
|
|
|
class ThreadPool;
|
|
|
|
} //namespace roar11
|
|
|
|
|
|
|
|
namespace oro {
|
|
|
|
class Api;
|
|
|
|
class OriginsDB;
|
2020-08-10 18:52:40 +01:00
|
|
|
struct Header;
|
2020-08-10 19:19:06 +01:00
|
|
|
struct Shops;
|
|
|
|
struct Icons;
|
|
|
|
struct Items;
|
2020-08-10 03:01:54 +01:00
|
|
|
} //namespace oro
|
|
|
|
|
|
|
|
namespace duck {
|
|
|
|
|
|
|
|
class TimerBase : public eve::Timer {
|
|
|
|
public:
|
|
|
|
TimerBase (
|
|
|
|
const eve::Context& ctx,
|
|
|
|
double timeout,
|
|
|
|
roar11::ThreadPool* pool,
|
|
|
|
oro::Api* oro_api,
|
|
|
|
oro::OriginsDB* db
|
|
|
|
);
|
|
|
|
virtual ~TimerBase() noexcept = default;
|
|
|
|
|
|
|
|
virtual void on_timer() override;
|
|
|
|
|
|
|
|
protected:
|
2020-08-10 18:52:40 +01:00
|
|
|
void set_next_timer (const oro::Header& header);
|
2020-08-10 19:19:06 +01:00
|
|
|
void update_db (const oro::Shops& shops);
|
|
|
|
void update_db (const oro::Items& items);
|
|
|
|
void update_db (const oro::Icons& icons);
|
2020-08-10 03:01:54 +01:00
|
|
|
roar11::ThreadPool& pool();
|
|
|
|
oro::Api& oro_api();
|
|
|
|
oro::OriginsDB& db();
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void fetch_data() = 0;
|
|
|
|
|
|
|
|
roar11::ThreadPool* m_pool;
|
|
|
|
oro::Api* m_oro_api;
|
|
|
|
oro::OriginsDB* m_db;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace duck
|