Large scale refactor/rewrite of the AddonManager, adding cleaner separation between...
[supertux.git] / src / addon / addon.hpp
1 //  SuperTux - Add-on
2 //  Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (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, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_ADDON_ADDON_HPP
18 #define HEADER_SUPERTUX_ADDON_ADDON_HPP
19
20 #include <assert.h>
21 #include <memory>
22 #include <string>
23
24 #include "util/reader_fwd.hpp"
25
26 class Addon
27 {
28 public:
29   static std::unique_ptr<Addon> parse(const Reader& lisp);
30   static std::unique_ptr<Addon> parse(const std::string& fname);
31
32   enum Type { WORLD, WORLDMAP, LEVELSET };
33
34 private:
35   // fields provided by the addon.zip itself
36   std::string m_id;
37   int m_version;
38   Type m_type;
39   std::string m_title;
40   std::string m_author;
41   std::string m_license;
42
43   // additional fields provided for addons from an addon repository
44   std::string m_http_url;
45   std::string m_md5;
46
47   // fields filled by the AddonManager
48   std::string m_install_filename;
49   bool m_enabled;
50
51 private:
52   Addon();
53
54 public:
55   std::string get_id() const { return m_id; }
56
57   Type get_type() const { return m_type; }
58   std::string get_title() const { return m_title; }
59   std::string get_author() const { return m_author; }
60   std::string get_license() const { return m_license; }
61
62   std::string get_http_url() const { return m_http_url; }
63   std::string get_md5() const { return m_md5; }
64
65   std::string get_filename() const;
66   std::string get_install_filename() const;
67
68   bool is_installed() const;
69   bool is_enabled() const;
70
71   void set_install_filename(const std::string& absolute_filename);
72   void set_enabled(bool v);
73
74 private:
75   Addon(const Addon&) = delete;
76   Addon& operator=(const Addon&) = delete;
77 };
78
79 #endif
80
81 /* EOF */