2012-01-21 21:57:41 +01:00
|
|
|
#ifndef CACHEDLIST
|
|
|
|
#define CACHEDLIST
|
|
|
|
|
|
|
|
#include "list.hpp"
|
|
|
|
#include "cache.hpp"
|
|
|
|
#include "safe_vector.hpp"
|
|
|
|
#include "gecko.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
COVERFLOW_USB,
|
2012-04-08 17:54:34 +02:00
|
|
|
COVERFLOW_DML,
|
2012-01-21 21:57:41 +01:00
|
|
|
COVERFLOW_CHANNEL,
|
2012-04-08 17:54:34 +02:00
|
|
|
COVERFLOW_EMU,
|
2012-01-21 21:57:41 +01:00
|
|
|
COVERFLOW_HOMEBREW,
|
|
|
|
COVERFLOW_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T = dir_discHdr>
|
|
|
|
class CachedList : public safe_vector<T>
|
|
|
|
{
|
|
|
|
public:
|
2012-04-05 13:00:05 +02:00
|
|
|
void Init(string cachedir, string settingsDir, string curLanguage, string DMLgameDir, bool extcheck) /* Initialize Private Variables */
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
m_cacheDir = cachedir;
|
|
|
|
m_settingsDir = settingsDir;
|
2012-02-10 16:48:27 +01:00
|
|
|
m_curLanguage = m_lastLanguage = curLanguage;
|
2012-01-21 21:57:41 +01:00
|
|
|
m_loaded = false;
|
|
|
|
m_database = "";
|
|
|
|
m_update = false;
|
2012-04-05 13:00:05 +02:00
|
|
|
m_extcheck = extcheck;
|
2012-03-08 13:25:39 +01:00
|
|
|
m_DMLgameDir = DMLgameDir;
|
2012-01-21 21:57:41 +01:00
|
|
|
for(u32 i = 0; i < COVERFLOW_MAX; i++)
|
|
|
|
force_update[i] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Update(u32 view = COVERFLOW_MAX) /* Force db update on next load */
|
|
|
|
{
|
|
|
|
if(view == COVERFLOW_MAX)
|
|
|
|
for(u32 i = 0; i < COVERFLOW_MAX; i++)
|
2012-01-30 00:11:43 +01:00
|
|
|
{
|
2012-01-21 21:57:41 +01:00
|
|
|
force_update[i] = true;
|
2012-01-30 00:11:43 +01:00
|
|
|
gprintf("force_update[%d] = true\n", i);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
2012-01-30 00:11:43 +01:00
|
|
|
{
|
2012-01-21 21:57:41 +01:00
|
|
|
force_update[view] = true;
|
2012-01-30 00:11:43 +01:00
|
|
|
gprintf("force_update[%d] = true\n", view);
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2012-02-03 04:00:13 +01:00
|
|
|
void Load(string path, string containing, string m_lastLanguage);
|
|
|
|
void LoadChannels(string path, u32 channelType, string m_lastLanguage);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
void Unload(){if(m_loaded) {this->clear(); m_loaded = false; m_database = "";}};
|
|
|
|
void Save() {if(m_loaded) CCache<T>(*this, m_database, SAVE);} /* Save All */
|
|
|
|
|
|
|
|
void Get(T tmp, u32 index) {if(m_loaded) CCache<T>(tmp, m_database, index, LOAD);} /* Load One */
|
|
|
|
void Set(T tmp, u32 index) {if(m_loaded) CCache<T>(tmp, m_database, index, SAVE);} /* Save One */
|
|
|
|
|
|
|
|
void Add(T tmp) {if(m_loaded) CCache<T>(*this, m_database, tmp, ADD);} /* Add One */
|
|
|
|
void Remove(u32 index) {if(m_loaded) CCache<T>(*this, m_database, index, REMOVE);} /* Remove One */
|
|
|
|
|
2012-02-03 04:00:13 +01:00
|
|
|
void SetLanguage(string curLanguage) { m_curLanguage = curLanguage; }
|
2012-01-21 21:57:41 +01:00
|
|
|
private:
|
|
|
|
string make_db_name(string path);
|
|
|
|
|
|
|
|
bool m_loaded;
|
|
|
|
bool m_update;
|
|
|
|
bool m_wbfsFS;
|
2012-04-05 13:00:05 +02:00
|
|
|
bool m_extcheck;
|
2012-01-21 21:57:41 +01:00
|
|
|
u8 force_update[COVERFLOW_MAX];
|
|
|
|
CList<T> list;
|
|
|
|
string m_database;
|
|
|
|
string m_cacheDir;
|
|
|
|
string m_settingsDir;
|
|
|
|
string m_curLanguage;
|
2012-02-10 16:48:27 +01:00
|
|
|
string m_lastLanguage;
|
2012-02-02 02:46:01 +01:00
|
|
|
string m_discinf;
|
2012-03-08 13:25:39 +01:00
|
|
|
string m_DMLgameDir;
|
2012-01-21 21:57:41 +01:00
|
|
|
};
|
|
|
|
|
2012-01-30 00:11:43 +01:00
|
|
|
#endif
|