WiiFlow_Lite/source/list/cachedlist.hpp

86 lines
2.3 KiB
C++
Raw Normal View History

2012-01-21 21:57:41 +01:00
#ifndef CACHEDLIST
#define CACHEDLIST
#include "list.hpp"
#include "cache.hpp"
#include "config/config.hpp"
#include "gecko/gecko.h"
2012-01-21 21:57:41 +01:00
using namespace std;
enum {
COVERFLOW_USB,
COVERFLOW_DML,
2012-01-21 21:57:41 +01:00
COVERFLOW_CHANNEL,
COVERFLOW_EMU,
2012-01-21 21:57:41 +01:00
COVERFLOW_HOMEBREW,
COVERFLOW_MAX
};
2012-08-16 16:09:02 +02:00
class CachedList : public vector<dir_discHdr>
2012-01-21 21:57:41 +01:00
{
public:
void Init(string cachedir, string settingsDir, string curLanguage, string DMLgameDir, bool extcheck, bool skipcheck) /* 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;
m_extcheck = extcheck;
m_skipcheck = skipcheck;
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-21 21:57:41 +01:00
force_update[i] = true;
gprintf("force_update[%d] = true\n", i);
}
2012-01-21 21:57:41 +01:00
else
{
2012-01-21 21:57:41 +01:00
force_update[view] = true;
gprintf("force_update[%d] = true\n", view);
}
2012-01-21 21:57:41 +01:00
}
void Load(string path, string containing, string m_lastLanguage, Config &m_plugin);
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(*this, m_database, SAVE);} /* Save All */
2012-01-21 21:57:41 +01:00
void Get(dir_discHdr tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, LOAD);} /* Load One */
void Set(dir_discHdr tmp, u32 index) {if(m_loaded) CCache(tmp, m_database, index, SAVE);} /* Save One */
void Add(dir_discHdr tmp) {if(m_loaded) CCache(*this, m_database, tmp, ADD);} /* Add One */
void Remove(u32 index) {if(m_loaded) CCache(*this, m_database, index, REMOVE);} /* Remove One */
2012-01-21 21:57:41 +01:00
void SetLanguage(string curLanguage) { m_curLanguage = curLanguage; }
private:
string make_db_name(string path);
2012-01-21 21:57:41 +01:00
bool m_loaded;
bool m_update;
bool m_wbfsFS;
bool m_extcheck;
bool m_skipcheck;
2012-01-21 21:57:41 +01:00
u8 force_update[COVERFLOW_MAX];
CList<dir_discHdr> list;
string m_database;
string m_cacheDir;
2012-01-21 21:57:41 +01:00
string m_settingsDir;
string m_curLanguage;
2012-02-10 16:48:27 +01:00
string m_lastLanguage;
string m_discinf;
string m_DMLgameDir;
2012-01-21 21:57:41 +01:00
};
#endif