319 lines
9.5 KiB
C
319 lines
9.5 KiB
C
|
/****************************************************************************
|
|||
|
Copyright (c) 2011-2013,WebJet Business Division,CYOU
|
|||
|
|
|||
|
http://www.genesis-3d.com.cn
|
|||
|
|
|||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
of this software and associated documentation files (the "Software"), to deal
|
|||
|
in the Software without restriction, including without limitation the rights
|
|||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
copies of the Software, and to permit persons to whom the Software is
|
|||
|
furnished to do so, subject to the following conditions:
|
|||
|
|
|||
|
The above copyright notice and this permission notice shall be included in
|
|||
|
all copies or substantial portions of the Software.
|
|||
|
|
|||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
|
THE SOFTWARE.
|
|||
|
****************************************************************************/
|
|||
|
/** \file resourceserver.h
|
|||
|
* \brief
|
|||
|
|
|||
|
1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դֻ<EFBFBD><EFBF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FBFBD><EFBFBD>
|
|||
|
Step2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>֪ͨIO<EFBFBD>̣߳<EFBFBD><EFBFBD>ȴ<EFBFBD>IO<EFBFBD>߳̽<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>豸
|
|||
|
*/
|
|||
|
#ifndef __resourceserver_H__
|
|||
|
#define __resourceserver_H__
|
|||
|
#include "core/refcounted.h"
|
|||
|
#include "resource/resource.h"
|
|||
|
#include "core/singleton.h"
|
|||
|
#include "util/delegate.h"
|
|||
|
#include "util/queue.h"
|
|||
|
#include "util/list.h"
|
|||
|
#include "resource/resourceinterface.h"
|
|||
|
|
|||
|
#include "io/iointerfaceprotocol.h"
|
|||
|
#include "timing/timer.h"
|
|||
|
|
|||
|
namespace Resources
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
struct LoadedArg
|
|||
|
{
|
|||
|
LoadedArg(): processOK(false) { };
|
|||
|
bool processOK; // <09>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>سɹ<D8B3>
|
|||
|
GPtr<Resource> res; // <09><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Դ
|
|||
|
};
|
|||
|
|
|||
|
// ij<><C4B3><EFBFBD><EFBFBD>Դ<EFBFBD>ڶ<EFBFBD>дʱ<D0B4><CAB1>ʹ<EFBFBD>õı<C3B5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
class ResCodecReg: public Core::RefCounted
|
|||
|
{
|
|||
|
__DeclareClass(ResCodecReg);
|
|||
|
public:
|
|||
|
virtual void Open(void) { }
|
|||
|
virtual void Close(void) { }
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
class ResourceServer: public Core::RefCounted
|
|||
|
{
|
|||
|
__DeclareClass(ResourceServer);
|
|||
|
__DeclareImageSingleton(ResourceServer);
|
|||
|
public:
|
|||
|
ResourceServer();
|
|||
|
virtual ~ResourceServer();
|
|||
|
|
|||
|
/**
|
|||
|
* Open <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ResourceServer
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
void Open(void);
|
|||
|
|
|||
|
/**
|
|||
|
* IsOpen <EFBFBD>Ƿ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
* @return: bool
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
bool IsOpen(void) const;
|
|||
|
|
|||
|
/**
|
|||
|
* Close <EFBFBD>رսӿڣ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
void Close(void);
|
|||
|
|
|||
|
/**
|
|||
|
* RegisterResourceType ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>Ķ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Open֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const Core::Rtti * resType <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Rtti<EFBFBD><EFBFBD>Ϣ
|
|||
|
* @param: const Util::FourCC & typeFilter <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>filter<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ִӶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ʽ<EFBFBD>ж<EFBFBD>ȡ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ϵͳĬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>filter<EFBFBD><EFBFBD>'CYWJ'
|
|||
|
* @param: const Core::Rtti * loaderType <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>filter <EFBFBD><EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD>ȡ<EFBFBD><EFBFBD>
|
|||
|
* @param: const Core::Rtti * saverType <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>filter <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: GPtr<ResCodecReg>& codecReg Loader<EFBFBD><EFBFBD>Saver<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ResourceServer Open<EFBFBD><EFBFBD>Closeʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
void RegisterResourceType( const Core::Rtti* resType,
|
|||
|
const Util::FourCC& typeFilter,
|
|||
|
const Core::Rtti* loaderType,
|
|||
|
const Core::Rtti* saverType,
|
|||
|
const GPtr<ResCodecReg>& codecReg = GPtr<ResCodecReg>() );
|
|||
|
|
|||
|
/**
|
|||
|
* RegisterDefaultResouceTypes ע<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>filter<EFBFBD>Ͷ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Open֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark: Ĭ<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>MeshRes<EFBFBD><EFBFBD>ImageRes<EFBFBD><EFBFBD>SkeletonRes<EFBFBD><EFBFBD>AnimationRes
|
|||
|
*/
|
|||
|
void RegisterDefaultResouceTypes();
|
|||
|
|
|||
|
/**
|
|||
|
* CreateOrGetResource <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ߵõ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>
|
|||
|
* @param: const ResourceId & resID <EFBFBD><EFBFBD>ԴID
|
|||
|
* @param: const Core::Rtti * ResType <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: GPtr<Resource> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դָ<EFBFBD><EFBFBD>. <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD>ָ<EFBFBD>룬
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
GPtr<Resource> CreateOrGetResource( const ResourceId& resID, const Core::Rtti* ResType );
|
|||
|
|
|||
|
/**
|
|||
|
* HasResource <EFBFBD>ж<EFBFBD>resIDָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const ResourceId & resID
|
|||
|
* @return: bool
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
bool HasResource(const ResourceId& resID);
|
|||
|
|
|||
|
/**
|
|||
|
* GetResource <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԴID<EFBFBD><EFBFBD>ȡһ<EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
* @param: const ResourceId & resID
|
|||
|
* @return: GPtr<Resource> <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD>ָ<EFBFBD><EFBFBD>
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
GPtr<Resource> GetResource( const ResourceId& resID );
|
|||
|
|
|||
|
/**
|
|||
|
* LoadResource ͬ<EFBFBD><EFBFBD>/<EFBFBD>첽 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const GPtr<Resource> & res Ҫ<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>Դָ<EFBFBD><EFBFBD>
|
|||
|
* @param: bool bAsyn <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param: const Util::FourCC & typeFilter <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>filter<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'CYWJ'
|
|||
|
* @param: const Core::Rtti * manuLoaderType <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>
|
|||
|
1<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>typeFilterע<EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ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D><EFBFBD><EFBFBD>ж<EFBFBD>ء<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD>ټ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
bool LoadResource( const GPtr<Resource>& res,
|
|||
|
bool bAsyn = true,
|
|||
|
const Util::FourCC& typeFilter = 'CYWJ',
|
|||
|
const Core::Rtti* manuLoaderType = NULL );
|
|||
|
|
|||
|
/**
|
|||
|
* SaveResource ͬ<EFBFBD><EFBFBD><EFBFBD>洢һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
* @param: const GPtr<Resource> & res Ҫ<EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դָ<EFBFBD><EFBFBD>
|
|||
|
* @param: const IO::URI & uri <EFBFBD><EFBFBD>Դ<EFBFBD>Ĵ洢·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>res<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><EFBFBD><EFBFBD>Դ·<EFBFBD><EFBFBD>
|
|||
|
* @param: const Util::FourCC & typeFilter <EFBFBD>洢<EFBFBD><EFBFBD>filter<EFBFBD><EFBFBD>Ĭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'CYWJ'
|
|||
|
* @param: const Core::Rtti * manuSaverType <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Դд<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
1<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>typeFilterע<EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢ʧ<EFBFBD><EFBFBD>
|
|||
|
2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @return: bool <EFBFBD><EFBFBD><EFBFBD>ش洢<EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* @see:
|
|||
|
* @remark:
|
|||
|
*/
|
|||
|
bool SaveResource( const GPtr<Resource>& res,
|
|||
|
const IO::URI& uri = IO::URI(),
|
|||
|
const Util::FourCC& typeFilter = 'CYWJ',
|
|||
|
const Core::Rtti* manuSaverType = NULL );
|
|||
|
/**
|
|||
|
* Flush ˢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼߳<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̡߳<EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᷢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD>صĻص<EFBFBD>֪ͨ
|
|||
|
* @param: void
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark: <EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ÿ֡<EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
|
|||
|
*/
|
|||
|
void Flush(void);
|
|||
|
|
|||
|
|
|||
|
/**
|
|||
|
* UnLoadUnreferencedResources
|
|||
|
* @param: void
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark: this method is not fast
|
|||
|
*/
|
|||
|
void UnLoadUnreferencedResources(void);
|
|||
|
|
|||
|
/**
|
|||
|
* DicardUnreferencedResources ɾ<EFBFBD><EFBFBD>δʹ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
* @param: void
|
|||
|
* @return: void
|
|||
|
* @see:
|
|||
|
* @remark: this method is slow
|
|||
|
*/
|
|||
|
void DicardUnreferencedResources(void);
|
|||
|
|
|||
|
protected:
|
|||
|
IO::URI _ConstructURI( const IO::URI& defaultUri,
|
|||
|
const ResourceId& resID );
|
|||
|
|
|||
|
const Core::Rtti* _ConstructLoaderOrSaverType( const Core::Rtti* defaultType,
|
|||
|
const Core::Rtti* resType,
|
|||
|
const Util::FourCC& typeFilter,
|
|||
|
bool bloader );
|
|||
|
|
|||
|
// ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
bool _SynLoad(const GPtr<Resource>& res, const ResourceId& uri, const GPtr<ResourceLoader>& resLoader);
|
|||
|
|
|||
|
// <09>첽<EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
bool _AsynPrepare(const GPtr<Resource>& res, const ResourceId& uri, const GPtr<ResourceLoader>& resLoader);
|
|||
|
|
|||
|
void _FlushReadList(const Timing::Timer& t ,Timing::Tick max_tick);
|
|||
|
void _FlushPrepareList(const Timing::Timer& t, Timing::Tick max_tick);
|
|||
|
|
|||
|
protected:
|
|||
|
// <20><>Դ<EFBFBD>Ķ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2> <20><><EFBFBD>ݽṹ
|
|||
|
struct LoadSaveRegistry
|
|||
|
{
|
|||
|
const Core::Rtti* Loader;
|
|||
|
const Core::Rtti* Saver;
|
|||
|
GPtr<ResCodecReg> codecReg;
|
|||
|
};
|
|||
|
typedef Util::Dictionary<Util::FourCC, LoadSaveRegistry> ResFilterRegistry;
|
|||
|
typedef Util::Dictionary<const Core::Rtti*, ResFilterRegistry> ResRegistry;
|
|||
|
typedef Util::Dictionary< ResourceId, GPtr<Resource> > ResMap;
|
|||
|
|
|||
|
bool mIsOpen;
|
|||
|
ResRegistry mResReg; // ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>д<EFBFBD><D0B4>
|
|||
|
ResMap mResources; // <09><>Դ<EFBFBD>б<EFBFBD>
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>첽<EFBFBD><ECB2BD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ݽṹ<DDBD>ͱ<EFBFBD><CDB1><EFBFBD>
|
|||
|
|
|||
|
struct PrepareStub // IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ش<EFBFBD><D8B4><EFBFBD>
|
|||
|
{
|
|||
|
GPtr<Resource> res; // <09><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Դ
|
|||
|
GPtr<ResourceLoader> loader;
|
|||
|
GPtr<IO::ReadStream> msg_stream; // <09><>IO<49>߳<EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>Ϣ
|
|||
|
};
|
|||
|
|
|||
|
struct ReadStub // <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ش<EFBFBD><D8B4><EFBFBD>
|
|||
|
{
|
|||
|
GPtr<Resource> res; // <09><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Դ
|
|||
|
GPtr<ResMsg> msg_loader; // <09><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>߳<EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>Ϣ
|
|||
|
};
|
|||
|
|
|||
|
typedef Util::List<PrepareStub> PrepareStubbList;
|
|||
|
typedef Util::List<ReadStub> ReadStubList;
|
|||
|
|
|||
|
GPtr<ResourceInterface> mThreadInterface;// <09><><EFBFBD>л<EFBFBD><D0BB>̡߳<DFB3><CCA1><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>Դ
|
|||
|
PrepareStubbList mAsynPrepareQueue; // <09><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>IO<49>߳<EFBFBD><DFB3>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ⲿ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD>Դ
|
|||
|
ReadStubList mAsynReadQueue; // <09><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>߳<EFBFBD><DFB3>У<EFBFBD><D0A3><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
};
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
bool
|
|||
|
ResourceServer::IsOpen() const
|
|||
|
{
|
|||
|
return mIsOpen;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
bool
|
|||
|
ResourceServer::HasResource(const ResourceId& resID)
|
|||
|
{
|
|||
|
return mResources.FindIndex( resID ) != InvalidIndex;
|
|||
|
}
|
|||
|
//------------------------------------------------------------------------
|
|||
|
inline
|
|||
|
GPtr<Resource>
|
|||
|
ResourceServer::GetResource( const ResourceId& resID )
|
|||
|
{
|
|||
|
IndexT findIndex = mResources.FindIndex( resID );
|
|||
|
if ( InvalidIndex != findIndex )
|
|||
|
{
|
|||
|
return mResources.ValueAtIndex(findIndex);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return GPtr<Resource>(0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif // __resourceserver_H__
|