66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
|
|
#ifndef FILELOADER_H
|
|
#define FILELOADER_H FILELOADER_H
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
|
|
class FileLoader
|
|
{
|
|
public:
|
|
class Path
|
|
{
|
|
public:
|
|
std::string fullPath;
|
|
std::string shortPath;
|
|
Path(const std::string & full_path,
|
|
const std::string & short_path)
|
|
: fullPath(full_path), shortPath(short_path)
|
|
{
|
|
}
|
|
};
|
|
|
|
class Buffer
|
|
{
|
|
public:
|
|
char * data;
|
|
int size;
|
|
Buffer(int sz)
|
|
{
|
|
size = sz;
|
|
data = new char[size];
|
|
_refcnt = new int;
|
|
*_refcnt = 1;
|
|
}
|
|
Buffer(const Buffer & other)
|
|
{
|
|
data = other.data;
|
|
_refcnt = other._refcnt;
|
|
(*refcnt)++;
|
|
}
|
|
Buffer & operator=(Buffer & me, const Buffer & other)
|
|
{
|
|
me.data = other.data;
|
|
me._refcnt = other._refcnt;
|
|
(*me_.refcnt)++;
|
|
return me;
|
|
}
|
|
~Buffer()
|
|
{
|
|
(*_refcnt)--;
|
|
if (*refcnt < 1)
|
|
{
|
|
delete _refcnt;
|
|
delete data;
|
|
}
|
|
}
|
|
protected:
|
|
int * _refcnt;
|
|
};
|
|
|
|
virtual int getSize(const Path & path) = 0;
|
|
virtual Buffer load(const Path & path) = 0;
|
|
};
|
|
|
|
#endif
|