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