2010-12-04 16:14:34 +00:00
/********************************************************
* ContentManager . h *
* *
* XFX ContentManager definition file *
* Copyright <EFBFBD> XFX Team . All Rights Reserved *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef _XFX_CONTENT_CONTENTMANAGER_
# define _XFX_CONTENT_CONTENTMANAGER_
# include <System/Collections/Generic/List.h>
2012-09-28 20:36:02 +00:00
# include <System/Collections/Generic/Dictionary.h>
2010-12-04 16:14:34 +00:00
# include <System/IO/Stream.h>
# include <System/Interfaces.h>
# include <System/String.h>
using namespace System ;
using namespace System : : Collections : : Generic ;
using namespace System : : IO ;
namespace XFX
{
namespace Content
{
2012-03-29 22:02:43 +00:00
// The ContentManager is the run-time component which loads managed objects from the binary files produced by the design time content pipeline. It also manages the lifespan of the loaded objects, disposing the content manager will also dispose any assets which are themselves System.IDisposable.
2012-09-28 20:36:02 +00:00
class ContentManager : public IDisposable , public Object
2010-12-04 16:14:34 +00:00
{
private :
List < IDisposable * > disposableAssets ;
2012-09-28 20:36:02 +00:00
Dictionary < String , Object * > loadedAssets ;
2010-12-04 16:14:34 +00:00
bool disposed ;
2010-12-27 01:01:25 +00:00
IServiceProvider * _provider ;
2010-12-04 16:14:34 +00:00
protected :
virtual void Dispose ( bool disposing ) ;
2012-09-28 20:36:02 +00:00
virtual Stream * OpenStream ( const String & assetName ) ;
2010-12-04 16:14:34 +00:00
template < class T >
2012-09-28 20:36:02 +00:00
T ReadAsset ( const String & assetName ) ; //! usage: T ReadAsset<T>(assetName); where T is the preferred type, i.e. Texture2D*
2010-12-04 16:14:34 +00:00
public :
2012-09-28 20:36:02 +00:00
String RootDirectory ;
2010-12-04 16:14:34 +00:00
2010-12-27 01:01:25 +00:00
ContentManager ( IServiceProvider * provider ) ;
2012-09-28 20:36:02 +00:00
ContentManager ( IServiceProvider * provider , const String & rootDirectory ) ;
2010-12-04 16:14:34 +00:00
virtual ~ ContentManager ( ) ;
void Dispose ( ) ;
2012-09-28 20:36:02 +00:00
int GetType ( ) const ;
2010-12-04 16:14:34 +00:00
template < class T >
2012-09-28 20:36:02 +00:00
T Load ( const String & assetName ) ; //! usage: T Load<T>(assetName); where T is the preferred type, i.e. Texture2D*
2010-12-04 16:14:34 +00:00
virtual void Unload ( ) ;
} ;
}
}
# endif //_XFX_CONTENT_CONTENTMANAGER_