<commit_before>#pragma once

#include "../IPC/IPC.h"
#include "StaticFile.h"
#include <map>
#include <memory>
#include <thread>
#include <set>
#include <mutex>

namespace Effekseer
{

class IO
{
private:
	std::shared_ptr<IPC::KeyValueFileStorage> ipcStorage_;

	struct FileInfo
	{
		IOFileType fileType_;
		std::u16string path_;

		FileInfo(IOFileType fileType, std::u16string path) : fileType_(fileType), path_(path) {}

		bool operator==(const FileInfo& right) { return fileType_ == right.fileType_ && path_ == right.path_; }
		bool operator<(const FileInfo& right) const { return std::tie(fileType_, path_) < std::tie(right.fileType_, right.path_); }
	};

	std::map<FileInfo, int> fileUpdateDates_;
	std::thread checkFileThread;
	bool isFinishCheckFile_ = false;
	
	std::set<FileInfo> changedFileInfos_;
	std::set<FileInfo> notifiedFileInfos_;
	std::mutex mtx_;

public:
	IO(int checkFileInterval = 0);
	~IO();

	std::shared_ptr<StaticFile> LoadFile(const char16_t* path);
	std::shared_ptr<StaticFile> LoadIPCFile(const char16_t* path);

	bool GetIsExistLatestFile(std::shared_ptr<StaticFile> staticFile);

#ifndef SWIG
	std::shared_ptr<IPC::KeyValueFileStorage> GetIPCStorage() { return ipcStorage_; }
#endif

	void Update();

	virtual void OnFileChanged(IOFileType fileType, std::u16string path) {}

private:
	int GetFileLastWriteTime(const FileInfo& fileInfo);
	void CheckFile(int interval);
};

} // namespace Effekseer<commit_msg>Add virtual<commit_after>#pragma once

#include "../IPC/IPC.h"
#include "StaticFile.h"
#include <map>
#include <memory>
#include <thread>
#include <set>
#include <mutex>

namespace Effekseer
{

class IO
{
private:
	std::shared_ptr<IPC::KeyValueFileStorage> ipcStorage_;

	struct FileInfo
	{
		IOFileType fileType_;
		std::u16string path_;

		FileInfo(IOFileType fileType, std::u16string path) : fileType_(fileType), path_(path) {}

		bool operator==(const FileInfo& right) { return fileType_ == right.fileType_ && path_ == right.path_; }
		bool operator<(const FileInfo& right) const { return std::tie(fileType_, path_) < std::tie(right.fileType_, right.path_); }
	};

	std::map<FileInfo, int> fileUpdateDates_;
	std::thread checkFileThread;
	bool isFinishCheckFile_ = false;
	
	std::set<FileInfo> changedFileInfos_;
	std::set<FileInfo> notifiedFileInfos_;
	std::mutex mtx_;

public:
	IO(int checkFileInterval = 0);
	virtual ~IO();

	std::shared_ptr<StaticFile> LoadFile(const char16_t* path);
	std::shared_ptr<StaticFile> LoadIPCFile(const char16_t* path);

	bool GetIsExistLatestFile(std::shared_ptr<StaticFile> staticFile);

#ifndef SWIG
	std::shared_ptr<IPC::KeyValueFileStorage> GetIPCStorage() { return ipcStorage_; }
#endif

	void Update();

	virtual void OnFileChanged(IOFileType fileType, std::u16string path) {}

private:
	int GetFileLastWriteTime(const FileInfo& fileInfo);
	void CheckFile(int interval);
};

} // namespace Effekseer
{'fraction_non_alphanumeric': 0.1311589174184594, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 6.566929133858268, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7121478', 'n_tokens_mistral': 1043, 'n_tokens_neox': 990, 'n_words': 219}