mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-09 00:00:17 +02:00
Instead of having the configuration being loaded and stored in to a frontend system. First moves the backing store of the configuration in to FEXCore. Each layer that is constructed then loads its particular configuration. After the layers are loaded, then a meta layer is constructed that merges the layers flat. This means we will no longer hit the problem where a configuration is stored in the "main" configuration file, then environment and arguments passed manage to overwrite it. The order of the layers going from inner most layer to outer most, with outermost overwriting previous layer configurations is as follows: Main < Global application < Local application < Arguments < Environment One step that needs to be changed in the future is that FEXCore can then just load its configuration from the layers directly since the data is in FEXCore now. This will be reserved for a future change so we are less disruptive.
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#pragma once
|
|
#include <FEXCore/Config/Config.h>
|
|
|
|
#include <cassert>
|
|
#include <list>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
/**
|
|
* @brief This is a singleton for storing global configuration state
|
|
*/
|
|
namespace FEX::Config {
|
|
class EmptyMapper : public FEXCore::Config::Layer {
|
|
public:
|
|
explicit EmptyMapper()
|
|
: FEXCore::Config::Layer(FEXCore::Config::LayerType::LAYER_MAIN) {
|
|
}
|
|
void Load() override {}
|
|
|
|
protected:
|
|
};
|
|
|
|
class OptionMapper : public FEXCore::Config::Layer {
|
|
public:
|
|
explicit OptionMapper(FEXCore::Config::LayerType Layer);
|
|
|
|
protected:
|
|
void MapNameToOption(const char *ConfigName, const char *ConfigString);
|
|
};
|
|
|
|
class MainLoader final : public FEX::Config::OptionMapper {
|
|
public:
|
|
explicit MainLoader();
|
|
explicit MainLoader(std::string ConfigFile);
|
|
void Load() override;
|
|
|
|
private:
|
|
std::string Config;
|
|
};
|
|
|
|
class AppLoader final : public FEX::Config::OptionMapper {
|
|
public:
|
|
explicit AppLoader(std::string Filename, bool Global);
|
|
void Load();
|
|
|
|
private:
|
|
std::string Config;
|
|
};
|
|
|
|
class EnvLoader final : public FEXCore::Config::Layer {
|
|
public:
|
|
explicit EnvLoader(char *const _envp[]);
|
|
void Load() override;
|
|
|
|
private:
|
|
char *const *envp;
|
|
};
|
|
|
|
std::string GetConfigFolder(bool Global);
|
|
std::string GetConfigFileLocation();
|
|
std::string GetApplicationConfig(std::string &Filename, bool Global);
|
|
|
|
void SaveLayerToJSON(std::string Filename, FEXCore::Config::Layer *const Layer);
|
|
}
|