2012-01-21 21:57:41 +01:00
|
|
|
#ifndef CCACHE
|
|
|
|
#define CCACHE
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <fstream>
|
2012-05-06 14:03:43 +02:00
|
|
|
#include <vector>
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "loader/disc.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
//#include "gecko.h"
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
const char io[4][5] = {
|
|
|
|
"wb",
|
|
|
|
"rb",
|
|
|
|
"ab",
|
|
|
|
"wb",
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CMode
|
|
|
|
{
|
|
|
|
SAVE,
|
|
|
|
LOAD,
|
|
|
|
ADD,
|
|
|
|
REMOVE
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class CCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCache(T &tmp, string path, u32 index, CMode mode); /* Load/Save One */
|
2012-05-06 14:03:43 +02:00
|
|
|
CCache(vector<T> &list, string path, CMode mode); /* Load/Save All */
|
|
|
|
CCache(vector<T> &list, string path, T tmp, CMode mode); /* Add One */
|
|
|
|
CCache(vector<T> &list, string path, u32 index, CMode mode); /* Remove One */
|
2012-01-21 21:57:41 +01:00
|
|
|
~CCache();
|
|
|
|
private:
|
2012-05-06 14:03:43 +02:00
|
|
|
void SaveAll(vector<T> list);
|
2012-01-21 21:57:41 +01:00
|
|
|
void SaveOne(T tmp, u32 index);
|
2012-05-06 14:03:43 +02:00
|
|
|
void LoadAll(vector<T> &list);
|
2012-01-21 21:57:41 +01:00
|
|
|
void LoadOne(T &tmp, u32 index);
|
|
|
|
|
2012-05-06 14:03:43 +02:00
|
|
|
void AddOne(vector<T> &list, T tmp);
|
|
|
|
void RemoveOne(vector<T> &list, u32 index);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
FILE *cache;
|
|
|
|
string filename;
|
|
|
|
};
|
|
|
|
#endif
|