74 I_ASSIGN(m_objectCompPtr,
"Object",
"Object will be restored and stored",
true,
"Object");
75 I_ASSIGN_TO(m_objectModelCompPtr, m_objectCompPtr,
false);
76 I_ASSIGN_TO(m_serializeableObjectCompPtr, m_objectCompPtr,
false);
77 I_ASSIGN(m_fileLoaderCompPtr,
"FileLoader",
"File loader used to store and restore object",
true,
"FileLoader");
78 I_ASSIGN(m_filePathCompPtr,
"FilePath",
"File path where object data will be stored if non anonymous loader is used",
false,
"FilePath");
79 I_ASSIGN_TO(m_filePathModelCompPtr, m_filePathCompPtr,
false);
80 I_ASSIGN(m_restoreOnBeginAttrPtr,
"RestoreOnBegin",
"Flag indicating that object should be restored on begin",
true,
true);
81 I_ASSIGN(m_storeOnBeginAttrPtr,
"StoreOnBegin",
"Flag indicating that object should be stored on begin if the storage file doesn't exist",
true,
false);
82 I_ASSIGN(m_storeOnEndAttrPtr,
"StoreOnEnd",
"Flag indicating that object should be stored on end",
true,
true);
83 I_ASSIGN(m_storeOnChangeAttrPtr,
"StoreOnChange",
"Flag indicating that object should be stored on each data change",
true,
false);
84 I_ASSIGN(m_storeIntervalAttrPtr,
"StoreInterval",
"Time interval in seconds for automatic object storing",
false, 10);
85 I_ASSIGN(m_reloadOnFileChangeAttrPtr,
"AutoReload",
"Update data model if the file was changed",
true,
false);
86 I_ASSIGN(m_runtimeStatusCompPtr,
"RuntimeStatus",
"Application's runtime status",
false,
"RuntimeStatus");
87 I_ASSIGN_TO(m_runtimeStatusModelCompPtr, m_runtimeStatusCompPtr,
false);
88 I_ASSIGN(m_staleLockTimeAttrPtr,
"StaleLockTime",
"Time in seconds after which a lock file is considered stale.",
true, 30.0);
89 I_ASSIGN(m_tryLockTimeoutAttrPtr,
"TryLockTimeout",
"Lock function will wait for at most TryLockTimeout seconds for the lock file to become available."
90 "\nNOTE: Lock will wait forever until the lock file can be locked when set to negative",
true, 0.0);
91 I_ASSIGN(m_enableLockForLoadAttrPtr,
"EnableLockForRead",
"When enabled lock is also set when reading from file."
92 "\nNOTE: On NTFS file systems, ownership and permissions checking is disabled (in QT) by default for performance reasons."
93 "\nEnable this flag when you are known what you are doing.",
true,
false);
129 void OnFileContentsChanged(
const QString& path);
135 bool TryStartIntervalStore();
137 bool LockFile(
const QString& filePath,
bool store)
const;
138 void UnlockFile()
const;
165 I_ATTR(
bool, m_restoreOnBeginAttrPtr);
171 I_ATTR(
bool, m_storeOnBeginAttrPtr);
176 I_ATTR(
bool, m_storeOnEndAttrPtr);
181 I_ATTR(
bool, m_storeOnChangeAttrPtr);
187 I_ATTR(
double, m_storeIntervalAttrPtr);
192 I_ATTR(
bool, m_reloadOnFileChangeAttrPtr);
199 I_ATTR(
double, m_staleLockTimeAttrPtr);
206 I_ATTR(
double, m_tryLockTimeoutAttrPtr);
213 I_ATTR(
bool, m_enableLockForLoadAttrPtr);
220 std::atomic<bool> m_isObjectChanged;
225 bool m_isLoadedFromFile;
227 QTimer m_storingTimer;
229 QFuture<void> m_storingFuture;
236 QFileSystemWatcher m_fileWatcher;
238 QMutex m_loadSaveMutex;
240 mutable bool m_blockLoadingOnFileChanges;
242#if QT_VERSION >= 0x050000
245 mutable QMutex m_fileLockMutex;