ScummVM API documentation
qd_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 QDENGINE_QDCORE_QD_RESOURCE_H
23#define QDENGINE_QDCORE_QD_RESOURCE_H
24
25#include "common/path.h"
26
27
29
32namespace QDEngine {
33
35public:
46 };
47
48 qdResource();
49 qdResource(const qdResource &res);
50 virtual ~qdResource();
51
52 qdResource &operator = (const qdResource &res);
53
55 virtual bool load_resource() = 0;
57 virtual bool free_resource() = 0;
58
60 virtual void set_resource_file(const Common::Path &file_name) = 0;
62
65 virtual const Common::Path resource_file() const = 0;
66
68 bool is_resource_loaded() const {
69 return _is_loaded;
70 }
71
72 static file_format_t file_format(const Common::Path &file_name);
73
74#ifdef __QD_DEBUG_ENABLE__
75 virtual uint32 resource_data_size() const = 0;
76#endif
77
78protected:
79
81 void toggle_resource_status(bool st = true) {
82 _is_loaded = st;
83 }
84
85private:
86
88 bool _is_loaded;
89};
90
91#ifdef __QD_DEBUG_ENABLE__
92class qdResourceInfo {
93public:
94 qdResourceInfo(const qdResource *res = NULL, const qdNamedObject *owner = NULL);
95 qdResourceInfo(const qdResourceInfo &inf) : _resource(inf._resource), _data_size(inf._data_size), _resource_owner(inf._resource_owner) { }
96 ~qdResourceInfo();
97
98 qdResourceInfo &operator = (const qdResourceInfo &inf) {
99 if (this == &inf) return *this;
100
101 _resource = inf._resource;
102 _resource_owner = inf._resource_owner;
103 _data_size = inf._data_size;
104
105 return *this;
106 }
107
108 bool operator < (const qdResourceInfo &inf) const {
109 return _data_size < inf._data_size;
110 }
111
112 uint32 data_size() const {
113 return _data_size;
114 }
115
116 qdResource::file_format_t file_format() const;
117
118private:
119 uint32 _data_size;
120 const qdResource *_resource;
121 const qdNamedObject *_resource_owner;
122};
123
124typedef Std::vector<qdResourceInfo> qdResourceInfoContainer;
125
126#endif
127
128} // namespace QDEngine
129
130#endif // QDENGINE_QDCORE_QD_RESOURCE_H
Definition: path.h:52
Definition: qd_resource.h:34
bool is_resource_loaded() const
Возвращает true, если данные ресурса загружены в память.
Definition: qd_resource.h:68
virtual void set_resource_file(const Common::Path &file_name)=0
Устанавливает имя файла, в котором хранятся данные ресурса.
file_format_t
Форматы файлов.
Definition: qd_resource.h:37
@ RES_SPRITE
спрайт - .tga
Definition: qd_resource.h:41
@ RES_SOUND
звук - .wav
Definition: qd_resource.h:43
@ RES_UNKNOWN
неопознанный формат
Definition: qd_resource.h:45
@ RES_ANIMATION
анимация - .qda
Definition: qd_resource.h:39
virtual const Common::Path resource_file() const =0
Возвращает имя файла, в котором хранятся данные ресурса.
virtual bool free_resource()=0
Выгружает из памяти данные ресурса.
virtual bool load_resource()=0
Загружает в память данные ресурса.
void toggle_resource_status(bool st=true)
Устанавливает или скидывает флаг, показывающий что данные ресурса загружены в память.
Definition: qd_resource.h:81
Definition: vector.h:39
Базовый класс для игровых ресурсов.
Definition: console.h:28