// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include "FactorySettings.hpp" #include #include #include #include #include #include namespace settings { struct EntryPath; class SettingsCache; } // namespace settings namespace sys { class Service; } // namespace sys class SettingsAgent : public DatabaseAgent { public: SettingsAgent(sys::Service *parentService, std::string dbName, settings::SettingsCache *cache = nullptr); ~SettingsAgent() = default; void registerMessages() override; void unRegisterMessages() override; auto getAgentName() -> const std::string override; auto getDbFilePath() -> const std::string override; private: settings::SettingsCache *cache; settings::FactorySettings factorySettings; using MapOfRecipentsToBeNotified = std::map>; MapOfRecipentsToBeNotified variableChangeRecipients; using SetOfRecipents = std::set; SetOfRecipents profileChangedRecipients; SetOfRecipents modeChangeRecipients; const std::string dbName; // db operations auto dbGetValue(const settings::EntryPath &path) -> std::optional; auto dbSetValue(const settings::EntryPath &path, const std::string &value) -> bool; auto dbRegisterValueChange(const settings::EntryPath &path) -> bool; auto dbUnregisterValueChange(const settings::EntryPath &path) -> bool; // msg handlers // variable auto handleGetVariable(sys::Message *req) -> sys::MessagePointer; auto handleSetVariable(sys::Message *req) -> sys::MessagePointer; auto handleRegisterOnVariableChange(sys::Message *req) -> sys::MessagePointer; auto handleUnregisterOnVariableChange(sys::Message *req) -> sys::MessagePointer; };