ScummVM API documentation
resource.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TOLTECS_RESOURCE_H
23 #define TOLTECS_RESOURCE_H
24 
25 #include "common/file.h"
26 #include "common/hashmap.h"
27 #include "common/hash-str.h"
28 
29 #include "engines/engine.h"
30 
31 namespace Toltecs {
32 
33 const uint kMaxCacheItems = 1024;
34 const uint kMaxCacheSize = 8 * 1024 * 1024; // 8 MB
35 
36 
37 class ArchiveReader : public Common::File {
38 public:
39  ArchiveReader();
40  ~ArchiveReader() override;
41 
42  void openArchive(const char *filename);
43 
44  // Returns the size of the opened resource
45  uint32 openResource(uint resIndex);
46  // Closes the resource
47  void closeResource();
48  // Returns the size of the resource
49  uint32 getResourceSize(uint resIndex);
50 
51  void dump(uint resIndex);
52 
53 protected:
54  uint32 *_offsets;
55 
56 };
57 
58 struct Resource {
59  uint32 size;
60  byte *data;
61 };
62 
64 public:
66  ~ResourceCache();
67 
68  Resource *load(uint resIndex);
69  void purgeCache();
70 
71 protected:
73 
74  ToltecsEngine *_vm;
75 
76  ResourceMap _cache;
77 
78 };
79 
80 
81 } // End of namespace Toltecs
82 
83 #endif /* TOLTECS_H */
Definition: animation.h:28
Definition: resource.h:58
Definition: resource.h:37
Definition: resource.h:63
Definition: file.h:47
int64 size() const override
Definition: toltecs.h:94