finish move to Python-handled imports
[Tsunagari.git] / src / reader.h
blobc6459d49f526bb77ce15fcc79d41c411b4b736b5
1 /***************************************
2 ** Tsunagari Tile Engine **
3 ** reader.h **
4 ** Copyright 2011-2013 PariahSoft LLC **
5 ***************************************/
7 // **********
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // **********
27 #ifndef READER_H
28 #define READER_H
30 #include <string>
32 #include <boost/shared_ptr.hpp>
33 #include <libxml/parser.h>
35 #include "cache.h"
36 #include "image.h"
37 #include "sound.h"
38 #include "tiledimage.h"
39 #include "xml.h"
41 namespace Gosu {
42 class Buffer;
43 class Sample;
44 class Song;
47 // We hand out and manage resources in these forms:
48 typedef boost::shared_ptr<Sound> SampleRef;
50 /**
51 * FIXME
52 * Provides data and resource extraction for a World.
53 * Each World comes bundled with associated data in the form of a Zip file.
54 * A Reader object knows how to navigate the data, extract individual
55 * requested files, and process the files into data structures. The final data
56 * structures are kept in memory for future requests.
58 class Reader
60 public:
61 static bool init(char* argv0);
62 static void deinit();
64 static bool prependPath(const std::string& path);
65 static bool appendPath(const std::string& path);
66 static bool rmPath(const std::string& path);
68 //! Returns true if the World contains a resource by that name.
69 static bool resourceExists(const std::string& name);
70 static bool directoryExists(const std::string& name);
71 static bool fileExists(const std::string& name);
73 static Gosu::Buffer* readBuffer(const std::string& name);
74 static std::string readString(const std::string& name);
76 //! Request an image from the World.
77 static ImageRef getImage(const std::string& name);
79 //! Request an image resource from the World and splits it into a
80 //! number of tiles that each have width and height w by h.
81 static TiledImageRef getTiledImage(const std::string& name,
82 int w, int h);
84 //! Request a sound object from the World. The sound will be
85 //! completely loaded into memory at once.
86 static SampleRef getSample(const std::string& name);
88 //! Request an XML document from the World.
89 static XMLRef getXMLDoc(const std::string& name,
90 const std::string& dtdPath);
92 //! Request a text file from the World.
93 static std::string getText(const std::string& name);
95 //! Expunge old resources cached in memory. Decisions on which are
96 //! removed and which are kept are based on the global Conf struct.
97 static void garbageCollect();
100 void exportReader();
102 #endif