ResourceSystem.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
00004  *       mailto: <tevs@mpi-sb.mpg.de>                                      *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  ***************************************************************************/
00012 #ifndef _NR__RESOURCES_SYSTEM_H
00013 #define _NR__RESOURCES_SYSTEM_H
00014 
00015 /*!
00016  * \defgroup resource Resource managment
00017  *
00018  * <b>nrEngine</b> has support for resource managment. Each resource can be
00019  * loaded or unloaded at the runtime. There is a class for generic support
00020  * of resource managment system ResourceManager. This class provides generic
00021  * functions used for resource reservation/allocation/release. We also provides
00022  * a possibility to unload the resource at runtime but not to delete it from
00023  * the memory completly. So the application can still access to it and will
00024  * get only empty resource back.
00025  * 
00026  * Each resource class has to be derived from IResource and provide
00027  * their own functions for returning an empty resource. ResourcePtr is a
00028  * class representing smart pointer to any resource. This pointers can be
00029  * used as normal pointers and will give you transparent access to empty
00030  * item if this resource is not present in the memory.
00031  *
00032  * So with the help of
00033  * such subsystem you do not have to check each time you want to use the
00034  * data if it still exists in the memory. This happens transparent to you and
00035  * will stay efficient.
00036  *
00037  * <img src="../dias/Resources.png">
00038  **/
00039 
00040  
00041 
00042 //----------------------------------------------------------------------------------
00043 // Includes
00044 //----------------------------------------------------------------------------------
00045 #include "Prerequisities.h"
00046 #include "Priority.h"
00047 #include "Property.h"
00048 
00049 //----------------------------------------------------------------------------------
00050 // Types
00051 //----------------------------------------------------------------------------------
00052 namespace nrEngine{
00053                 
00054         //! Smart pointer pointing to a loader
00055         typedef SharedPtr<IResourceLoader> ResourceLoader;
00056         
00057         //! This handle will store something like resource id.
00058         typedef uint32                                  ResourceHandle;
00059 
00060         //! Cast a resource loader of basis type to any derived type
00061         template<class T>
00062         SharedPtr<T> ResourceLoaderCast (ResourceLoader loader)
00063         {
00064                 return boost::dynamic_pointer_cast<T, IResourceLoader>(loader);
00065         }
00066 };
00067 
00068 
00069 //----------------------------------------------------------------------------------
00070 // Includes for teh system
00071 //----------------------------------------------------------------------------------
00072 #include "ResourceManager.h"
00073 #include "Resource.h"
00074 #include "ResourceHolder.h"
00075 #include "ResourceLoader.h" 
00076 #include "ResourcePtr.h"
00077 
00078 
00079 #endif

Generated on Wed Sep 12 23:19:42 2007 for nrEngine by  doxygen 1.5.1