.travis.yml: use env.matrix for Debug/Release builds
[supertux.git] / src / addon / addon.hpp
1 //  SuperTux - Add-on
2 //  Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
3 //                2014 Ingo Ruhnke <grumbel@gmail.com>
4 //
5 //  This program is free software: you can redistribute it and/or modify
6 //  it under the terms of the GNU General Public License as published by
7 //  the Free Software Foundation, either version 3 of the License, or
8 //  (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 #ifndef HEADER_SUPERTUX_ADDON_ADDON_HPP
19 #define HEADER_SUPERTUX_ADDON_ADDON_HPP
20
21 #include <assert.h>
22 #include <memory>
23 #include <string>
24
25 #include "util/reader_fwd.hpp"
26
27 class Addon
28 {
29 public:
30   static std::unique_ptr<Addon> parse(const Reader& lisp);
31   static std::unique_ptr<Addon> parse(const std::string& fname);
32
33   enum Type { WORLD, WORLDMAP, LEVELSET };
34
35 private:
36   // fields provided by the addon.zip itself
37   std::string m_id;
38   int m_version;
39   Type m_type;
40   std::string m_title;
41   std::string m_author;
42   std::string m_license;
43
44   // additional fields provided for addons from an addon repository
45   std::string m_url;
46   std::string m_md5;
47
48   // fields filled by the AddonManager
49   std::string m_install_filename;
50   bool m_enabled;
51
52 private:
53   Addon();
54
55 public:
56   std::string get_id() const { return m_id; }
57   int get_version() const { return m_version; }
58
59   Type get_type() const { return m_type; }
60   std::string get_title() const { return m_title; }
61   std::string get_author() const { return m_author; }
62   std::string get_license() const { return m_license; }
63
64   std::string get_url() const { return m_url; }
65   std::string get_md5() const { return m_md5; }
66
67   std::string get_filename() const;
68   std::string get_install_filename() const;
69
70   bool is_installed() const;
71   bool is_enabled() const;
72
73   void set_install_filename(const std::string& absolute_filename, const std::string& md5);
74   void set_enabled(bool v);
75
76 private:
77   Addon(const Addon&) = delete;
78   Addon& operator=(const Addon&) = delete;
79 };
80
81 #endif
82
83 /* EOF */