This commit is contained in:
hyzboy 2020-01-13 11:55:03 +08:00
parent 641256a8db
commit b622b98f79
3 changed files with 18 additions and 23 deletions

View File

@ -50,8 +50,6 @@ namespace hgl
*/ */
class AssetsSource class AssetsSource
{ {
protected:
UTF8String uri_short_name; UTF8String uri_short_name;
public: public:
@ -74,12 +72,9 @@ namespace hgl
virtual AssetsSource * CreateSubSource (const UTF8String &){return nullptr;} virtual AssetsSource * CreateSubSource (const UTF8String &){return nullptr;}
};//class AssetsSource };//class AssetsSource
AssetsSource *CreateByFilesystem(const UTF8String &sn,const OSString &pathname,const bool only_read); AssetsSource *CreateSourceByFilesystem(const UTF8String &sn,const OSString &pathname,const bool only_read);
bool RegistryAssetsSource(const UTF8String &uri_short_name,AssetsSource *); AssetsSource *GetSource(const UTF8String &uri_short_name);
void UnregistryAssetsSource(const UTF8String &uri_short_name);
AssetsSource *GetAssetsSource(const UTF8String &uri_short_name);
io::InputStream *GetAssets(const UTF8String &uri); io::InputStream *GetAssets(const UTF8String &uri);
}//namespace assets }//namespace assets

View File

@ -10,17 +10,6 @@ namespace hgl
Map<UTF8String,AssetsSource *> assets_source_map; Map<UTF8String,AssetsSource *> assets_source_map;
}//namespace }//namespace
AssetsSource::AssetsSource(const UTF8String &sn)
{
uri_short_name=sn;
RegistryAssetsSource(sn,this);
}
AssetsSource::~AssetsSource()
{
UnregistryAssetsSource(uri_short_name);
}
bool RegistryAssetsSource(const UTF8String &uri_short_name,AssetsSource *as) bool RegistryAssetsSource(const UTF8String &uri_short_name,AssetsSource *as)
{ {
if(!as) if(!as)
@ -44,7 +33,7 @@ namespace hgl
assets_source_map.DeleteByKey(uri_short_name); assets_source_map.DeleteByKey(uri_short_name);
} }
AssetsSource *GetAssetsSource(const UTF8String &uri_short_name) AssetsSource *GetSource(const UTF8String &uri_short_name)
{ {
if(uri_short_name.IsEmpty()) if(uri_short_name.IsEmpty())
return(nullptr); return(nullptr);
@ -68,7 +57,7 @@ namespace hgl
const UTF8String sn=uri.SubString(0,pos); const UTF8String sn=uri.SubString(0,pos);
AssetsSource *source=GetAssetsSource(sn); AssetsSource *source=GetSource(uri);
if(!source) if(!source)
return(nullptr); return(nullptr);
@ -77,5 +66,16 @@ namespace hgl
return source->OpenByName(surl); return source->OpenByName(surl);
} }
AssetsSource::AssetsSource(const UTF8String &sn)
{
uri_short_name=sn;
RegistryAssetsSource(sn,this);
}
AssetsSource::~AssetsSource()
{
UnregistryAssetsSource(uri_short_name);
}
}//namespace assets }//namespace assets
}//namespace hgl }//namespace hgl

View File

@ -39,7 +39,7 @@ namespace hgl
} }
};//class AssetsSourceFilesytem:public AssetsSource };//class AssetsSourceFilesytem:public AssetsSource
AssetsSource *CreateByFilesystem(const OSString &path,const bool only_read) AssetsSource *CreateSourceByFilesystem(const OSString &path,const bool only_read)
{ {
if(path.IsEmpty()) if(path.IsEmpty())
return(nullptr); return(nullptr);