/*
 * Copyright © 2020-2026 Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
 */
#ifndef ZIPDIRFS_ZIP_FACTORY_H
#define ZIPDIRFS_ZIP_FACTORY_H

#include "ZipDirFs/Zip/Archive.h"
#include <filesystem>
#include <map>
#include <memory>

namespace ZipDirFs::Zip
{
	namespace fs = std::filesystem;

	struct FactoryInstantiate;

	/**
	 * @brief A Factory to create or access zip archives
	 * @authors Pierrick Caillon <pierrick.caillon+zipdirfs@megami.fr>
	 */
	class Factory
	{
	public:
		std::shared_ptr<Archive> get(const fs::path&);
		static Factory& getInstance();

	protected:
		Factory();
		~Factory();
		static Factory* instance;
		static std::map<fs::path, std::weak_ptr<Archive>> archivesByPath;

	private:
		friend struct FactoryInstantiate;
	};

} // namespace ZipDirFs::Zip

#endif // ZIPDIRFS_ZIP_FACTORY_H
