Allolib  1.0
C++ Components For Interactive Multimedia
al_PersistentConfig.hpp
1 #ifndef INCLUDE_PERSISTENTCONFIG_HPP
2 #define INCLUDE_PERSISTENTCONFIG_HPP
3 
4 #include <cinttypes>
5 #include <iostream>
6 #include <string>
7 #include <vector>
8 
9 #include "al/io/al_File.hpp"
10 #include "al/io/al_Toml.hpp"
11 #include "al/ui/al_Parameter.hpp"
12 
13 namespace al {
14 
19 public:
24  void setAppName(std::string appName);
25 
26  void registerDouble(std::string name, double *value);
27 
28  void registerInt(std::string name, int64_t *value);
29 
30  void registerString(std::string name, std::string *value);
31 
32  void registerParameter(Parameter &param);
33  void registerParameter(ParameterInt &param);
34  void registerParameter(ParameterString &param);
35  void registerParameter(ParameterColor &param);
36 
45  bool read();
46 
47  void write();
48 
49 private:
50  std::string mAppName{"app"};
51  std::vector<std::pair<std::string, double *>> mDoubles;
52  std::vector<std::pair<std::string, int64_t *>> mInts;
53  std::vector<std::pair<std::string, std::string *>> mStrings;
54 
55  std::vector<Parameter *> mParameters;
56  std::vector<ParameterInt *> mParameterInts;
57  std::vector<ParameterString *> mParameterStrings;
58  std::vector<ParameterColor *> mParameterColors;
59 };
60 
61 } // namespace al
62 
63 #endif // INCLUDE_PERSISTENTCONFIG_HPP
The Parameter class.
The PersistentConfig class allows easy sotrage of persisitent values.
void setAppName(std::string appName)
Set name of app. This determines the file name for the config file.
Definition: al_App.hpp:23