38 I_ASSIGN(m_objectCompPtr,
"Object",
"Object will be restored and stored",
true,
"Object");
39 I_ASSIGN_TO(m_objectModelCompPtr, m_objectCompPtr,
false);
40 I_ASSIGN(m_fileLoaderCompPtr,
"FileLoader",
"File loader used to store and restore object",
true,
"FileLoader");
41 I_ASSIGN(m_filePathCompPtr,
"FilePath",
"File path where object data will be stored if non anonymous loader is used",
false,
"FilePath");
42 I_ASSIGN_TO(m_filePathModelCompPtr, m_filePathCompPtr,
false);
43 I_ASSIGN(m_prototypeFilePathAttrPtr,
"PrototypeFilePath",
"File path of prototype file, will be used for load if the file pointed at normal file path does not exist",
false,
"");
67 I_ATTR(QString, m_prototypeFilePathAttrPtr);
116 I_ASSIGN(m_restoreOnBeginAttrPtr,
"RestoreOnBegin",
"Flag indicating that object should be restored on begin",
true,
true);
117 I_ASSIGN(m_storeOnBeginAttrPtr,
"StoreOnBegin",
"Flag indicating that object should be stored on begin if the storage file doesn't exist",
true,
false);
118 I_ASSIGN(m_storeOnEndAttrPtr,
"StoreOnEnd",
"Flag indicating that object should be stored on end",
true,
true);
119 I_ASSIGN(m_storeOnChangeAttrPtr,
"StoreOnChange",
"Flag indicating that object should be stored on each data change",
true,
false);
120 I_ASSIGN(m_storeIntervalAttrPtr,
"StoreInterval",
"Time interval in seconds for automatic object storing",
false, 10);
121 I_ASSIGN(m_reloadOnFileChangeAttrPtr,
"AutoReload",
"Update data model if the file was changed",
true,
false);
122 I_ASSIGN(m_runtimeStatusCompPtr,
"RuntimeStatus",
"Application's runtime status",
false,
"RuntimeStatus");
123 I_ASSIGN_TO(m_runtimeStatusModelCompPtr, m_runtimeStatusCompPtr,
false);
124 I_ASSIGN(m_staleLockTimeAttrPtr,
"StaleLockTime",
"Time in seconds after which a lock file is considered stale.",
true, 30.0);
125 I_ASSIGN(m_tryLockTimeoutAttrPtr,
"TryLockTimeout",
"Lock function will wait for at most TryLockTimeout seconds for the lock file to become available."
126 "\nNOTE: Lock will wait forever until the lock file can be locked when set to negative",
true, 0.0);
127 I_ASSIGN(m_enableLockForLoadAttrPtr,
"EnableLockForRead",
"When enabled lock is also set when reading from file."
128 "\nNOTE: On NTFS file systems, ownership and permissions checking is disabled (in QT) by default for performance reasons."
129 "\nEnable this flag when you are known what you are doing.",
true,
false);
146 virtual bool LoadObject(
const QString& filePath,
bool allowPrototypeFile);
165 void OnFileContentsChanged(
const QString& path);
171 bool TryStartIntervalStore();
173 bool LockFile(
const QString& filePath,
bool store)
const;
174 void UnlockFile()
const;
183 I_ATTR(
bool, m_restoreOnBeginAttrPtr);
189 I_ATTR(
bool, m_storeOnBeginAttrPtr);
194 I_ATTR(
bool, m_storeOnEndAttrPtr);
199 I_ATTR(
bool, m_storeOnChangeAttrPtr);
205 I_ATTR(
double, m_storeIntervalAttrPtr);
210 I_ATTR(
bool, m_reloadOnFileChangeAttrPtr);
217 I_ATTR(
double, m_staleLockTimeAttrPtr);
224 I_ATTR(
double, m_tryLockTimeoutAttrPtr);
231 I_ATTR(
bool, m_enableLockForLoadAttrPtr);
238 bool m_isObjectChanged;
243 bool m_isLoadedFromFile;
245 QTimer m_storingTimer;
247 QFuture<bool> m_storingFuture;
252 mutable std::unique_ptr<istd::IChangeable> m_objectShadowPtr;
254 QFileSystemWatcher m_fileWatcher;
256 QReadWriteLock m_loadSaveMutex;
258 mutable bool m_blockLoadingOnFileChanges;
260 mutable std::unique_ptr<QLockFile> m_lockFilePtr;
261 mutable QReadWriteLock m_fileLockMutex;