SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
saveable.h
Go to the documentation of this file.
1#ifndef SENSESP_SYSTEM_SAVEABLE_H_
2#define SENSESP_SYSTEM_SAVEABLE_H_
3
4#include "sensesp.h"
5
6#include <ArduinoJson.h>
7
8#include "Arduino.h"
9#include "serializable.h"
10
11namespace sensesp {
12
18class Saveable {
19 public:
20 Saveable(const String& config_path) : config_path_{config_path} {}
21
28 virtual bool load() { return false; }
39 virtual bool refresh() { return false; }
46 virtual bool save() { return false; }
53 virtual bool clear() { return false; }
54
55 const String& get_config_path() const { return config_path_; }
56
57 protected:
58 const String config_path_;
59};
60
61class FileSystemSaveable : public Saveable, virtual public Serializable {
62 public:
63 FileSystemSaveable(const String& config_path) : Saveable(config_path) {}
64
65 virtual bool load() override;
66 virtual bool save() override;
67 virtual bool clear() override;
68
69 bool find_config_file(const String& config_path, String& filename);
70};
71
72} // namespace sensesp
73
74#endif // SENSESP_SYSTEM_SAVEABLE_H_
virtual bool clear() override
Delete the data from a persistent storage.
Definition saveable.cpp:72
virtual bool load() override
Load and populate the object from a persistent storage.
Definition saveable.cpp:8
virtual bool save() override
Save the object to a persistent storage.
Definition saveable.cpp:41
FileSystemSaveable(const String &config_path)
Definition saveable.h:63
bool find_config_file(const String &config_path, String &filename)
Definition saveable.cpp:90
Interface for saveable objects.
Definition saveable.h:18
virtual bool save()
Save the object to a persistent storage.
Definition saveable.h:46
virtual bool clear()
Delete the data from a persistent storage.
Definition saveable.h:53
virtual bool refresh()
Refresh the object. This may or may not access the persistent storage but is not expected to overwrit...
Definition saveable.h:39
Saveable(const String &config_path)
Definition saveable.h:20
const String & get_config_path() const
Definition saveable.h:55
const String config_path_
Definition saveable.h:58
virtual bool load()
Load and populate the object from a persistent storage.
Definition saveable.h:28
Interface for serializable objects.