| 1 | /* |
| 2 | * Copyright (C) 1999 Ross Combs ([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 |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #ifndef INCLUDED_ADBANNER_H |
| 19 | #define INCLUDED_ADBANNER_H |
| 20 | |
| 21 | #include <array> |
| 22 | #include <cstdint> |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include "common/tag.h" |
| 27 | #include "common/bn_type.h" |
| 28 | |
| 29 | |
| 30 | namespace pvpgn |
| 31 | { |
| 32 | namespace bnetd |
| 33 | { |
| 34 | /** |
| 35 | * Forward Declarations |
| 36 | */ |
| 37 | class AdBanner; |
| 38 | |
| 39 | /***************************************************************************************************/ |
| 40 | |
| 41 | class AdBannerSelector |
| 42 | { |
| 43 | public: |
| 44 | AdBannerSelector() = default; |
| 45 | ~AdBannerSelector() = default; |
| 46 | |
| 47 | bool is_loaded() const noexcept; |
| 48 | void load(const std::string& filename); |
| 49 | void unload() noexcept; |
| 50 | |
| 51 | std::size_t size() const noexcept; |
| 52 | |
| 53 | const AdBanner* const pick(t_clienttag client_tag, t_gamelang client_lang, std::size_t prev_ad_id); |
| 54 | const AdBanner* const find(t_clienttag client_tag, t_gamelang client_lang, std::size_t ad_id); |
| 55 | |
| 56 | private: |
| 57 | bool m_loaded = false; |
| 58 | std::vector<AdBanner> m_banners; |
| 59 | }; |
| 60 | extern AdBannerSelector AdBannerList; |
| 61 | |
| 62 | /***************************************************************************************************/ |
| 63 | |
| 64 | class AdBanner |
| 65 | { |
| 66 | public: |
| 67 | AdBanner() = delete; |
| 68 | |
| 69 | bool is_empty() const; |
| 70 | |
| 71 | std::size_t get_id() const noexcept; |
| 72 | std::string get_filename() const noexcept; |
| 73 | unsigned int get_extension_tag() const noexcept; |
| 74 | std::string get_url() const noexcept; |
| 75 | t_clienttag get_client() const noexcept; |
| 76 | t_gamelang get_language() const noexcept; |
| 77 | |
| 78 | private: |
| 79 | friend void AdBannerSelector::load(const std::string& filename); |
| 80 | |
| 81 | AdBanner(std::size_t id, bn_int extensiontag, const std::string& filename, const std::string& url, t_clienttag clienttag, t_gamelang language); |
| 82 | |
| 83 | const std::size_t m_id; |
| 84 | const std::string m_filename; |
| 85 | const unsigned int m_extensiontag; |
| 86 | const std::string m_url; |
| 87 | const t_clienttag m_client; |
| 88 | const t_gamelang m_language; |
| 89 | }; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #endif |