argh, clean out copy
[supertux.git] / src / src / addon.hpp
1 //  $Id$
2 //
3 //  SuperTux - Add-on
4 //  Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 //
21 #ifndef ADDON_H
22 #define ADDON_H
23
24 #include <string>
25 #include <vector>
26 #include "lisp/parser.hpp"
27 #include "lisp/lisp.hpp"
28 #include "lisp/writer.hpp"
29
30 /**
31  * Represents an (available or installed) Add-on, e.g. a level set
32  */
33 class Addon
34 {
35 public:
36   std::string kind;
37   std::string title;
38   std::string author;
39   std::string license;
40   std::string http_url;
41   std::string file;
42   std::string md5;
43
44   bool isInstalled;
45
46   /**
47    * Download and install Add-on
48    */
49   void install();
50
51   /**
52    * Physically delete Add-on
53    */
54   void remove();
55
56   /**
57    * Read additional information from given contents of a (supertux-addoninfo ...) block
58    */
59   void parse(const lisp::Lisp& lisp);
60
61   /**
62    * Read additional information from given file
63    */
64   void parse(std::string fname);
65
66   /**
67    * Writes out Add-on metainformation to a Lisp Writer
68    */
69   void write(lisp::Writer& writer) const;
70
71   /**
72    * Writes out Add-on metainformation to a file
73    */
74   void write(std::string fname) const;
75
76   /**
77    * Checks if Add-on is the same as given one. 
78    * If available, checks MD5 sum, else relies on title alone.
79    */
80   bool equals(const Addon& addon2) const;
81
82 };
83
84 #endif