]> git.tdb.fi Git - libs/gl.git/blob - source/resource.h
Change some class names
[libs/gl.git] / source / resource.h
1 #ifndef MSP_GL_RESOURCE_H_
2 #define MSP_GL_RESOURCE_H_
3
4 #include <msp/core/inttypes.h>
5 #include <msp/io/seekable.h>
6
7 namespace Msp {
8 namespace GL {
9
10 class ResourceManager;
11 class Resources;
12
13 class Resource
14 {
15 public:
16         class AsyncLoader
17         {
18         protected:
19                 AsyncLoader() { }
20         public:
21                 virtual ~AsyncLoader() { }
22
23                 virtual bool needs_sync() const = 0;
24                 virtual bool process() = 0;
25         };
26
27 protected:
28         ResourceManager *manager;
29         void *manager_data;
30
31         Resource();
32 public:
33         virtual ~Resource();
34
35         void set_manager(ResourceManager *);
36         ResourceManager *get_manager() const { return manager; }
37         void *get_manager_data() const { return manager_data; }
38         virtual int get_load_priority() const { return 0; }
39         virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) = 0;
40         virtual bool is_loaded() const;
41
42         /** Returns the amount of graphics memory used by this resource.  The
43         returned value must not change while the resource is loaded. */
44         virtual UInt64 get_data_size() const = 0;
45
46         virtual void unload() = 0;
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif