VR-Forces 4.8 Class Documentation
 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) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 #include <vrvCore/DtDeSettings.h>
15 #include <boost/signals.hpp>
16 
17 namespace makVrv
18 {
23  {
24  public:
25 
26  typedef std::vector<std::string> NameList;
27 
30 
32  virtual ~DtBackupInterface();
33 
35  virtual bool backupFileExists() const = 0;
36 
38  virtual bool factoryFileExists() const = 0;
39 
41  virtual bool backupDirExists() const = 0;
42 
44  virtual bool factoryDirExists() const = 0;
45 
47  virtual void backup() = 0;
48 
50  virtual void deleteBackup() = 0;
51 
54  virtual void restore(bool fromFactory = false) = 0;
55 
57  virtual void getRestorableNames(NameList& names) = 0;
58 
61  boost::signal<void (DtBackupInterface*)> signal_backupFileChanged;
62 
63  };
64 
65  class DtDeSettings;
66 
67 
68 
75  template <typename Manager>
77  {
78  public:
80  DtManagerBackup(Manager& manager)
81  : myManager(manager)
82  {
83  }
84 
86  virtual ~DtManagerBackup()
87  {
88  }
89 
91  virtual bool backupFileExists() const
92  {
93  return DtVrvFilesystem::exists(myManager.settings()->backupFilePath());
94  }
95 
97  virtual bool factoryFileExists() const
98  {
99  return DtVrvFilesystem::exists(myManager.settings()->factoryFilePath());
100  }
101 
103  virtual bool backupDirExists() const
104  {
105  return DtVrvFilesystem::exists(myManager.settings()->backupDirPath());
106  }
107 
109  virtual bool factoryDirExists() const
110  {
111  return DtVrvFilesystem::exists(myManager.settings()->factoryDirPath());
112  }
113 
115  virtual void backup()
116  {
117  myManager.exportSettings(myManager.settings()->backupFilePath());
118  }
119 
121  virtual void deleteBackup()
122  {
123  DtVrvFilesystem::deleteFile(myManager.settings()->backupFilePath());
124  }
125 
128  virtual void restore(bool fromFactory = false)
129  {
130  if(fromFactory)
131  {
132  myManager.importSettings(myManager.settings()->factoryFilePath());
133  }
134  else
135  {
136  myManager.importSettings(myManager.settings()->backupFilePath());
137  }
139  }
140 
143  {
144  names.push_back(myManager.settings()->name());
145  }
146 
147  boost::signal<void ()> signal_settingsRestored;
148 
149  protected:
150  Manager& myManager;
151  };
152 }
153 
virtual bool backupFileExists() const
Check for a the existence of the backup state?
Definition: DtBackupInterface.h:91
boost::signal< void()> signal_settingsRestored
Definition: DtBackupInterface.h:147
virtual bool factoryFileExists() const
Check for a the existence of the factory shipped state?
Definition: DtBackupInterface.h:97
The common template version of the backup interface.
Definition: DtBackupInterface.h:76
virtual bool factoryDirExists() const
Check for a the existence of the factory shipped state?
Definition: DtBackupInterface.h:109
void getRestorableNames(NameList &names)
Get the names of states restore will affect.
Definition: DtBackupInterface.h:142
static bool deleteFile(const std::string &file)
Delete the given file.
DtManagerBackup(Manager &manager)
CTOR.
Definition: DtBackupInterface.h:80
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:128
virtual void deleteBackup()
Delete the current backup state.
Definition: DtBackupInterface.h:121
virtual void backup()
Save the current state. This should overwrite the existing state.
Definition: DtBackupInterface.h:115
Settings class for reading and writing settings to/from files.
Definition: DtDeSettings.h:29
boost::signal< void(DtBackupInterface *)> signal_backupFileChanged
This signal should be emitted when the backup file is created, written to, or destroyed.
Definition: DtBackupInterface.h:61
Manager & myManager
Definition: DtBackupInterface.h:150
virtual bool backupDirExists() const
Check for a the existence of the backup state?
Definition: DtBackupInterface.h:103
Contains the DtDeSettings class declaration.
The backup interface, is used by components to control backups of a state.
Definition: DtBackupInterface.h:22
virtual ~DtManagerBackup()
DTOR.
Definition: DtBackupInterface.h:86
std::vector< std::string > NameList
Definition: DtBackupInterface.h:26

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)