Minsky
saver.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2021
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef SAVER_H
21 #define SAVER_H
22 #include <xml_pack_base.h>
23 #include <fstream>
24 #include <string>
25 #include <thread>
26 
27 namespace schema3
28 {
29  class Minsky;
30 }
31 
32 namespace minsky
33 {
34  extern const char* schemaURL;
35 
36  struct Saver
37  {
38  std::string fileName;
39  std::ofstream os;
40  classdesc::xml_pack_t packer;
41  Saver(const std::string& fileName);
42  void save(const schema3::Minsky&);
43  };
44 
45  struct BackgroundSaver: public Saver, public std::thread
46  {
47  std::thread thread;
48  std::string lastError;
49  BackgroundSaver(const std::string& fileName): Saver(fileName) {}
51  void save(const schema3::Minsky&);
52  void killThread();
53  };
54 }
55 
56 #endif
std::ofstream os
Definition: saver.h:39
BackgroundSaver(const std::string &fileName)
Definition: saver.h:49
std::thread thread
Definition: saver.h:47
void save(const schema3::Minsky &)
Definition: saver.cc:40
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
std::string fileName
Definition: saver.h:38
const char * schemaURL
Definition: saver.cc:26
Saver(const std::string &fileName)
Definition: saver.cc:28
std::string lastError
Definition: saver.h:48
classdesc::xml_pack_t packer
Definition: saver.h:40
void save(const schema3::Minsky &)
Definition: saver.cc:68