00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2005 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 _Resource_H__ 00026 #define _Resource_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 #include "OgreString.h" 00030 #include "OgreSharedPtr.h" 00031 #include "OgreStringInterface.h" 00032 00033 namespace Ogre { 00034 00035 typedef unsigned long ResourceHandle; 00036 00037 00038 // Forward declaration 00039 class ManualResourceLoader; 00040 00067 class _OgreExport Resource : public StringInterface 00068 { 00069 public: 00070 OGRE_AUTO_MUTEX // public to allow external locking 00071 protected: 00073 ResourceManager* mCreator; 00075 String mName; 00077 String mGroup; 00079 ResourceHandle mHandle; 00081 bool mIsLoaded; 00083 size_t mSize; 00085 bool mIsManual; 00087 String mOrigin; 00089 ManualResourceLoader* mLoader; 00090 00093 Resource() 00094 : mCreator(0), mHandle(0), mIsLoaded(false), mSize(0), mIsManual(0), mLoader(0) 00095 { 00096 } 00097 00101 virtual void loadImpl(void) = 0; 00105 virtual void unloadImpl(void) = 0; 00107 virtual size_t calculateSize(void) const = 0; 00108 00109 public: 00124 Resource(ResourceManager* creator, const String& name, ResourceHandle handle, 00125 const String& group, bool isManual = false, ManualResourceLoader* loader = 0); 00126 00132 virtual ~Resource(); 00133 00142 virtual void load(void); 00143 00149 virtual void reload(void); 00150 00153 bool isManuallyLoaded(void) const 00154 { 00155 return mIsManual; 00156 } 00157 00161 virtual void unload(void); 00162 00165 size_t getSize(void) const 00166 { 00167 return mSize; 00168 } 00169 00172 virtual void touch(void); 00173 00176 const String& getName(void) const 00177 { 00178 return mName; 00179 } 00180 00181 ResourceHandle getHandle(void) const 00182 { 00183 return mHandle; 00184 } 00185 00188 bool isLoaded(void) const 00189 { 00190 OGRE_LOCK_AUTO_MUTEX 00191 return mIsLoaded; 00192 } 00193 00195 const String& getGroup(void) { return mGroup; } 00196 00198 ResourceManager* getCreator(void) { return mCreator; } 00205 const String& getOrigin(void) const { return mOrigin; } 00207 void _notifyOrigin(const String& origin) { mOrigin = origin; } 00208 00209 }; 00210 00229 typedef SharedPtr<Resource> ResourcePtr; 00230 00252 class _OgreExport ManualResourceLoader 00253 { 00254 public: 00255 ManualResourceLoader() {} 00256 virtual ~ManualResourceLoader() {} 00257 00261 virtual void loadResource(Resource* resource) = 0; 00262 }; 00263 } 00264 00265 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:21 2005