VR-Forces Development_Version 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/DtDe.h>
21 
22 namespace makVrv
23 {
28  {
29  public:
30  DtRecordSettingsBackupInterface(DtDe& de, const std::string& classType, const std::string& descriptiveName)
31  : myDe(de)
32  , myClassType(classType)
33  , myDescriptiveName(descriptiveName)
34  , myCanBackup(true)
35  {
36  DtDeSettings* settings = DtDeSettingsManager::instance(myDe).findSettings(classType);
37  if (settings)
38  {
39  setFactoryFile(settings->factoryFilePath());
40  }
42  }
43 
45  : myDe(orig.myDe)
46  , myClassType(orig.myClassType)
47  , myCanBackup(orig.myCanBackup)
48  , myDescriptiveName(orig.myDescriptiveName)
49  {
50  }
51 
53  {
54  }
55 
56  std::string backupClassType() const
57  {
58  return myClassType;
59  }
60 
61  std::string backupName() const
62  {
63  return myDescriptiveName;
64  }
65 
66  virtual void backup()
67  {
68  if (canBackup())
69  {
71  }
72  }
73 
74  void setCanBackup(bool b)
75  {
76  myCanBackup = b;
77  }
78 
79  bool canBackup() const
80  {
81  return myCanBackup;
82  }
83 
84  protected:
86  std::string myClassType;
87  std::string myDescriptiveName;
89  };
90 
94  template <typename SettingsClass, typename ArchiveClass>
96  {
97  public:
98  DtRecordSettingsBackup(DtDe& de, SettingsClass* parent, const std::string& classType, const std::string& descriptiveName)
99  : DtRecordSettingsBackupInterface(de, classType, descriptiveName)
100  , myParent(parent)
101  {
102  }
103 
106  , myParent(orig.myParent)
107  {
108  }
109 
111  {
112  }
113 
114  void restore(const DtSettingsBackup* from)
115  {
116  bool can = canBackup();
117 
118  setCanBackup(false);
119 
120  myParent->setFromRecord(
122 
123  setCanBackup(can);
124  }
125 
127  {
129  }
130 
131  void write(boost::archive::xml_oarchive& ar)
132  {
133  ArchiveClass rec;
134 
135  myParent->getRecord(rec);
136 
137  ar << boost::serialization::make_nvp(myClassType.c_str(), rec);
138  }
139 
140  void read(boost::archive::xml_iarchive& ar)
141  {
142  ar >> boost::serialization::make_nvp(myClassType.c_str(), myRestoredRecord);
143  }
144 
145  const ArchiveClass& restoredRecord() const
146  {
147  return myRestoredRecord;
148  }
149 
150  protected:
151  ArchiveClass myRestoredRecord;
152  SettingsClass* myParent;
153  };
154 
158  template <typename SettingsClass, typename ArchiveClass>
160  {
161  public:
162 
163  DtSharedRecordSettingsBackup(DtSharedSettingsManager& manager, const std::string& classType, const std::string& descriptiveName)
164  : myManager(manager)
165  , myClassType(classType)
166  , myCanBackup(true)
167  , myDescriptiveName(descriptiveName)
168  {
169  }
170 
172  {
173  }
174 
175  void restore(const DtSettingsBackup* from)
176  {
177  bool can = canBackup();
178 
179  myCanBackup = false;
180 
182 
184 
185  myCanBackup = can;
186  }
187 
188  std::string backupClassType() const
189  {
190  return myClassType;
191  }
192 
193  std::string backupName() const
194  {
195  return myDescriptiveName;
196  }
197 
199  {
201  }
202 
203  void write(boost::archive::xml_oarchive& ar)
204  {
205  ar << boost::serialization::make_nvp(backupClassType().c_str(), myRestoredRecord);
206  }
207 
208  void read(boost::archive::xml_iarchive& ar)
209  {
210  ar >> boost::serialization::make_nvp(backupClassType().c_str(), myRestoredRecord);
211  }
212 
213  const ArchiveClass& restoredRecord() const
214  {
215  return myRestoredRecord;
216  }
217 
218  void backup(const ArchiveClass& rec)
219  {
220  if (myCanBackup)
221  {
222  myRestoredRecord = rec;
224  }
225  }
226 
227  void setCanBackup(bool b)
228  {
229  myCanBackup = b;
230  }
231 
232  bool canBackup() const
233  {
234  return myCanBackup;
235  }
236 
237  protected:
239  ArchiveClass myRestoredRecord;
241  std::string myClassType;
242  std::string myDescriptiveName;
243  };
244 }
245 
246 #endif

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)