#ifndef DGRIDD_DATASTORE_SIMPLE_H #define DGRIDD_DATASTORE_SIMPLE_H #include #include "dgrid.h" #include "dgrid_req_structs.h" namespace DGrid { class DGriddNodeArbiter; class DGriddDataStoreSimple { public: DGriddDataStoreSimple(std::string session = "", DGriddNodeArbiter* a = nullptr); virtual ~DGriddDataStoreSimple(); void setNodeArbiter(DGriddNodeArbiter*); void showStats(); uint32_t getThemesCount(); uint64_t getKeysCount(); /* client-controlled methods: stats */ DGridResult get_stats(const std::string& theme, std::vector& data, std::string& error_string); /* client-controlled methods */ DGridResult set_value(const std::string& theme, const std::string& key, /*const*/ SimpleValueData& value, std::string& error_string); DGridResult get_value(const std::string& theme, const std::string& key, SimpleValueData& value, std::string& error_string); DGridResult del_value(const std::string& theme, const std::string& key, std::string& error_string); /* node interaction methods */ // ответ на запрос темы (в data можно указать ключи, если нужна не вся тема) DGridResult get_theme_simple(const std::string& name, SimpleValueMap& data); // сохраняем копию в локальное хранилище, для единичной записи возвращаем прошлый источник DGridResult append_theme_simple(const std::string& name, const SimpleValueMap& data, NodeID& source_node); // дописываем в локальное хранилище и возвращаем разницу DGridResult sync_theme_simple(const std::string& name, SimpleValueMap& data); private: DGriddNodeArbiter* _node_arbiter; std::string _session; std::mutex io_mutex; std::unordered_map internal_data; }; } // namespace DGrid #endif // DGRIDD_DATASTORE_SIMPLE_H