#pragma once #include "boost/unordered/concurrent_flat_map.hpp" #include "fileinfo.hpp" #include #include #include constexpr int INVALID_BACKING_ID = -1; class State { public: State(); public: struct OpenFile { OpenFile() : ref_count(0), backing_id(INVALID_BACKING_ID), fi(nullptr) { } int ref_count; int backing_id; FileInfo *fi; }; public: struct GetSet { std::function get; std::function set; }; void set_getset(const std::string &name, const State::GetSet &gs); int get(const std::string &key, std::string &val); int set(const std::string &key, const std::string_view val); public: using OpenFileMap = boost::concurrent_flat_map; private: std::map _getset; public: OpenFileMap open_files; }; extern State state;