Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
checkpointer.h
Go to the documentation of this file.
1 #ifndef CHECKPOINTER_H
2 #define CHECKPOINTER_H
3 
4 #include <QObject>
5 #include <QMap>
6 
7 #include "parameters.h"
8 
9 namespace LangmuirCore
10 {
11 
12 class World;
13 class KeyValueParser;
14 
20 class CheckPointer : public QObject
21 {
22  Q_OBJECT
23 public:
24 
28  enum Section
29  {
38  };
39  Q_ENUMS(Section)
40 
41 
46  explicit CheckPointer(World& world, QObject *parent = 0);
47 
53  void load(const QString& fileName, ConfigurationInfo &configInfo);
54 
59  void save(const QString& fileName = "%stub.chk");
60 
66  void checkStream(std::istream& stream, const QString& message = "");
67 
68 private:
69 
75  std::istream& loadElectrons(std::istream &stream, ConfigurationInfo &configInfo);
76 
82  std::istream& loadHoles(std::istream &stream, ConfigurationInfo &configInfo);
83 
89  std::istream& loadDefects(std::istream &stream, ConfigurationInfo &configInfo);
90 
96  std::istream& loadTraps(std::istream &stream, ConfigurationInfo &configInfo);
97 
103  std::istream& loadTrapPotentials(std::istream &stream, ConfigurationInfo &configInfo);
104 
110  std::istream& loadFluxState(std::istream &stream, ConfigurationInfo &configInfo);
111 
116  std::istream& loadParameters(std::istream &stream);
117 
122  std::istream& loadRandomState(std::istream &stream);
123 
128  std::ostream& saveElectrons(std::ostream &stream);
129 
134  std::ostream& saveHoles(std::ostream &stream);
135 
140  std::ostream& saveDefects(std::ostream &stream);
141 
146  std::ostream& saveTraps(std::ostream &stream);
147 
152  std::ostream& saveTrapPotentials(std::ostream &stream);
153 
158  std::ostream& saveFluxState(std::ostream &stream);
159 
164  std::ostream& saveParameters(std::ostream &stream);
165 
170  std::ostream& saveRandomState(std::ostream &stream);
171 
176 };
177 
178 inline static std::ostream& operator<<(std::ostream& stream, QString& string)
179 {
180  stream << string.toStdString();
181  return stream;
182 }
183 
184 inline static std::istream& operator>>(std::istream& stream, QString& string)
185 {
186  std::string temporary;
187  stream >> temporary;
188  string = QString::fromStdString(temporary);
189  return stream;
190 }
191 
192 }
193 #endif // CHECKPOINTER_H
void save(const QString &fileName="%stub.chk")
save simulation information
World & m_world
reference to world object
Definition: checkpointer.h:175
void load(const QString &fileName, ConfigurationInfo &configInfo)
load simulation information
std::ostream & saveHoles(std::ostream &stream)
save hole site ids to output file
Definition: checkpointer.h:35
std::istream & loadParameters(std::istream &stream)
load parameter from input file
A class to read and write checkpoint files.
Definition: checkpointer.h:20
std::istream & loadTraps(std::istream &stream, ConfigurationInfo &configInfo)
load trap sites from input file
std::istream & loadHoles(std::istream &stream, ConfigurationInfo &configInfo)
load hole sites from input file
Definition: checkpointer.h:34
Definition: checkpointer.h:33
std::ostream & saveDefects(std::ostream &stream)
save defect site ids to output file
Definition: checkpointer.h:32
Definition: checkpointer.h:36
std::istream & loadFluxState(std::istream &stream, ConfigurationInfo &configInfo)
load flux state from input file
std::istream & loadElectrons(std::istream &stream, ConfigurationInfo &configInfo)
load electrons sites from input file
A class to hold all objects in a simulation.
Definition: world.h:51
Definition: checkpointer.h:30
Section
A way to identify different sections in the input file.
Definition: checkpointer.h:28
std::ostream & saveRandomState(std::ostream &stream)
save random number generator state to output file
static std::istream & operator>>(std::istream &stream, QString &string)
Definition: checkpointer.h:184
void checkStream(std::istream &stream, const QString &message="")
check to see if input stream has failed
A struct to temporarily store site IDs.
Definition: parameters.h:14
std::ostream & saveTrapPotentials(std::ostream &stream)
save trap energies to output file
std::istream & loadTrapPotentials(std::istream &stream, ConfigurationInfo &configInfo)
load trap energies from input file
std::ostream & saveTraps(std::ostream &stream)
save trap site ids to output file
Definition: agent.h:12
Definition: checkpointer.h:31
std::ostream & saveParameters(std::ostream &stream)
save parameters to output file
std::istream & loadDefects(std::istream &stream, ConfigurationInfo &configInfo)
load defect sites from input file
std::istream & loadRandomState(std::istream &stream)
load random number generator state from input file
std::ostream & saveElectrons(std::ostream &stream)
save electron site ids to output file
std::ostream & saveFluxState(std::ostream &stream)
save flux states to output file
Definition: checkpointer.h:37