PetaVision  Alpha
PV::CheckpointableFileStream Class Reference
Inheritance diagram for PV::CheckpointableFileStream:
PV::FileStream PV::CheckpointerDataInterface PV::PrintStream PV::Observer

Public Member Functions

 CheckpointableFileStream (string const &path, bool newFile, Checkpointer *checkpointer, string const &objName, bool verifyWrites)
 
 CheckpointableFileStream (string const &path, bool newFile, Checkpointer *checkpointer, string const &objName)
 
bool binary ()
 
void flush ()
 
std::string const & getDescription () const
 
char const * getDescription_c () const
 
std::string const & getFileName () const
 
long getInPos ()
 
MPIBlock const * getMPIBlock ()
 
long getOutPos ()
 
template<typename T >
PrintStreamoperator<< (const T &x)
 
PrintStreamoperator<< (std::ostream &(*f)(std::ostream &))
 
PrintStreamoperator<< (std::ostream &(*f)(std::ios &))
 
PrintStreamoperator<< (std::ostream &(*f)(std::ios_base &))
 
int printf (const char *fmt,...)
 
virtual void read (void *data, long length) override
 
bool readable ()
 
virtual Response::Status readStateFromCheckpoint (Checkpointer *checkpointer)
 
bool readwrite ()
 
virtual Response::Status respond (std::shared_ptr< BaseMessage const > message) override
 
virtual void setInPos (long pos, std::ios_base::seekdir seekAnchor)
 
virtual void setInPos (long pos, bool fromBeginning) override
 
virtual void setOutPos (long pos, std::ios_base::seekdir seekAnchor)
 
virtual void setOutPos (long pos, bool fromBeginning) override
 
virtual void write (void const *data, long length) override
 
bool writeable ()
 

Protected Member Functions

void openFile (char const *path, std::ios_base::openmode mode, bool verifyWrites)
 
virtual Response::Status prepareCheckpointWrite ()
 
virtual Response::Status processCheckpointRead ()
 
Response::Status respondPrepareCheckpointWrite (std::shared_ptr< PrepareCheckpointWriteMessage const > message)
 
Response::Status respondProcessCheckpointRead (std::shared_ptr< ProcessCheckpointReadMessage const > message)
 
Response::Status respondReadStateFromCheckpoint (std::shared_ptr< ReadStateFromCheckpointMessage< Checkpointer > const > message)
 
Response::Status respondRegisterData (std::shared_ptr< RegisterDataMessage< Checkpointer > const > message)
 
void setOutStream (std::ostream &stream)
 
void verifyFlags (const char *caller)
 

Protected Attributes

std::string description
 
std::string mFileName
 
std::fstream mFStream
 

Private Member Functions

void initialize (string const &path, bool newFile, Checkpointer *checkpointer, string const &objName, bool verifyWrites)
 
virtual Response::Status registerData (Checkpointer *checkpointer) override
 
Response::Status respondProcessCheckpointRead (ProcessCheckpointReadMessage const *message)
 
void setDescription ()
 
void syncFilePos ()
 
void updateFilePos ()
 

Private Attributes

long mFileReadPos = 0
 
long mFileWritePos = 0
 
string mObjName
 

Detailed Description

Definition at line 13 of file CheckpointableFileStream.hpp.

Constructor & Destructor Documentation

PV::CheckpointableFileStream::CheckpointableFileStream ( string const &  path,
bool  newFile,
Checkpointer checkpointer,
string const &  objName,
bool  verifyWrites 
)

Constructor for CheckpointableFileStream. Opens a file for reading and writing at the path indicated, and registers its file positions with the given checkpointer. The path must be a relative path; it is relative to the checkpointer's OutputPath directory. If newFile is true, the file is created (clobbering the file if it already exists). If newFile is false and the file does not exist, a warning is issued and the file is created. A CheckpointableFileStream can only be instantiated by the root process of the Checkpointer's MPIBlock; all other processes generate a fatal error. objName is the object name used when registering the file positions with the checkpointer. verifyWrites has the same meaning as in the FileStream constructor.

Definition at line 5 of file CheckpointableFileStream.cpp.

PV::CheckpointableFileStream::CheckpointableFileStream ( string const &  path,
bool  newFile,
Checkpointer checkpointer,
string const &  objName 
)

This constructor is identical to the previous constructor, except that the checkpointer's verifyWrites flag is used in place of an explicit argument.

Definition at line 14 of file CheckpointableFileStream.cpp.


The documentation for this class was generated from the following files: