Debian Codegraph @

engine/core/util/resource/resource.i

raw
1 /***************************************************************************
2 * Copyright (C) 2005-2019 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21 %module fife
22
23 %{
24 #include "util/base/sharedptr.h"
25 #include "util/resource/resource.h"
26 #include "util/resource/resourcemanager.h"
27 %}
28
29 namespace FIFE {
30
31 // %warnfilter(473) ResourceLoader; // filter out "returning a pointer or reference in a director method is not recommended"
32 // %feature("director") ResourceLoader;
33 // class ResourceLoader {
34 // public:
35 // virtual ~ResourceLoader() { };
36 // virtual IResource* loadResource(const ResourceLocation& location) = 0;
37 // };
38
39 typedef std::size_t ResourceHandle;
40
41 class IResource;
42
43 class IResourceLoader {
44 public:
45 virtual ~IResourceLoader() { }
46
47 virtual void load(IResource* resource) = 0;
48 };
49
50 class IResource {
51 public:
52 enum ResourceState {
53 RES_NOT_LOADED,
54 RES_LOADED
55 };
56
57 virtual ~IResource();
58
59 virtual const std::string& getName();
60
61 ResourceHandle getHandle();
62
63 virtual ResourceState getState();
64 virtual void setState(const ResourceState& state);
65
66 virtual size_t getSize() = 0;
67
68 virtual void load() = 0;
69 virtual void free() = 0;
70 };
71
72 template <typename T>
73 class SharedPtr {
74 public:
75 SharedPtr();
76
77 template <typename U>
78 explicit SharedPtr(U *ptr);
79
80 SharedPtr(const SharedPtr& rhs);
81
82 template <typename U>
83 SharedPtr(const SharedPtr<U>& rhs);
84
85 ~SharedPtr();
86
87 inline T& operator*() const;
88 inline T* operator->() const;
89 inline T* get() const;
90 inline void reset(T* ptr = 0);
91 inline uint32_t useCount() const;
92 inline uint32_t* useCountPtr() const;
93 inline bool unique() const;
94 operator bool();
95 };
96
97 typedef SharedPtr<IResource> ResourcePtr;
98 %template(SharedResourcePointer) SharedPtr<IResource>;
99
100 class IResourceManager {
101 public:
102 virtual size_t getMemoryUsed() const = 0;
103 virtual size_t getTotalResourcesCreated() const = 0;
104 virtual size_t getTotalResourcesLoaded() const = 0;
105 virtual size_t getTotalResources() const = 0;
106 };
107 }