2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <fstream>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class SettingsReader {
|
|
|
|
public:
|
|
|
|
virtual ~SettingsReader() {}
|
2019-09-02 18:04:22 +08:00
|
|
|
static SettingsReader *create(const std::string ®Key) {
|
2017-12-21 07:45:38 +08:00
|
|
|
SettingsReader *readerImpl = createFileReader();
|
|
|
|
if (readerImpl != nullptr)
|
|
|
|
return readerImpl;
|
|
|
|
|
2019-09-02 18:04:22 +08:00
|
|
|
return createOsReader(false, regKey);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-09-02 18:04:22 +08:00
|
|
|
static SettingsReader *createOsReader(bool userScope, const std::string ®Key);
|
2017-12-21 07:45:38 +08:00
|
|
|
static SettingsReader *createFileReader();
|
|
|
|
virtual int32_t getSetting(const char *settingName, int32_t defaultValue) = 0;
|
2020-03-27 14:47:16 +08:00
|
|
|
virtual int64_t getSetting(const char *settingName, int64_t defaultValue) = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
virtual bool getSetting(const char *settingName, bool defaultValue) = 0;
|
|
|
|
virtual std::string getSetting(const char *settingName, const std::string &value) = 0;
|
2018-10-10 22:02:19 +08:00
|
|
|
virtual const char *appSpecificLocation(const std::string &name) = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
static const char *settingsFileName;
|
2020-08-24 07:55:47 +08:00
|
|
|
MOCKABLE_VIRTUAL char *getenv(const char *settingName);
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
}; // namespace NEO
|