oasisresourcemanager.h
来自「使用stl技术,(还没看,是听说的)」· C头文件 代码 · 共 100 行
H
100 行
/******************************************************************************
* This source file is part of Bad Camel Gaming
* Copyright (C) 2003 Zephie Greyvenstein
* See Readme.html for acknowledgements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/******************************************************************************
* FILENAME : oasisResourceManager.h
* DESCRIPTION : The resource manager base class
* AUTHOR : Zephie Greyvenstein
*****************************************************************************/
/// Avoid double inclusion
#ifndef __RESOURCEMANAGER_H__
#define __RESOURCEMANAGER_H__
/// Include common stuff
#include "oasisCommon.h"
/// Forward declare ogre stuff
namespace Ogre {
class ArchiveEx;
class DataChunk;
class String;
};
namespace Oasis {
/// The resource manager base class for loading any type of resource
class _oasisExport resourceManager {
public:
/// Constructor
resourceManager( );
/// Destructor
virtual ~resourceManager( );
/// Set the memory limit/budget in bytes
virtual void setMemoryLimit( size bytes );
/// Create a new resource
virtual resource *createResource( const string &name ) = 0;
/// Load a resource
virtual void load( resource *res, uint8 priority );
/// Add a resource to the manager
virtual void add( resource *res );
/// Unload a resource from the system
virtual void unload( resource *res );
/// Unload and destroy all resources for this system
virtual void unloadAndDestroyAll( void );
protected:
/// Memory budget for this manager
size memoryBudget;
/// List of name indexed resources
typedef std::map< string, resource* > resourceMap;
/// Resources that this manager knows about. This should be a hash_map
resourceMap resources;
/// Get files of a specific name extension
void _getAllNamesLike( const string &dirStart,
const string &ex );
/// Get a file's data
bool _findResourceData( const string &fileName,
Ogre::DataChunk &chunk );
/// Checks the memory budget
void checkMemoryBudget( void ) {}
/// Get a resource by name
virtual resource *getByName( const string &name );
/// Parse all sources
virtual void _parseAllSources( const string &extension );
/// Parse a source file
virtual void _parseFile( const string &name );
/// Parse a source file
virtual void _parseFile( Ogre::DataChunk &chunk ) = 0;
/// Logs errors in parsing
static void _logError( const string &line, resource *file );
};
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?