API adjustments

This commit is contained in:
Jack Andersen 2015-06-26 10:01:15 -10:00
parent 8f2f4ea2e6
commit ccb67d0d0e
6 changed files with 49 additions and 33 deletions

View File

@ -1,5 +1,5 @@
TEMPLATE = lib
CONFIG += staticlib c++11
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
QT =
@ -15,10 +15,12 @@ HEADERS += \
include/DiscWii.hpp
SOURCES += \
lib/NODLib.cpp \
lib/DiscIOFILE.cpp \
lib/DiscIOWBFS.cpp \
lib/FileIOFILE.cpp \
lib/FileIOMEM.cpp \
lib/DiscBase.cpp \
lib/DiscGCN.cpp \
lib/DiscWii.cpp
lib/DiscWii.cpp \
main.cpp

View File

@ -13,27 +13,48 @@ namespace NOD
class DiscBase
{
IDiscIO& m_discIO;
protected:
struct Partition
public:
class IPartReadStream
{
public:
virtual size_t read(void* buf, size_t length)=0;
};
class IPartWriteStream
{
public:
virtual size_t write(void* buf, size_t length)=0;
};
protected:
class Partition
{
public:
enum Kind
{
PART_DATA,
PART_UPDATE
};
struct File
class File
{
const Partition& m_parent;
std::unique_ptr<IFileIO> m_hddFile;
std::string m_discPath;
size_t m_discOffset;
size_t m_discLength;
File(const std::string& discPath)
: m_discPath(discPath) {}
public:
File(const Partition& parent, const std::string& discPath)
: m_parent(parent), m_discPath(discPath) {}
std::unique_ptr<IPartReadStream> beginReadStream();
};
private:
std::list<File> files;
Kind m_kind;
public:
Partition(Kind kind)
: m_kind(kind) {}
std::unique_ptr<IPartReadStream> beginReadStream(size_t offset);
};
std::list<Partition> partitions;
Partition& addPartition(Partition::Kind kind);
@ -41,22 +62,6 @@ public:
DiscBase(IDiscIO& dio);
virtual bool sync()=0;
class IPartReadStream
{
public:
virtual size_t read(void* buf, size_t length)=0;
};
virtual std::unique_ptr<IPartReadStream> beginDataReadStream()=0;
virtual std::unique_ptr<IPartReadStream> beginUpdateReadStream()=0;
class IPartWriteStream
{
public:
virtual size_t write(void* buf, size_t length)=0;
};
virtual std::unique_ptr<IPartWriteStream> beginDataWriteStream()=0;
virtual std::unique_ptr<IPartWriteStream> beginUpdateWriteStream()=0;
};
}

View File

@ -17,14 +17,14 @@ public:
public:
virtual size_t read(void* buf, size_t length)=0;
};
virtual std::unique_ptr<IReadStream> beginReadStream(size_t offset);
virtual std::unique_ptr<IReadStream> beginReadStream(size_t offset)=0;
class IWriteStream
{
public:
virtual size_t write(void* buf, size_t length)=0;
};
virtual std::unique_ptr<IWriteStream> beginWriteStream(size_t offset);
virtual std::unique_ptr<IWriteStream> beginWriteStream(size_t offset)=0;
};
}

View File

@ -9,8 +9,7 @@
namespace NOD
{
std::unique_ptr<IDiscIO> NewDiscIOFILE(const char* path);
std::unique_ptr<IDiscIO> NewDiscIOWBFS(const char* path);
std::unique_ptr<DiscBase> OpenDiscFromImage(const char* path);
}

View File

@ -0,0 +1,6 @@
#include "DiscBase.hpp"
namespace NOD
{
}

View File

@ -1,10 +1,14 @@
#include <iostream>
#include "NODLib.hpp"
using namespace std;
int main()
int main(int argc, char* argv[])
{
cout << "Hello World!" << endl;
if (argc < 2)
return -1;
std::unique_ptr<NOD::DiscBase> disc = NOD::OpenDiscFromImage(argv[1]);
if (!disc)
return -1;
return 0;
}