source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreArchiveManager.h @ 1812

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