Pol  Revision:cb584c9
savedata.h
Go to the documentation of this file.
1 
7 #ifndef SAVEDATA_H
8 #define SAVEDATA_H
9 
10 #include <boost/noncopyable.hpp>
11 #include <fstream>
12 #include <future>
13 #include <string>
14 
15 #include "../clib/streamsaver.h"
16 
17 namespace Pol
18 {
19 namespace Core
20 {
21 class SaveContext : boost::noncopyable
22 {
23  // typedef Clib::ThreadedOFStreamWriter SaveStrategy; // too many context switches!
25 
26 private:
27  std::ofstream _pol;
28  std::ofstream _objects;
29  std::ofstream _pcs;
30  std::ofstream _pcequip;
31  std::ofstream _npcs;
32  std::ofstream _npcequip;
33  std::ofstream _items;
34  std::ofstream _multis;
35  std::ofstream _storage;
36  std::ofstream _resource;
37  std::ofstream _guilds;
38  std::ofstream _datastore;
39  std::ofstream _party;
40 
41 public:
42  SaveContext();
43  ~SaveContext();
44  SaveStrategy pol;
45  SaveStrategy objects;
46  SaveStrategy pcs;
47  SaveStrategy pcequip;
48  SaveStrategy npcs;
49  SaveStrategy npcequip;
50  SaveStrategy items;
51  SaveStrategy multis;
52  SaveStrategy storage;
53  SaveStrategy resource;
54  SaveStrategy guilds;
55  SaveStrategy datastore;
56  SaveStrategy party;
57  static std::shared_future<bool> finished;
58  static void ready();
59 };
60 
61 int save_incremental( unsigned int& dirty_writes, unsigned int& clean_objects,
62  long long& elapsed_ms );
63 
67 
68 bool commit( const std::string& basename );
70 bool should_write_data();
71 }
72 }
73 #endif
Clib::OFStreamWriter SaveStrategy
Definition: savedata.h:24
SaveStrategy items
Definition: savedata.h:50
SaveStrategy guilds
Definition: savedata.h:54
static void ready()
blocks till possible last commit finishes
Definition: uimport.cpp:798
SaveStrategy npcequip
Definition: savedata.h:49
void write_system_data(Clib::StreamWriter &sw)
Definition: uimport.cpp:816
std::ofstream _party
Definition: savedata.h:39
SaveStrategy pcequip
Definition: savedata.h:47
std::ofstream _multis
Definition: savedata.h:34
static std::shared_future< bool > finished
Definition: savedata.h:57
SaveStrategy pol
Definition: savedata.h:44
void write_shadow_realms(Clib::StreamWriter &sw)
Definition: uimport.cpp:827
std::ofstream _pcequip
Definition: savedata.h:30
std::ofstream _pcs
Definition: savedata.h:29
std::ofstream _datastore
Definition: savedata.h:38
std::ofstream _resource
Definition: savedata.h:36
SaveStrategy datastore
Definition: savedata.h:55
SaveStrategy multis
Definition: savedata.h:51
void commit_incremental_saves()
Definition: savedata.cpp:302
SaveStrategy party
Definition: savedata.h:56
SaveStrategy storage
Definition: savedata.h:52
SaveStrategy pcs
Definition: savedata.h:46
bool should_write_data()
Definition: uimport.cpp:1015
void write_global_properties(Clib::StreamWriter &sw)
Definition: uimport.cpp:808
std::ofstream _npcequip
Definition: savedata.h:32
std::ofstream _guilds
Definition: savedata.h:37
int save_incremental(unsigned int &dirty, unsigned int &clean, long long &elapsed_ms)
Definition: savedata.cpp:229
SaveStrategy npcs
Definition: savedata.h:48
std::ofstream _npcs
Definition: savedata.h:31
std::ofstream _pol
Definition: savedata.h:27
std::ofstream _objects
Definition: savedata.h:28
bool commit(const std::string &basename)
Definition: uimport.cpp:968
SaveStrategy objects
Definition: savedata.h:45
SaveStrategy resource
Definition: savedata.h:53
std::ofstream _items
Definition: savedata.h:33
std::ofstream _storage
Definition: savedata.h:35
Definition: berror.cpp:12