BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
FileCredentialsStorage.h
1 #pragma once
2 #include <Poco/Timer.h>
3 #include <Poco/AtomicCounter.h>
4 #include <Poco/Timespan.h>
5 
6 #include "credentials/CredentialsStorage.h"
7 
8 namespace BeeeOn{
9 
17 public:
20 
21  void setFile(const std::string &path);
22 
28  void setConfigRoot(const std::string &root);
29 
38  void setSaveDelay(const Poco::Timespan &delay);
39  void load();
40  void save();
41 
42  void insertOrUpdate(
43  const DeviceID &device,
44  const Poco::SharedPtr<Credentials> credentials) override;
45 
46  void remove(const DeviceID &device) override;
47  void clear() override;
48 
49 protected:
53  void saveLater();
54  void onSaveLater(Poco::Timer &);
55 
56  void saveUnlocked() const;
57 
58 private:
59  std::string m_file;
60  std::string m_confRoot;
61  Poco::Timer m_timer;
62  Poco::TimerCallback<FileCredentialsStorage> m_callback;
63  Poco::AtomicCounter m_timerRunning;
64  Poco::Timespan m_saveDelayTime;
65 };
66 
67 }
void setSaveDelay(const Poco::Timespan &delay)
Definition: FileCredentialsStorage.cpp:40
Definition: CredentialsStorage.h:16
void setConfigRoot(const std::string &root)
Definition: FileCredentialsStorage.cpp:59
void saveLater()
Definition: FileCredentialsStorage.cpp:124
Definition: FileCredentialsStorage.h:16
Definition: DeviceID.h:17