| 6 |
| 7 | #ifndef TGVOIP_VOIPSERVERCONFIG_H |
| 8 | #define TGVOIP_VOIPSERVERCONFIG_H |
| 9 |
| 10 | #include "json11.hpp" |
| 11 | #include "threading.h" |
| 12 |
| 13 | #include <cstdint> |
| 14 | #include <string> |
| 15 |
| 16 | namespace tgvoip |
| 17 | { |
| 18 |
| 19 | class ServerConfig |
| 20 | { |
| 21 | public: |
| 22 | ServerConfig(); |
| 23 | ~ServerConfig(); |
| 24 | static ServerConfig* GetSharedInstance(); |
| 25 | std::int32_t GetInt(const std::string& name, std::int32_t fallback); |
| 26 | double GetDouble(const std::string& name, double fallback); |
| 27 | std::string GetString(const std::string& name, const std::string& fallback); |
| 28 | bool GetBoolean(const std::string& name, bool fallback); |
| 29 | void Update(const std::string& jsonString); |
| 30 |
| 31 | private: |
| 32 | static ServerConfig* m_sharedInstance; |
| 33 | json11::Json m_config; |
| 34 | Mutex m_mutex; |
| 35 |
| 36 | [[nodiscard]] bool ContainsKey(const std::string& key) const; |
| 37 | }; |
| 38 |
| 39 | } // namespace tgvoip |
| 40 |
| 41 | #endif // TGVOIP_VOIPSERVERCONFIG_H |
| 42 |