VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtBackupInterface.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvCore/DtDeSettings.h>
12 #include <vrvUtil/signalslib.h>
13 
14 namespace makVrv
15 {
20  {
21  public:
22 
23  typedef std::vector<std::string> NameList;
24 
27 
29  virtual ~DtBackupInterface();
30 
32  virtual bool backupFileExists() const = 0;
33 
35  virtual bool factoryFileExists() const = 0;
36 
38  virtual bool backupDirExists() const = 0;
39 
41  virtual bool factoryDirExists() const = 0;
42 
44  virtual void backup() = 0;
45 
47  virtual void deleteBackup() = 0;
48 
51  virtual void restore(bool fromFactory = false) = 0;
52 
54  virtual void getRestorableNames(NameList& names) = 0;
55 
58  boost::signalslib::signal<void (DtBackupInterface*)> signal_backupFileChanged;
59 
60  };
61 
62  class DtDeSettings;
63 
64 
65 
72  template <typename Manager>
74  {
75  public:
77  DtManagerBackup(Manager& manager)
78  : myManager(manager)
79  {
80  }
81 
83  virtual ~DtManagerBackup()
84  {
85  }
86 
88  virtual bool backupFileExists() const
89  {
90  return DtVrvFilesystem::exists(myManager.settings()->backupFilePath());
91  }
92 
94  virtual bool factoryFileExists() const
95  {
96  return DtVrvFilesystem::exists(myManager.settings()->factoryFilePath());
97  }
98 
100  virtual bool backupDirExists() const
101  {
102  return DtVrvFilesystem::exists(myManager.settings()->backupDirPath());
103  }
104 
106  virtual bool factoryDirExists() const
107  {
108  return DtVrvFilesystem::exists(myManager.settings()->factoryDirPath());
109  }
110 
112  virtual void backup()
113  {
114  myManager.exportSettings(myManager.settings()->backupFilePath());
115  }
116 
118  virtual void deleteBackup()
119  {
120  DtVrvFilesystem::deleteFile(myManager.settings()->backupFilePath());
121  }
122 
125  virtual void restore(bool fromFactory = false)
126  {
127  if(fromFactory)
128  {
129  myManager.importSettings(myManager.settings()->factoryFilePath());
130  }
131  else
132  {
133  myManager.importSettings(myManager.settings()->backupFilePath());
134  }
136  }
137 
140  {
141  names.push_back(myManager.settings()->name());
142  }
143 
144  boost::signalslib::signal<void ()> signal_settingsRestored;
145 
146  protected:
147  Manager& myManager;
148  };
149 }
150 
virtual bool backupFileExists() const
Check for a the existence of the backup state?
Definition: DtBackupInterface.h:88
virtual bool factoryFileExists() const
Check for a the existence of the factory shipped state?
Definition: DtBackupInterface.h:94
The common template version of the backup interface. The manager must implement this interface: virtu...
Definition: DtBackupInterface.h:73
virtual bool factoryDirExists() const
Check for a the existence of the factory shipped state?
Definition: DtBackupInterface.h:106
void getRestorableNames(NameList &names)
Get the names of states restore will affect.
Definition: DtBackupInterface.h:139
boost::signalslib::signal< void()> signal_settingsRestored
Definition: DtBackupInterface.h:144
static bool deleteFile(const std::string &file)
Delete the given file.
DtManagerBackup(Manager &manager)
CTOR.
Definition: DtBackupInterface.h:77
static bool exists(const std::string &path)
Check if the given path is exists.
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
virtual void restore(bool fromFactory=false)
Restore the state, either from the backup (default) or from the factory.
Definition: DtBackupInterface.h:125
virtual void deleteBackup()
Delete the current backup state.
Definition: DtBackupInterface.h:118
boost::signalslib::signal< void(DtBackupInterface *)> signal_backupFileChanged
This signal should be emitted when the backup file is created, written to, or destroyed.
Definition: DtBackupInterface.h:58
virtual void backup()
Save the current state. This should overwrite the existing state.
Definition: DtBackupInterface.h:112
Settings class for reading and writing settings to/from files.
Definition: DtDeSettings.h:29
Manager & myManager
Definition: DtBackupInterface.h:147
virtual bool backupDirExists() const
Check for a the existence of the backup state?
Definition: DtBackupInterface.h:100
Contains the DtDeSettings class declaration.
The backup interface, is used by components to control backups of a state.
Definition: DtBackupInterface.h:19
virtual ~DtManagerBackup()
DTOR.
Definition: DtBackupInterface.h:83
std::vector< std::string > NameList
Definition: DtBackupInterface.h:23

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)