comparison engine/core/util/resource/resource.i @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children 485f4c6dd9fc
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21 %module fife
22
23 %{
24 #include "util/resource/resource.h"
25 #include "util/resource/resource_location.h"
26 #include "util/resource/pool.h"
27 %}
28
29 namespace FIFE {
30
31 class ResourceLocation {
32 public:
33 ResourceLocation(const std::string& filename);
34 virtual ~ResourceLocation() {};
35 const std::string& getFilename() const;
36 virtual bool operator ==(const ResourceLocation& loc) const;
37 virtual bool operator <(const ResourceLocation& loc) const;
38 virtual ResourceLocation* clone() const;
39
40 private:
41 ResourceLocation(const std::string& filename);
42 };
43
44
45 class IReferenceCounted {
46 virtual ~IReferenceCounted();
47 virtual void addRef() = 0;
48 virtual void decRef() = 0;
49 virtual unsigned int getRefCount() = 0;
50 };
51
52 class IResource: public IReferenceCounted {
53 public:
54 virtual ~IResource() {};
55 virtual const ResourceLocation& getResourceLocation() = 0;
56 virtual const std::string& getResourceFile() = 0;
57 virtual void setResourceLocation(const ResourceLocation& location) = 0;
58 virtual void setResourceFile(const std::string& filename) = 0;
59 virtual int getPoolId() = 0;
60 virtual void setPoolId(int poolid) = 0;
61 };
62
63 %warnfilter(473) ResourceLoader; // filter out "returning a pointer or reference in a director method is not recommended"
64 %feature("director") ResourceLoader;
65 class ResourceLoader {
66 public:
67 virtual ~ResourceLoader() { };
68 virtual IResource* loadResource(const ResourceLocation& location) = 0;
69 };
70
71 class ResourceSaver {
72 public:
73 virtual ~ResourceSaver() { };
74 virtual void save(const ResourceLocation& location, IResource* resource) = 0;
75 virtual void save(const std::string& filename, IResource* resource) { save(ResourceLocation(filename), resource); }
76 };
77
78
79 enum { RES_LOADED = 0x01, RES_NON_LOADED = 0x02};
80
81 class Pool {
82 public:
83 static const int INVALID_ID = -1;
84 virtual ~Pool();
85 virtual int addResourceFromFile(const std::string& filename);
86 virtual int getResourceCount(int status);
87 virtual void addResourceLoader(ResourceLoader* loader);
88 private:
89 Pool();
90 };
91 }