FOX/ObjCryst++  2022
Undo.cpp
1 /* ObjCryst++ Object-Oriented Crystallographic Library
2  (c) 2000- Vincent Favre-Nicolin vincefn@gmail.com
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #include <cstdlib>
20 #include <boost/date_time.hpp>
21 #include <sstream>
22 #include "ObjCryst/ObjCryst/Undo.h"
23 
24 namespace ObjCryst
25 {
27 
29 //
30 // XMLConfig
31 //
34 {
35  mClock.Click();
36  mTime = boost::posix_time::second_clock::local_time();
37 
38  for(std::vector<Crystal*>::const_iterator pos=gCrystalRegistry.begin();pos!=gCrystalRegistry.end();++pos)
39  {
40  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
41  stringstream ss;
42  (*pos)->XMLOutput(ss,0);
43  mvpCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
44  }
45 
46  for(std::vector<DiffractionDataSingleCrystal*>::const_iterator pos=gDiffractionDataSingleCrystalRegistry.begin();pos!=gDiffractionDataSingleCrystalRegistry.end();++pos)
47  {
48  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
49  stringstream ss;
50  (*pos)->XMLOutput(ss,0);
51  mvpDiffractionDataSingleCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
52  }
53 
54  for(std::vector<PowderPattern*>::const_iterator pos=gPowderPatternRegistry.begin();pos!=gPowderPatternRegistry.end();++pos)
55  {
56  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
57  stringstream ss;
58  (*pos)->XMLOutput(ss,0);
59  mvpPowderPatternXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
60  }
61 
62  for(std::vector<OptimizationObj*>::const_iterator pos=gOptimizationObjRegistry.begin();pos!=gOptimizationObjRegistry.end();++pos)
63  {
64  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
65  stringstream ss;
66  (*pos)->XMLOutput(ss,0);
67  mvpOptimizationObjXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
68  }
69  mClock.Click();
70 }
71 
73 {
74  mTime = boost::posix_time::second_clock::local_time();
75 
76  for(std::vector<Crystal*>::const_iterator pos=gCrystalRegistry.begin();pos!=gCrystalRegistry.end();++pos)
77  {
78  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(&old): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
79  std::map<Crystal*, boost::shared_ptr<std::string> >::const_iterator pos2 = old.mvpCrystalXML.find(*pos);
80  if(pos2 != old.mvpCrystalXML.end())
81  {
82  if((*pos)->GetClockMaster() <= old.GetClock())
83  mvpCrystalXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
84  else
85  {
86  stringstream ss;
87  (*pos)->XMLOutput(ss,0);
88  if(ss.str() == *(pos2->second))
89  mvpCrystalXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
90  else
91  mvpCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
92  }
93  }
94  else
95  {
96  stringstream ss;
97  (*pos)->XMLOutput(ss,0);
98  mvpCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
99  }
100  }
101 
102  for(std::vector<DiffractionDataSingleCrystal*>::const_iterator pos=gDiffractionDataSingleCrystalRegistry.begin();pos!=gDiffractionDataSingleCrystalRegistry.end();++pos)
103  {
104  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(&old): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
105  std::map<DiffractionDataSingleCrystal*, boost::shared_ptr<std::string> >::const_iterator pos2 = old.mvpDiffractionDataSingleCrystalXML.find(*pos);
106  if(pos2 != old.mvpDiffractionDataSingleCrystalXML.end())
107  {
108  if((*pos)->GetClockMaster() <= old.GetClock())
109  mvpDiffractionDataSingleCrystalXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
110  else
111  {
112  stringstream ss;
113  (*pos)->XMLOutput(ss,0);
114  if(ss.str() == *(pos2->second))
115  mvpDiffractionDataSingleCrystalXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
116  else
117  mvpDiffractionDataSingleCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
118  }
119  }
120  else
121  {
122  stringstream ss;
123  (*pos)->XMLOutput(ss,0);
124  mvpDiffractionDataSingleCrystalXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
125  }
126  }
127 
128  for(std::vector<PowderPattern*>::const_iterator pos=gPowderPatternRegistry.begin();pos!=gPowderPatternRegistry.end();++pos)
129  {
130  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(&old): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
131  std::map<PowderPattern*, boost::shared_ptr<std::string> >::const_iterator pos2 = old.mvpPowderPatternXML.find(*pos);
132  if(pos2 != old.mvpPowderPatternXML.end())
133  {
134  if((*pos)->GetClockMaster() <= old.GetClock())
135  mvpPowderPatternXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
136  else
137  {
138  stringstream ss;
139  (*pos)->XMLOutput(ss,0);
140  if(ss.str() == *(pos2->second))
141  mvpPowderPatternXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
142  else
143  mvpPowderPatternXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
144  }
145  }
146  else
147  {
148  stringstream ss;
149  (*pos)->XMLOutput(ss,0);
150  mvpPowderPatternXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
151  }
152  }
153 
154  for(std::vector<OptimizationObj*>::const_iterator pos=gOptimizationObjRegistry.begin();pos!=gOptimizationObjRegistry.end();++pos)
155  {
156  VFN_DEBUG_MESSAGE("XMLConfig::XMLConfig(&old): storing "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
157  std::map<OptimizationObj*, boost::shared_ptr<std::string> >::const_iterator pos2 = old.mvpOptimizationObjXML.find(*pos);
158  if(pos2 != old.mvpOptimizationObjXML.end())
159  {
160  stringstream ss;
161  (*pos)->XMLOutput(ss,0);
162  if(ss.str() == *(pos2->second))
163  mvpOptimizationObjXML[*pos] = boost::shared_ptr<std::string>(pos2->second);
164  else
165  mvpOptimizationObjXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
166  }
167  else
168  {
169  stringstream ss;
170  (*pos)->XMLOutput(ss,0);
171  mvpOptimizationObjXML[*pos] = boost::shared_ptr<std::string>(new std::string(ss.str()));
172  }
173  }
174  mClock.Click();
175 }
176 
178 {
179  VFN_DEBUG_ENTRY("XMLConfig::Restore()", 10)
180  std::list<RefinableObj*> vpRefObjUpdated;
181  std::list<OptimizationObj*> vpOptimObjUpdated;
182  std::list<RefinableObj*> vpRefObjDeleted;
183  std::list<OptimizationObj*> vpOptimObjDeleted;
184  // Restore objects configuration and load new ones
185  for(std::map<Crystal*, boost::shared_ptr<std::string> >::const_iterator pos= mvpCrystalXML.begin(); pos!=mvpCrystalXML.end();++pos)
186  {
187  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): found "<< pos->first->GetClassName() << ":" << pos->first->GetName(), 10)
188  Crystal *p;
189  if(gCrystalRegistry.Find(pos->first) >= 0)
190  {
191  p = pos->first;
192  stringstream ss;
193  p->XMLOutput(ss,0);
194  if(ss.str()== *(pos->second)) continue;
195  }
196  else
197  p = new Crystal;
198  stringstream ss;
199  ss << *(pos->second);
200  VFN_DEBUG_MESSAGE("XMLConfig::Restore():Crystal:xml="<<*(pos->second), 5)
201  VFN_DEBUG_MESSAGE("XMLConfig::Restore():Crystal:xml="<<ss.str(), 5)
202  XMLCrystTag tag(ss);
203  VFN_DEBUG_MESSAGE("XMLConfig::Restore():Crystal:tag="<<tag, 5)
204  VFN_DEBUG_ENTRY("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
205  p->XMLInput(ss,tag);
206  VFN_DEBUG_EXIT("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
207  vpRefObjUpdated.push_back(p);
208  }
209 
210  for(std::map<DiffractionDataSingleCrystal*, boost::shared_ptr<std::string> >::const_iterator pos= mvpDiffractionDataSingleCrystalXML.begin(); pos!=mvpDiffractionDataSingleCrystalXML.end();++pos)
211  {
212  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): found "<< pos->first->GetClassName() << ":" << pos->first->GetName(), 10)
214  if(gDiffractionDataSingleCrystalRegistry.Find(pos->first) >= 0)
215  {
216  p = pos->first;
217  stringstream ss;
218  p->XMLOutput(ss,0);
219  if(ss.str()== *(pos->second)) continue;
220  }
221  else
223  stringstream ss;
224  ss << pos->second;
225  XMLCrystTag tag(ss);
226  VFN_DEBUG_ENTRY("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
227  p->XMLInput(ss,tag);
228  VFN_DEBUG_EXIT("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
229  vpRefObjUpdated.push_back(p);
230  }
231 
232  for(std::map<PowderPattern*, boost::shared_ptr<std::string> >::const_iterator pos= mvpPowderPatternXML.begin(); pos!=mvpPowderPatternXML.end();++pos)
233  {
234  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): found "<< pos->first->GetClassName() << ":" << pos->first->GetName(), 10)
235  PowderPattern *p;
236  if(gPowderPatternRegistry.Find(pos->first) >= 0)
237  {
238  p = pos->first;
239  stringstream ss;
240  p->XMLOutput(ss,0);
241  if(ss.str()== *(pos->second)) continue;
242  }
243  else
244  p = new PowderPattern;
245  stringstream ss;
246  ss << pos->second;
247  XMLCrystTag tag(ss);
248  VFN_DEBUG_ENTRY("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
249  p->XMLInput(ss,tag);
250  VFN_DEBUG_EXIT("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
251  vpRefObjUpdated.push_back(p);
252  }
253 
254  for(std::map<OptimizationObj*, boost::shared_ptr<std::string> >::const_iterator pos= mvpOptimizationObjXML.begin(); pos!=mvpOptimizationObjXML.end();++pos)
255  {
256  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): found "<< pos->first->GetClassName() << ":" << pos->first->GetName(), 10)
257  OptimizationObj *p;
258  if(gOptimizationObjRegistry.Find(pos->first) >= 0)
259  {
260  p = pos->first;
261  stringstream ss;
262  p->XMLOutput(ss,0);
263  if(ss.str()== *(pos->second)) continue;
264  }
265  else
266  p = new MonteCarloObj;
267  stringstream ss;
268  ss << pos->second;
269  XMLCrystTag tag(ss);
270  VFN_DEBUG_ENTRY("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
271  p->XMLInput(ss,tag);
272  VFN_DEBUG_EXIT("XMLConfig::Restore()"<<p->GetClassName()<<":"<<p->GetName(), 10)
273  vpOptimObjUpdated.push_back(p);
274  }
275 
276  // List objects which don't exist in the loaded configuration and which should be deleted
277  for(std::vector<Crystal*>::const_iterator pos=gCrystalRegistry.begin();pos!=gCrystalRegistry.end();++pos)
278  if(mvpCrystalXML.find(*pos) == mvpCrystalXML.end()) vpRefObjDeleted.push_back(*pos);
279 
280  for(std::vector<DiffractionDataSingleCrystal*>::const_iterator pos=gDiffractionDataSingleCrystalRegistry.begin();pos!=gDiffractionDataSingleCrystalRegistry.end();++pos)
281  if(mvpDiffractionDataSingleCrystalXML.find(*pos) == mvpDiffractionDataSingleCrystalXML.end()) vpRefObjDeleted.push_back(*pos);
282 
283  for(std::vector<PowderPattern*>::const_iterator pos=gPowderPatternRegistry.begin();pos!=gPowderPatternRegistry.end();++pos)
284  if(mvpPowderPatternXML.find(*pos) == mvpPowderPatternXML.end()) vpRefObjDeleted.push_back(*pos);
285 
286  for(std::vector<OptimizationObj*>::const_iterator pos=gOptimizationObjRegistry.begin();pos!=gOptimizationObjRegistry.end();++pos)
287  if(mvpOptimizationObjXML.find(*pos) == mvpOptimizationObjXML.end()) vpOptimObjDeleted.push_back(*pos);
288 
289  // Objects are destroyed after listing all, to avoid unvalidating the ObjRegistry containers (std::vector)
290  // First optimisation obj, then diffraction data, then crystals
291  for(std::list<OptimizationObj*>::const_iterator pos = vpOptimObjDeleted.begin();pos!=vpOptimObjDeleted.end();++pos)
292  {
293  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): deleting "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
294  delete *pos;
295  }
296  for(std::list<RefinableObj*>::const_reverse_iterator pos = vpRefObjDeleted.rbegin();pos!=vpRefObjDeleted.rend();++pos)
297  {
298  VFN_DEBUG_MESSAGE("XMLConfig::Restore(): deleting "<< (*pos)->GetClassName() << ":" << (*pos)->GetName(), 10)
299  delete *pos;
300  }
301 
302  // Update display. Order should not matter
303  for(std::list<OptimizationObj*>::const_iterator pos = vpOptimObjUpdated.begin() ; pos!=vpOptimObjUpdated.end() ; ++pos) (*pos)->UpdateDisplay();
304  for(std::list<RefinableObj*>::const_iterator pos = vpRefObjUpdated.begin() ; pos!=vpRefObjUpdated.end() ; ++pos) (*pos)->UpdateDisplay();
305  VFN_DEBUG_EXIT("XMLConfig::Restore()", 10)
306 }
307 
309 {
310  if(mvpCrystalXML.size() != rhs.mvpCrystalXML.size()) return false;
311  if(mvpDiffractionDataSingleCrystalXML.size() != rhs.mvpDiffractionDataSingleCrystalXML.size()) return false;
312  if(mvpPowderPatternXML.size() != rhs.mvpPowderPatternXML.size()) return false;
313  if(mvpOptimizationObjXML.size() != rhs.mvpOptimizationObjXML.size()) return false;
314 
315  for(std::map<Crystal*, boost::shared_ptr<std::string> >::const_iterator pos = mvpCrystalXML.begin(); pos!=mvpCrystalXML.end(); pos++)
316  {
317  std::map<Crystal*, boost::shared_ptr<std::string> >::const_iterator pos2 = rhs.mvpCrystalXML.find(pos->first);
318  if(pos2==rhs.mvpCrystalXML.end()) return false;
319  if(*(pos->second) != *(pos2->second)) return false;
320  }
321 
322  for(std::map<DiffractionDataSingleCrystal*, boost::shared_ptr<std::string> >::const_iterator pos = mvpDiffractionDataSingleCrystalXML.begin(); pos!=mvpDiffractionDataSingleCrystalXML.end(); pos++)
323  {
324  std::map<DiffractionDataSingleCrystal*, boost::shared_ptr<std::string> >::const_iterator pos2 = rhs.mvpDiffractionDataSingleCrystalXML.find(pos->first);
325  if(pos2==rhs.mvpDiffractionDataSingleCrystalXML.end()) return false;
326  if(*(pos->second) != *(pos2->second)) return false;
327  }
328 
329  for(std::map<PowderPattern*, boost::shared_ptr<std::string> >::const_iterator pos = mvpPowderPatternXML.begin(); pos!=mvpPowderPatternXML.end(); pos++)
330  {
331  std::map<PowderPattern*, boost::shared_ptr<std::string> >::const_iterator pos2 = rhs.mvpPowderPatternXML.find(pos->first);
332  if(pos2==rhs.mvpPowderPatternXML.end()) return false;
333  if(*(pos->second) != *(pos2->second)) return false;
334  }
335 
336  for(std::map<OptimizationObj*, boost::shared_ptr<std::string> >::const_iterator pos = mvpOptimizationObjXML.begin(); pos!=mvpOptimizationObjXML.end(); pos++)
337  {
338  std::map<OptimizationObj*, boost::shared_ptr<std::string> >::const_iterator pos2 = rhs.mvpOptimizationObjXML.find(pos->first);
339  if(pos2==rhs.mvpOptimizationObjXML.end()) return false;
340  if(*(pos->second) != *(pos2->second)) return false;
341  }
342  return true;
343 }
344 
346 {
347  return !(this->operator==(rhs));
348 }
349 
351 
352 
354 //
355 // XMLConfigHistory
356 //
359 mMaxNb(maxnb), mpCurrentConfig(), mLock(false)
360 {}
361 
363 {
364  if(mLock) return false;
365  mLock=true;
366  VFN_DEBUG_ENTRY("XMLConfigHistory::Store()", 10)
367  if(mvpConfig.size()==0) mvpConfig.push_front(boost::shared_ptr<XMLConfig>(new XMLConfig));
368  else
369  {
370  boost::shared_ptr<XMLConfig> previous = mpCurrentConfig;
371  if(mpCurrentConfig==NULL) // C++11 could use nullptr
372  previous = mvpConfig.front();
373  boost::shared_ptr<XMLConfig> newconf(new XMLConfig(*previous));
374  if(*newconf == *previous)
375  {
376  VFN_DEBUG_EXIT("XMLConfigHistory::Store(): nothing new", 10)
377  mLock=false;
378  return false;
379  }
380  mvpConfig.push_front(newconf);
381  }
382  mpCurrentConfig = boost::shared_ptr<XMLConfig>();
383  if(mvpConfig.size()>mMaxNb) mvpConfig.pop_back();
384  (*fpObjCrystInformUser)("XMLConfigHistory::Store()");
385 
386  VFN_DEBUG_EXIT("XMLConfigHistory::Store(): new config", 10)
387  mLock=false;
388  return true;
389 }
390 
391 void XMLConfigHistory::Restore(boost::shared_ptr<XMLConfig> &p)
392 {
393  mLock=true;
394  p->Restore();
395  mpCurrentConfig = p;
396  mLock=false;
397 }
398 
399 std::list<boost::shared_ptr<XMLConfig> > XMLConfigHistory::GetList() { return mvpConfig;}
400 
401 const std::list<boost::shared_ptr<XMLConfig> > XMLConfigHistory::GetList() const { return mvpConfig;}
402 
404 {
405  if(mvpConfig.size()==0) return false;
406  if(mpCurrentConfig == mvpConfig.back())
407  {
408  fpObjCrystInformUser("XMLConfigHistory::Previous(): already at last stored configuration");
409  return false;
410  }
411  mLock=true;
412  boost::shared_ptr<XMLConfig> p;
413  if(mpCurrentConfig==NULL) p = mvpConfig.front();
414  else
415  {
416  std::list<boost::shared_ptr<XMLConfig> >::const_iterator pos;
417  for(pos=mvpConfig.begin();pos!=mvpConfig.end();++pos)
418  if(*pos == mpCurrentConfig) {++pos ; break;}
419  p = *pos;
420  }
421  (*fpObjCrystInformUser)("XMLConfigHistory::Previous()");
422  mpCurrentConfig = p;
423  p->Restore();
424  mLock=false;
425  return true;
426 }
427 
429 {
430  if((mvpConfig.size()==0) || (mpCurrentConfig==NULL)) return false;
431  if(mpCurrentConfig == mvpConfig.front())
432  {
433  fpObjCrystInformUser("XMLConfigHistory::Next(): already at first stored configuration");
434  return false;
435  }
436  mLock=true;
437  (*fpObjCrystInformUser)("XMLConfigHistory::Next()");
438 
439  std::list<boost::shared_ptr<XMLConfig> >::const_reverse_iterator pos;
440  for(pos=mvpConfig.rbegin();pos!=mvpConfig.rend();++pos)
441  if(*pos == mpCurrentConfig) {++pos ; break;}
442  (*pos)->Restore();
443  mpCurrentConfig = *pos;
444  mLock=false;
445  return true;
446 }
447 
448 
449 } // namespace ObjCryst
The namespace which includes all objects (crystallographic and algorithmic) in ObjCryst++.
Definition: doc-main.h:25
ObjRegistry< OptimizationObj > gOptimizationObjRegistry("List of all Optimization objects")
Global Registry for all OptimizationObj.
void(* fpObjCrystInformUser)(const string &)
Pointer to a function for passing info to the user during or after long/important processes (use scar...
Definition: Exception.cpp:76
XMLConfigHistory gConfigHistory
Global object to hold configurations history.
Definition: Undo.cpp:26
ObjRegistry< Crystal > gCrystalRegistry("List of all Crystals")
Global registry for all Crystal objects.
Definition: Crystal.h:669
ObjRegistry< DiffractionDataSingleCrystal > gDiffractionDataSingleCrystalRegistry("Global DiffractionDataSingleCrystal Registry")
Global registry for all PowderPattern objects.
Crystal class: Unit cell, spacegroup, scatterers.
Definition: Crystal.h:98
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Definition: Crystal.cpp:182
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input the crystal structure from a stream.
DiffractionData object for Single Crystal analysis.
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
Powder pattern class, with an observed pattern and several calculated components to modelize the patt...
virtual void XMLOutput(ostream &os, int indent=0) const
Output to stream in well-formed XML.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)
Input From stream.
virtual const string & GetClassName() const
Name for this class ("RefinableObj", "Crystal",...).
Class to store & restore all top-level ObjCryst++ objects as their XML description.
Definition: Undo.h:41
RefinableObjClock mClock
Clock recording the creation of this XMLConfig.
Definition: Undo.h:62
XMLConfig()
Default cronstructor.
Definition: Undo.cpp:33
void Restore()
Restore the saved XML configuration.
Definition: Undo.cpp:177
bool operator!=(const XMLConfig &rhs) const
Non-equality operator.
Definition: Undo.cpp:345
bool operator==(const XMLConfig &rhs) const
Equality operator.
Definition: Undo.cpp:308
const RefinableObjClock & GetClock() const
Access the clock corresponding to the creation of this config.
Definition: Undo.cpp:350
Class to store XMLConfig configurations.
Definition: Undo.h:69
boost::shared_ptr< XMLConfig > mpCurrentConfig
The current configuration loaded (can be null if none is selected) This is reset every time a change ...
Definition: Undo.h:100
void Restore(boost::shared_ptr< XMLConfig > &p)
Restore a configuration.
Definition: Undo.cpp:391
XMLConfigHistory(const int maxnb=20)
Constructor.
Definition: Undo.cpp:358
std::list< boost::shared_ptr< XMLConfig > > GetList()
Access the list of configurations.
Definition: Undo.cpp:399
bool Next()
Reload the next (more recent) configuration in the list.
Definition: Undo.cpp:428
bool mLock
Lock used during Store and Restore.
Definition: Undo.h:102
std::list< boost::shared_ptr< XMLConfig > > mvpConfig
List of configurations.
Definition: Undo.h:97
int mMaxNb
Maximum number of stored configurations.
Definition: Undo.h:95
bool Store()
Store a new configuration.
Definition: Undo.cpp:362
bool Previous()
Reload the previous (older) configuration in the list.
Definition: Undo.cpp:403
Base object for Optimization methods.
virtual const string GetClassName() const
Get the name for this class type.
virtual void XMLOutput(ostream &os, int indent=0) const =0
Output a description of the object in XML format to a stream.
virtual void XMLInput(istream &is, const XMLCrystTag &tag)=0
Input in XML format from a stream, restoring the set of refined objects and the associated cost funct...
const string & GetName() const
Get the name for this object.
Base object for Monte-Carlo Global Optimization methods.
class to input or output a well-formatted xml beginning or ending tag.
We need to record exactly when refinable objects have been modified for the last time (to avoid re-co...
Definition: RefinableObj.h:140
void Click()
Record an event for this clock (generally, the 'time' an object has been modified,...
virtual const string & GetName() const
Name of the object.