Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreResourceManager.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef _ResourceManager_H__
00026 #define _ResourceManager_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 
00030 #include "OgreResource.h"
00031 #include "OgreResourceMap.h"
00032 #include "OgreDataChunk.h"
00033 #include "OgreArchiveEx.h"
00034 
00035 
00036 namespace Ogre {
00037 
00052     class _OgreExport ResourceManager
00053     {
00054     public:
00055         ResourceManager();
00056         virtual ~ResourceManager();
00057 
00065         virtual void setMemoryBudget( size_t bytes);
00066 
00075         virtual Resource* create( const String& name ) = 0;
00076 
00079         virtual void load( Resource *res, int priority );
00080 
00090         virtual void unload( Resource *res );
00091 
00097         virtual void unloadAndDestroyAll(void);
00098 
00101         virtual Resource* getByName(const String& name);
00102 
00109         void addSearchPath( const String& path );
00110 
00118         static void addCommonSearchPath( const String& path );
00119 
00128         void addArchiveEx( const String& strName, const String& strDriverName );
00129 
00135         static void addCommonArchiveEx( const String& strName, const String& strDriverName );
00136 
00147         bool _findResourceData( const String& filename, DataChunk& refChunk );
00148 
00159         static std::set<String> _getAllCommonNamesLike( const String& startPath, const String& extension );
00160 
00174         static bool _findCommonResourceData( const String& filename, DataChunk& refChunk );
00175 
00176     protected:
00177 
00178         typedef HashMap< String, ArchiveEx *, _StringHash > FileMap;
00179         static FileMap mCommonArchiveFiles;
00180         FileMap mArchiveFiles;
00181 
00182         ResourceMap mResources;
00183 
00184         size_t mMemoryBudget; // In bytes
00185         size_t mMemoryUsage; // In bytes, at last checkUsage() call
00186 
00189         void checkUsage(void);
00190 
00192         static std::vector<ArchiveEx*> mCommonVFS;
00193 
00195         std::vector<ArchiveEx*> mVFS;
00196     };
00197 
00198 }
00199 
00200 #endif

Copyright © 2002 by The OGRE Team