Make GetApplicableFiles() static and don't create a loader unless it can load from that directory.

This commit is contained in:
Steve Checkoway
2006-11-01 10:09:13 +00:00
parent a9e04a845a
commit 5f851a47ca
6 changed files with 11 additions and 33 deletions
+7 -26
View File
@@ -9,13 +9,6 @@
#include "NotesLoaderBMS.h"
#include "NotesLoaderKSF.h"
bool NotesLoader::Loadable( const RString &sPath )
{
vector<RString> list;
GetApplicableFiles( sPath, list );
return !list.empty();
}
void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut )
{
const RString sLeftSeps[] = { "\t", " -", " ~", " (", " [" };
@@ -35,26 +28,14 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, R
NotesLoader *NotesLoader::MakeLoader( const RString &sDir )
{
NotesLoader *ret;
vector<RString> list;
/* Actually, none of these have any persistant data, so we
* could optimize this, but since they don't have any data,
* there's no real point ... */
ret = new SMLoader;
if(ret->Loadable( sDir )) return ret;
delete ret;
ret = new DWILoader;
if(ret->Loadable( sDir )) return ret;
delete ret;
ret = new BMSLoader;
if(ret->Loadable( sDir )) return ret;
delete ret;
ret = new KSFLoader;
if(ret->Loadable( sDir )) return ret;
delete ret;
#define CHECK_LOADER(x) x::GetApplicableFiles( sDir, list ); if( list.size() ) return new x
CHECK_LOADER( SMLoader );
CHECK_LOADER( DWILoader );
CHECK_LOADER( BMSLoader );
CHECK_LOADER( KSFLoader );
#undef CHECK_LOADER
return NULL;
}
-3
View File
@@ -10,8 +10,6 @@ class Song;
class NotesLoader
{
protected:
virtual void GetApplicableFiles( const RString &sPath, vector<RString> &out )=0;
set<RString> BlacklistedImages;
public:
@@ -20,7 +18,6 @@ public:
static void GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut );
virtual bool LoadFromDir( const RString &sPath, Song &out ) = 0;
virtual void TidyUpData( Song &song, bool cache ) { }
bool Loadable( const RString &sPath );
static NotesLoader *MakeLoader( const RString& sDir );
};
+1 -1
View File
@@ -32,7 +32,7 @@ class BMSLoader: public NotesLoader
map<RString,int> m_mapWavIdToKeysoundIndex;
public:
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
bool LoadFromDir( const RString &sDir, Song &out );
};
+1 -1
View File
@@ -26,7 +26,7 @@ class DWILoader: public NotesLoader
RString m_sLoadingFile;
public:
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
bool LoadFromDir( const RString &sPath, Song &out );
};
+1 -1
View File
@@ -17,7 +17,7 @@ class KSFLoader: public NotesLoader
void LoadTags( const RString &str, Song &out );
public:
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
bool LoadFromDir( const RString &sDir, Song &out );
private:
+1 -1
View File
@@ -33,7 +33,7 @@ public:
return LoadFromSMFile( sPath, out );
}
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
bool LoadFromDir( const RString &sPath, Song &out );
void TidyUpData( Song &song, bool cache );
static bool LoadTimingFromFile( const RString &fn, TimingData &out );