diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 17:20:50 -0500 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2019-08-08 17:20:50 -0500 |
| commit | 55087521f6db9aaa874cccd86e424d77e6c820c3 (patch) | |
| tree | fdc87b595d29c8eb383ab85aa0173259c0558d25 /controller/DB.hpp | |
| parent | 760ae07d7243b8e7ff6ec03cf508058c287c219f (diff) | |
| download | infinitytier-55087521f6db9aaa874cccd86e424d77e6c820c3.tar.gz infinitytier-55087521f6db9aaa874cccd86e424d77e6c820c3.zip | |
Add periodic sync check when syncing LF<>another DB
Diffstat (limited to 'controller/DB.hpp')
| -rw-r--r-- | controller/DB.hpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/controller/DB.hpp b/controller/DB.hpp index aebe4e11..6c518426 100644 --- a/controller/DB.hpp +++ b/controller/DB.hpp @@ -100,6 +100,19 @@ public: void networks(std::set<uint64_t> &networks); + template<typename F> + inline void each(F f) + { + nlohmann::json nullJson; + std::lock_guard<std::mutex> lck(_networks_l); + for(auto nw=_networks.begin();nw!=_networks.end();++nw) { + f(nw->first,nw->second->config,0,nullJson); // first provide network with 0 for member ID + for(auto m=nw->second->members.begin();m!=nw->second->members.end();++m) { + f(nw->first,nw->second->config,m->first,m->second); + } + } + } + virtual bool save(nlohmann::json &record,bool notifyListeners) = 0; virtual void eraseNetwork(const uint64_t networkId) = 0; @@ -114,7 +127,7 @@ public: } protected: - inline bool _compareRecords(const nlohmann::json &a,const nlohmann::json &b) + static inline bool _compareRecords(const nlohmann::json &a,const nlohmann::json &b) { if (a.is_object() == b.is_object()) { if (a.is_object()) { |
