]> git.tdb.fi Git - libs/gl.git/blob - source/resources/resource.cpp
Simplify Program by removing transient data
[libs/gl.git] / source / resources / resource.cpp
1 #include "resource.h"
2 #include "resourcemanager.h"
3
4 namespace Msp {
5 namespace GL {
6
7 Resource::~Resource()
8 {
9         if(manager)
10                 manager->remove_resource(*this);
11 }
12
13 Resource::Resource(Resource &&other):
14         manager(other.manager),
15         manager_data(other.manager_data)
16 {
17         if(manager)
18         {
19                 manager->move_resource(other, *this);
20                 manager_data = manager->get_data_for_resource(*this);
21         }
22         other.manager = 0;
23         other.manager_data = 0;
24 }
25
26 void Resource::set_manager(ResourceManager *m)
27 {
28         if(manager)
29                 manager->remove_resource(*this);
30         manager = m;
31         if(manager)
32         {
33                 manager->add_resource(*this);
34                 manager_data = manager->get_data_for_resource(*this);
35         }
36         else
37                 manager_data = 0;
38 }
39
40 bool Resource::is_loaded() const
41 {
42         return manager ? manager->is_resource_loaded(*this) : true;
43 }
44
45 } // namespace GL
46 } // namespace Msp