You.i Engine
YiPreferences.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_PREFERENCES_H_
3 #define _YI_PREFERENCES_H_
4 
5 #include <ostream>
6 
8 
22 {
23 public:
28 
34  CYIPreferences(const CYIString &path, bool watchFile = false);
35 
39  CYIPreferences(const CYIPreferences &prefs);
40 
44  virtual ~CYIPreferences();
45 
51 
55  std::vector<CYIString> GetNames() const;
56 
60  const CYIString &GetPropFilePath() const
61  {
62  return m_configFilePath;
63  }
64 
68  void SetPropFilePath(const CYIString &path)
69  {
70  m_configFilePath = path;
71  }
72 
76  void Clear();
77 
82  virtual bool Load() final;
83 
89  virtual bool Save(const CYIString &path = CYIString::EmptyString()) const;
90 
95  CYIString Get(const CYIString &name, bool *pFound = nullptr) const;
96 
100  void Set(const CYIString &name, const CYIString &value);
101 
106  bool IsWatchingFile() const;
107 
112  void UpdateFileMonitor();
113 
119 
125 
131 
132 private:
136  yi::deprecated::CYIFileWatcher *CreateFileWatcher();
137 
141  void CleanUpFileWatcher();
142 
146  void OnFileModified(const CYIString &path);
147 
151  void OnFileCreated(const CYIString &path);
152 
156  void OnFileDeleted(const CYIString &path);
157 
158  CYIString m_configFilePath;
159  bool m_watchFile;
160 
161  std::map<CYIString, CYIString> m_settings;
162 
163  yi::deprecated::YI_FILEWATCHID m_watchedID;
164 
165  std::unique_ptr<yi::deprecated::CYIFileWatcher> m_pFileWatcher;
166 };
167 
168 std::ostream &operator<<(std::ostream &stream, const CYIPreferences &val);
169 
172 #endif // _YI_PREFERENCES_H_
CYISignal< CYIPreferences > PropFileDeleted
Definition: YiPreferences.h:130
void Set(const CYIString &name, const CYIString &value)
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
CYIString Get(const CYIString &name, bool *pFound=nullptr) const
virtual ~CYIPreferences()
bool IsWatchingFile() const
CYIPreferences & operator=(const CYIPreferences &rhs)
static const CYIString & EmptyString()
std::ostream & operator<<(std::ostream &stream, const CYIPreferences &val)
int32_t YI_FILEWATCHID
Definition: YiFileWatcher.h:18
CYISignal< CYIPreferences > PropFileCreated
Definition: YiPreferences.h:124
Definition: YiSignalHandler.h:175
virtual bool Save(const CYIString &path=CYIString::EmptyString()) const
virtual bool Load() final
Property management class using CYIString names and values.
Definition: YiPreferences.h:21
void UpdateFileMonitor()
std::vector< CYIString > GetNames() const
const CYIString & GetPropFilePath() const
Definition: YiPreferences.h:60
void SetPropFilePath(const CYIString &path)
Definition: YiPreferences.h:68
Monitor one or more directories for changes in their files.
Definition: YiFileWatcher.h:35
CYISignal< CYIPreferences > PropFileChanged
Definition: YiPreferences.h:118