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 isReloadable(void) const 00154 { 00155 return !mIsManual || mLoader; 00156 } 00157 00160 bool isManuallyLoaded(void) const 00161 { 00162 return mIsManual; 00163 } 00164 00168 virtual void unload(void); 00169 00172 size_t getSize(void) const 00173 { 00174 return mSize; 00175 } 00176 00179 virtual void touch(void); 00180 00183 const String& getName(void) const 00184 { 00185 return mName; 00186 } 00187 00188 ResourceHandle getHandle(void) const 00189 { 00190 return mHandle; 00191 } 00192 00195 bool isLoaded(void) const 00196 { 00197 OGRE_LOCK_AUTO_MUTEX 00198 return mIsLoaded; 00199 } 00200 00202 const String& getGroup(void) { return mGroup; } 00203 00211 void changeGroupOwnership(const String& newGroup); 00212 00214 ResourceManager* getCreator(void) { return mCreator; } 00221 const String& getOrigin(void) const { return mOrigin; } 00223 void _notifyOrigin(const String& origin) { mOrigin = origin; } 00224 00225 }; 00226 00245 typedef SharedPtr<Resource> ResourcePtr; 00246 00268 class _OgreExport ManualResourceLoader 00269 { 00270 public: 00271 ManualResourceLoader() {} 00272 virtual ~ManualResourceLoader() {} 00273 00277 virtual void loadResource(Resource* resource) = 0; 00278 }; 00279 } 00280 00281 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:48 2006