2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
#include <unordered_map>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <string>
|
2018-10-24 23:31:26 +11:00
|
|
|
#include <memory>
|
2021-11-27 00:53:57 +01:00
|
|
|
#include <vector>
|
2018-10-24 23:31:26 +11:00
|
|
|
#include <mutex>
|
|
|
|
|
2019-10-14 18:41:16 +11:00
|
|
|
#include <filesystem>
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
namespace xiv
|
|
|
|
{
|
|
|
|
namespace dat
|
|
|
|
{
|
|
|
|
class GameData;
|
|
|
|
}
|
|
|
|
namespace exd
|
|
|
|
{
|
|
|
|
|
|
|
|
class Cat;
|
|
|
|
|
|
|
|
// Interface for retrieval of exd data - Main entry point
|
|
|
|
// the game_data object should outlive the exd_data object
|
|
|
|
class ExdData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Need an initialized dat::GameData to retrieve the files from the dat
|
2023-04-26 13:58:41 +02:00
|
|
|
ExdData( dat::GameData& i_game_data );
|
|
|
|
~ExdData() = default;
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
// Get the list of thenames of the categories
|
2023-04-26 13:58:41 +02:00
|
|
|
const std::vector< std::string >& get_cat_names() const;
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
// Get a category by its name
|
2023-04-26 13:58:41 +02:00
|
|
|
const Cat& get_category( const std::string& i_cat_name );
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
// Export in csv in base flder i_ouput_path
|
2023-04-26 13:58:41 +02:00
|
|
|
void export_as_csvs( const std::filesystem::path& i_output_path );
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Lazy instantiation of category
|
2023-04-26 13:58:41 +02:00
|
|
|
void create_category( const std::string& i_cat_name );
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
// Reference to the game_data object
|
|
|
|
dat::GameData& _game_data;
|
|
|
|
|
|
|
|
// Categories, indexed by their name
|
2023-04-26 13:58:41 +02:00
|
|
|
std::unordered_map< std::string, std::unique_ptr< Cat > > _cats;
|
2018-10-24 23:31:26 +11:00
|
|
|
// List of category names = m_cats.keys()
|
2023-04-26 13:58:41 +02:00
|
|
|
std::vector< std::string > _cat_names;
|
2018-10-24 23:31:26 +11:00
|
|
|
// Mutexes used to avoid race condition when lazy instantiating a category
|
2023-04-26 13:58:41 +02:00
|
|
|
std::unordered_map< std::string, std::unique_ptr< std::mutex > > _cat_creation_mutexes;
|
2018-10-24 23:31:26 +11:00
|
|
|
};
|
|
|
|
|
2023-04-26 13:58:41 +02:00
|
|
|
}// namespace exd
|
|
|
|
}// namespace xiv
|