1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef _ArchiveManager_H__ |
---|
30 | #define _ArchiveManager_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | |
---|
34 | #include "OgreResourceManager.h" |
---|
35 | #include "OgreSingleton.h" |
---|
36 | |
---|
37 | namespace Ogre { |
---|
38 | |
---|
39 | /** This class manages the available ArchiveFactory plugins. |
---|
40 | */ |
---|
41 | class _OgreExport ArchiveManager : public Singleton<ArchiveManager> |
---|
42 | { |
---|
43 | protected: |
---|
44 | typedef std::map<String, ArchiveFactory*> ArchiveFactoryMap; |
---|
45 | /// Factories available to create archives, indexed by archive type (String identifier e.g. 'Zip') |
---|
46 | ArchiveFactoryMap mArchFactories; |
---|
47 | /// Currently loaded archives |
---|
48 | typedef std::map<String, Archive*> ArchiveMap; |
---|
49 | ArchiveMap mArchives; |
---|
50 | |
---|
51 | public: |
---|
52 | /** Default constructor - should never get called by a client app. |
---|
53 | */ |
---|
54 | ArchiveManager() {} |
---|
55 | /** Default destructor. |
---|
56 | */ |
---|
57 | virtual ~ArchiveManager(); |
---|
58 | |
---|
59 | /** Opens an archive for file reading. |
---|
60 | @remarks |
---|
61 | The archives are created using class factories within |
---|
62 | extension libraries. |
---|
63 | @param filename |
---|
64 | The filename that will be opened |
---|
65 | @param refLibrary |
---|
66 | The library that contains the data-handling code |
---|
67 | @returns |
---|
68 | If the function succeeds, a valid pointer to an Archive |
---|
69 | object is returened. |
---|
70 | @par |
---|
71 | If the function fails, an exception is thrown. |
---|
72 | */ |
---|
73 | Archive* load( const String& filename, const String& archiveType); |
---|
74 | |
---|
75 | /** Unloads an archive. |
---|
76 | @remarks |
---|
77 | You must ensure that this archive is not being used before removing it. |
---|
78 | */ |
---|
79 | void unload(Archive* arch); |
---|
80 | /** Unloads an archive by name. |
---|
81 | @remarks |
---|
82 | You must ensure that this archive is not being used before removing it. |
---|
83 | */ |
---|
84 | void unload(const String& filename); |
---|
85 | |
---|
86 | |
---|
87 | /** Adds a new ArchiveFactory to the list of available factories. |
---|
88 | @remarks |
---|
89 | Plugin developers who add new archive codecs need to call |
---|
90 | this after defining their ArchiveFactory subclass and |
---|
91 | Archive subclasses for their archive type. |
---|
92 | */ |
---|
93 | void addArchiveFactory(ArchiveFactory* factory); |
---|
94 | /** Override standard Singleton retrieval. |
---|
95 | @remarks |
---|
96 | Why do we do this? Well, it's because the Singleton |
---|
97 | implementation is in a .h file, which means it gets compiled |
---|
98 | into anybody who includes it. This is needed for the |
---|
99 | Singleton template to work, but we actually only want it |
---|
100 | compiled into the implementation of the class based on the |
---|
101 | Singleton, not all of them. If we don't change this, we get |
---|
102 | link errors when trying to use the Singleton-based class from |
---|
103 | an outside dll. |
---|
104 | @par |
---|
105 | This method just delegates to the template version anyway, |
---|
106 | but the implementation stays in this single compilation unit, |
---|
107 | preventing link errors. |
---|
108 | */ |
---|
109 | static ArchiveManager& getSingleton(void); |
---|
110 | /** Override standard Singleton retrieval. |
---|
111 | @remarks |
---|
112 | Why do we do this? Well, it's because the Singleton |
---|
113 | implementation is in a .h file, which means it gets compiled |
---|
114 | into anybody who includes it. This is needed for the |
---|
115 | Singleton template to work, but we actually only want it |
---|
116 | compiled into the implementation of the class based on the |
---|
117 | Singleton, not all of them. If we don't change this, we get |
---|
118 | link errors when trying to use the Singleton-based class from |
---|
119 | an outside dll. |
---|
120 | @par |
---|
121 | This method just delegates to the template version anyway, |
---|
122 | but the implementation stays in this single compilation unit, |
---|
123 | preventing link errors. |
---|
124 | */ |
---|
125 | static ArchiveManager* getSingletonPtr(void); |
---|
126 | }; |
---|
127 | |
---|
128 | } |
---|
129 | |
---|
130 | #endif |
---|