//
// Created by Иван_Архипов on 31.10.2017.
//

#ifndef LOTRO_DAT_PATCHER_DATFILE_H
#define LOTRO_DAT_PATCHER_DATFILE_H

#ifdef LOTRO_DAT_EXPORTS
#define LOTRO_DAT_API __declspec(dllexport)
#else
#define LOTRO_DAT_API __declspec(dllimport)
#endif

#include <bits/unique_ptr.h>
#include "DatSubsystems/DatBackupManager.h"
#include "DatSubsystems/DatExporter.h"
#include "DatSubsystems/DatFileSystem.h"
#include "DatSubsystems/DatIO.h"
#include "DatSubsystems/DatLocaleManager.h"
#include "DatSubsystems/DatPatcher.h"
#include "DatSubsystems/DatStatus.h"

// Dat file names definitions

extern "C++"
{
namespace LOTRO_DAT {
    enum FILE_TYPE : int {
        NO_TYPE = 0,
        TEXT = 1,
        JPG = 2,
        DDS = 4,
        WAV = 8,
        OGG = 16,
        FONT = 32,
        UNKNOWN = 64
    };

    class DatFile {

    public:
        DatFile();
        DatFile(const DatFile &other) = delete;
        DatFile(DatFile &&other) = default;
        DatFile &operator=(const DatFile &other) = delete;
        DatFile &operator=(DatFile &&other) = default;
        ~DatFile();

        DatLocaleManager &GetLocaleManager();
        DatExporter &GetExporter();
        DatPatcher &GetPatcher();
        DatBackupManager &GetBackupManager();
        DatIO &GetIO();
        DatFileSystem &GetFileSystem();
        DatStatus &GetStatusModule();

        DatOperationResult<> Initialise(const std::string &filename, long long dat_id);
        DatOperationResult<> GatherInformation(const std::string &output_filename);
        DatOperationResult<> Deinitialize();
        bool Initialized();
        long long GetDatID();

    private:
        std::unique_ptr<DatIO> io_;
        std::unique_ptr<DatFileSystem> fileSystem_;
        std::unique_ptr<DatLocaleManager> localeManager_;
        std::unique_ptr<DatPatcher> patcher_;
        std::unique_ptr<DatExporter> exporter_;
        std::unique_ptr<DatBackupManager> backupManager_;
        std::unique_ptr<DatStatus> status_;

        bool initialized_;
        long long dat_id_;
    };
}
}

#endif //LOTRO_DAT_PATCHER_DATFILE_H