VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtRecordSettingsBackup.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtRecordSettingsBackup.h,v $ $Revision: 1.16 $ $State: Exp $
7 ******************************************************************************/
8 
11 
12 #pragma once
13 
14 #ifndef DtRecordSettingsBackup_H
15 #define DtRecordSettingsBackup_H
16 
17 #include <vrvCore/vrvCore.h>
18 #include <vrvCore/DtDe.h>
22 #include <vrvCore/DtDeSettings.h>
24 
25 namespace makVrv
26 {
31  {
32  public:
33  DtRecordSettingsBackupInterface(DtDe& de, const std::string& classType, const std::string& descriptiveName)
34  : myDe(de)
35  , myClassType(classType)
36  , myDescriptiveName(descriptiveName)
37  , myCanBackup(true)
38  {
39  DtDeSettings* settings = DtDeSettingsManager::instance(myDe).findSettings(classType);
40  if (settings)
41  {
42  setFactoryFile(settings->factoryFilePath());
43  }
45  }
46 
48  : myDe(orig.myDe)
49  , myClassType(orig.myClassType)
50  , myCanBackup(orig.myCanBackup)
51  , myDescriptiveName(orig.myDescriptiveName)
52  {
53  }
54 
56  {
57  }
58 
59  std::string backupClassType() const
60  {
61  return myClassType;
62  }
63 
64  std::string backupName() const
65  {
66  return myDescriptiveName;
67  }
68 
69  virtual void backup()
70  {
71  if (canBackup())
72  {
74  }
75  }
76 
77  void setCanBackup(bool b)
78  {
79  myCanBackup = b;
80  }
81 
82  bool canBackup() const
83  {
84  return myCanBackup;
85  }
86 
87  protected:
89  std::string myClassType;
90  std::string myDescriptiveName;
92  };
93 
97  template <typename SettingsClass, typename ArchiveClass>
99  {
100  public:
101  DtRecordSettingsBackup(DtDe& de, SettingsClass* parent, const std::string& classType, const std::string& descriptiveName)
102  : DtRecordSettingsBackupInterface(de, classType, descriptiveName)
103  , myParent(parent)
104  {
105  }
106 
109  , myParent(orig.myParent)
110  {
111  }
112 
114  {
115  }
116 
117  void restore(const DtSettingsBackup* from)
118  {
119  bool can = canBackup();
120 
121  setCanBackup(false);
122 
123  myParent->setFromRecord(
125 
126  setCanBackup(can);
127  }
128 
130  {
132  }
133 
134  void write(boost::archive::xml_oarchive& ar)
135  {
136  ArchiveClass rec;
137 
138  myParent->getRecord(rec);
139 
140  ar << boost::serialization::make_nvp(myClassType.c_str(), rec);
141  }
142 
143  void read(boost::archive::xml_iarchive& ar)
144  {
145  ar >> boost::serialization::make_nvp(myClassType.c_str(), myRestoredRecord);
146  }
147 
148  const ArchiveClass& restoredRecord() const
149  {
150  return myRestoredRecord;
151  }
152 
153  protected:
154  ArchiveClass myRestoredRecord;
155  SettingsClass* myParent;
156  };
157 
161  template <typename SettingsClass, typename ArchiveClass>
163  {
164  public:
165 
166  DtSharedRecordSettingsBackup(DtSharedSettingsManager& manager, const std::string& classType, const std::string& descriptiveName)
167  : myManager(manager)
168  , myClassType(classType)
169  , myCanBackup(true)
170  , myDescriptiveName(descriptiveName)
171  {
172  }
173 
175  {
176  }
177 
178  void restore(const DtSettingsBackup* from)
179  {
180  bool can = canBackup();
181 
182  myCanBackup = false;
183 
185 
187 
188  myCanBackup = can;
189  }
190 
191  std::string backupClassType() const
192  {
193  return myClassType;
194  }
195 
196  std::string backupName() const
197  {
198  return myDescriptiveName;
199  }
200 
202  {
204  }
205 
206  void write(boost::archive::xml_oarchive& ar)
207  {
208  ar << boost::serialization::make_nvp(backupClassType().c_str(), myRestoredRecord);
209  }
210 
211  void read(boost::archive::xml_iarchive& ar)
212  {
213  ar >> boost::serialization::make_nvp(backupClassType().c_str(), myRestoredRecord);
214  }
215 
216  const ArchiveClass& restoredRecord() const
217  {
218  return myRestoredRecord;
219  }
220 
221  void backup(const ArchiveClass& rec)
222  {
223  if (myCanBackup)
224  {
225  myRestoredRecord = rec;
227  }
228  }
229 
230  void setCanBackup(bool b)
231  {
232  myCanBackup = b;
233  }
234 
235  bool canBackup() const
236  {
237  return myCanBackup;
238  }
239 
240  protected:
242  ArchiveClass myRestoredRecord;
244  std::string myClassType;
245  std::string myDescriptiveName;
246  };
247 }
248 
249 #endif

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)