// FilePhysical.h #ifndef hes_FilePhysical_H #define hes_FilePhysical_H // David Adams // March 2002 // // Mixin for hes::File that provides functions for opening, // closing and reporting on the status of the physical file. #include #include "hesfile/File.h" namespace hes { class FilePhysical : public virtual File { private: // data // Flag indicating if events may be read from a file which is not // locked. bool m_read_unlocked; // Open status. // Initialized to CLOSED. File::OpenStatus m_open_status; // The file. std::fstream* m_pfstrm; public: // Interface for subclass // Notification that a file has just been opened. virtual void begin_file() =0; // Notification that a file is about to be closed. virtual void end_file() =0; public: // functions // Constructor. // The argument indicates whether an unlocked file cam be read. // We might want to add the option to open files in binary mode. FilePhysical(bool read_unlocked); // Destructor. // Deletes the stream which closes the file. ~FilePhysical(); // Return the file stream. // Only call if ths stream is open. std::fstream& file_stream(); std::fstream& file_stream() const; // Implement File interface // Open or close the file. // Return nonzero for error. int open(OpenStatus stat); // Return the open status. File::OpenStatus open_status() const; // Can event data be read? // File must be open and may have to be locked. bool can_be_read() const; // Can event data be written? // File must be unlocked and opened for writing. bool can_be_written() const; }; } // end namespace hes #endif