PetaVision  Alpha
CheckpointableFileStream.hpp
1 #ifndef __CHECKPOINTABLEFILESTREAM_HPP__
2 #define __CHECKPOINTABLEFILESTREAM_HPP__
3 
4 #include "CheckpointerDataInterface.hpp"
5 #include "io/FileStream.hpp"
6 
7 #include <string>
8 
9 using std::string;
10 
11 namespace PV {
12 
14 
15  public:
31  string const &path,
32  bool newFile,
33  Checkpointer *checkpointer,
34  string const &objName,
35  bool verifyWrites);
36 
43  string const &path,
44  bool newFile,
45  Checkpointer *checkpointer,
46  string const &objName);
47  virtual Response::Status respond(std::shared_ptr<BaseMessage const> message) override;
48  virtual void write(void const *data, long length) override;
49  virtual void read(void *data, long length) override;
50  virtual void setOutPos(long pos, bool fromBeginning) override;
51  virtual void setInPos(long pos, bool fromBeginning) override;
52 
53  private:
54  void initialize(
55  string const &path,
56  bool newFile,
57  Checkpointer *checkpointer,
58  string const &objName,
59  bool verifyWrites);
60  void setDescription();
61  virtual Response::Status registerData(Checkpointer *checkpointer) override;
62  Response::Status respondProcessCheckpointRead(ProcessCheckpointReadMessage const *message);
63  void syncFilePos();
64  void updateFilePos();
65  long mFileReadPos = 0;
66  long mFileWritePos = 0;
67  string mObjName; // Used for CheckpointerDataInterface
68 };
69 }
70 
71 #endif
CheckpointableFileStream(string const &path, bool newFile, Checkpointer *checkpointer, string const &objName, bool verifyWrites)