![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2010 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: $ $Revision: $ $State: $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 #include <vrvCore/vrvCore.h> 00015 #include <vrvCore/DtDeSettings.h> 00016 #include <vrvUtil/DtVrvFilesystem.h> 00017 #include <makArchives/DtXmlFileIo.h> 00018 #include <boost/signals.hpp> 00019 00020 namespace makVrv 00021 { 00025 class DT_DLL_VRVCORE DtBackupInterface 00026 { 00027 public: 00028 00029 typedef std::vector<std::string> NameList; 00030 00032 DtBackupInterface(); 00033 00035 virtual ~DtBackupInterface(); 00036 00038 virtual bool backupExists() const = 0; 00039 00041 virtual bool factoryExists() const = 0; 00042 00044 virtual void backup() = 0; 00045 00047 virtual void deleteBackup() = 0; 00048 00051 virtual void restore(bool fromFactory = false) = 0; 00052 00054 virtual void getRestorableNames(NameList& names) = 0; 00055 00058 boost::signal<void (DtBackupInterface*)> signal_backupFileChanged; 00059 00060 }; 00061 00062 class DtDeSettings; 00063 00064 00065 00072 template <typename Manager> 00073 class DtManagerBackup : public DtBackupInterface 00074 { 00075 public: 00077 DtManagerBackup(Manager& manager) 00078 : myManager(manager) 00079 { 00080 } 00081 00083 virtual ~DtManagerBackup() 00084 { 00085 } 00086 00088 virtual bool backupExists() const 00089 { 00090 return DtVrvFilesystem::exists(myManager.settings()->backupFilePath()); 00091 } 00092 00094 virtual bool factoryExists() const 00095 { 00096 return DtVrvFilesystem::exists(myManager.settings()->factoryFilePath()); 00097 } 00098 00100 virtual void backup() 00101 { 00102 myManager.exportSettings(myManager.settings()->backupFilePath()); 00103 } 00104 00106 virtual void deleteBackup() 00107 { 00108 DtVrvFilesystem::deleteFile(myManager.settings()->backupFilePath()); 00109 } 00110 00113 virtual void restore(bool fromFactory = false) 00114 { 00115 if(fromFactory) 00116 { 00117 myManager.importSettings(myManager.settings()->factoryFilePath()); 00118 } 00119 else 00120 { 00121 myManager.importSettings(myManager.settings()->backupFilePath()); 00122 } 00123 signal_settingsRestored(); 00124 } 00125 00127 void getRestorableNames(NameList& names) 00128 { 00129 names.push_back(myManager.settings()->name()); 00130 } 00131 00132 boost::signal<void ()> signal_settingsRestored; 00133 00134 protected: 00135 Manager& myManager; 00136 }; 00137 } 00138