2020-05-08 14:45:27 +00:00
|
|
|
/**
|
|
|
|
* A static class to manage the configuration file, read/write parameters to it.
|
|
|
|
*
|
|
|
|
* @author Lukas Heiligenbrunner
|
|
|
|
* @date 11.02.2020
|
|
|
|
*/
|
2020-02-11 15:42:05 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2020-04-30 17:37:11 +00:00
|
|
|
class Config {
|
2020-02-11 15:42:05 +00:00
|
|
|
public:
|
2020-05-01 13:33:20 +00:00
|
|
|
/**
|
2020-05-07 12:54:40 +00:00
|
|
|
* read configuration out of config file
|
|
|
|
*
|
|
|
|
* @return success of config read
|
|
|
|
*/
|
|
|
|
static bool readConfig();
|
2020-02-11 15:42:05 +00:00
|
|
|
|
2020-05-19 14:23:00 +00:00
|
|
|
/**
|
|
|
|
* save back configuration to file
|
|
|
|
*
|
|
|
|
* @return success of config write
|
|
|
|
*/
|
|
|
|
static bool saveConfig();
|
|
|
|
|
2020-05-01 13:33:20 +00:00
|
|
|
/**
|
|
|
|
* validate config file
|
|
|
|
*
|
|
|
|
* @return validity of config file
|
|
|
|
*/
|
|
|
|
static bool validateConfig();
|
|
|
|
|
2020-05-07 12:54:40 +00:00
|
|
|
/**
|
|
|
|
* check if telegram credentials in config are set
|
|
|
|
* @return is supported?
|
|
|
|
*/
|
|
|
|
static bool isTelegramSupported();
|
|
|
|
|
|
|
|
/** Getters **/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encapsulated getter for DynuApiKey
|
|
|
|
* @return api key
|
|
|
|
*/
|
|
|
|
static const std::string &getDynuapikey();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encapsulated getter for DomainId
|
|
|
|
* @return DomainId
|
|
|
|
*/
|
|
|
|
static const std::string &getDomainid();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encapsulated getter for Domainname
|
|
|
|
* @return Domainname
|
|
|
|
*/
|
|
|
|
static const std::string &getDomainname();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encapsulated getter for TelegramApiKey
|
|
|
|
* @return TelegramApiKey
|
|
|
|
*/
|
|
|
|
static const std::string &getTelegramApiKey();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encapsulated getter for ChatId
|
|
|
|
* @return ChatId
|
|
|
|
*/
|
|
|
|
static const std::string &getChatId();
|
|
|
|
|
2020-05-19 14:23:00 +00:00
|
|
|
/**
|
|
|
|
* set all parameters without telegram support
|
|
|
|
*
|
|
|
|
* @param domainname Dynu Domain name
|
|
|
|
* @param dynuapikey Dynu api key
|
|
|
|
* @param domainid Dynu domain id
|
|
|
|
*/
|
|
|
|
static void setValues(const std::string &domainname, const std::string &dynuapikey, const std::string &domainid);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set all parameters with telegram support
|
|
|
|
*
|
|
|
|
* @param domainname Dynu Domain name
|
|
|
|
* @param dynuapikey Dynu api key
|
|
|
|
* @param domainid Dynu domain id
|
|
|
|
* @param telegramApiKey Telegram api key
|
|
|
|
* @param chatId Telegram chat id
|
|
|
|
*/
|
|
|
|
static void setValues(const std::string &domainname, const std::string &dynuapikey, const std::string &domainid,
|
|
|
|
const std::string &telegramApiKey, const std::string &chatId);
|
2020-05-07 12:54:40 +00:00
|
|
|
|
2020-02-11 16:14:17 +00:00
|
|
|
private:
|
2020-05-07 12:54:40 +00:00
|
|
|
/**
|
|
|
|
* private constructor --> don't allow instance of this class
|
|
|
|
*/
|
2020-05-19 14:23:00 +00:00
|
|
|
Config() = default;
|
2020-05-07 12:54:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* helper variable for managing telegram Support
|
|
|
|
*/
|
|
|
|
static bool telegramSupport;
|
|
|
|
|
2020-05-08 14:45:27 +00:00
|
|
|
/**
|
|
|
|
* helper variables for storing keys and ids
|
|
|
|
*/
|
2020-05-07 12:54:40 +00:00
|
|
|
static std::string dynuapikey;
|
|
|
|
static std::string domainid; //id of the dynu domain
|
|
|
|
static std::string domainname;
|
|
|
|
static std::string telegramApiKey;
|
|
|
|
static std::string chatId;
|
2020-02-11 16:14:17 +00:00
|
|
|
};
|