Belle II Software  release-05-02-19
SeqFile.h
1 //+
2 // File : seqfile.h
3 // Description : Blocked file management for sequential binary I/O
4 //
5 // Author : Ryosuke Itoh, IPNS, KEK
6 // Date : 28 - Aug - 2003
7 //-
8 
9 #pragma once
10 
11 #include <iosfwd>
12 #include <memory>
13 #include <string>
14 
15 namespace Belle2 {
22  class SeqFile {
23  public:
31  SeqFile(const std::string& filename, const std::string& rwflag,
32  char* streamerinfo = NULL, int streamerinfo_size = 0,
33  bool filenameIsPattern = false);
35  ~SeqFile();
37  SeqFile(const SeqFile&) = delete;
39  SeqFile& operator=(const SeqFile&) = delete;
41  int status() const;
42 
44  int write(const char* buf);
46  int read(char* buf, int max);
47 
48  private:
50  void openFile(std::string filename, bool readonly);
51 
52  private:
54  const static int c_MaxFileSize {512000000 * 4};
55 
56  std::string m_filename;
57  std::string m_filenamePattern;
58  int m_fd{ -1};
59  int m_nb{0};
60  int m_nfile{0};
61  bool m_compressed{false};
62  std::unique_ptr<std::ios> m_stream;
66 
69 
70  };
71 
73 }
Belle2::SeqFile::m_fd
int m_fd
file descriptor.
Definition: SeqFile.h:58
Belle2::SeqFile::~SeqFile
~SeqFile()
Destructor.
Definition: SeqFile.cc:124
Belle2::SeqFile::SeqFile
SeqFile(const std::string &filename, const std::string &rwflag, char *streamerinfo=NULL, int streamerinfo_size=0, bool filenameIsPattern=false)
Constructor.
Definition: SeqFile.cc:25
Belle2::SeqFile::m_stream
std::unique_ptr< std::ios > m_stream
pointer to the filtering input or output stream
Definition: SeqFile.h:62
Belle2::SeqFile::m_streamerinfo
char * m_streamerinfo
StreamerInfo.
Definition: SeqFile.h:65
Belle2::SeqFile::c_MaxFileSize
const static int c_MaxFileSize
maximal size of one file (in Bytes).
Definition: SeqFile.h:54
Belle2::SeqFile::m_filenamePattern
std::string m_filenamePattern
Pattern for creating the file from the sequence number.
Definition: SeqFile.h:57
Belle2::SeqFile::m_nb
int m_nb
when saving a file, the total number of bytes written, 0 when reading.
Definition: SeqFile.h:59
Belle2::SeqFile::operator=
SeqFile & operator=(const SeqFile &)=delete
No assignment.
Belle2::SeqFile::m_filename
std::string m_filename
Name of the opened file.
Definition: SeqFile.h:56
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SeqFile::status
int status() const
Returns status after constructor call.
Definition: SeqFile.cc:131
Belle2::SeqFile::write
int write(const char *buf)
Write a record to a file.
Definition: SeqFile.cc:136
Belle2::SeqFile::m_streamerinfo_size
int m_streamerinfo_size
size(bytes) of StreamerInfo
Definition: SeqFile.h:68
Belle2::SeqFile::m_nfile
int m_nfile
file counter, starting at 0 (files are split after c_MaxFileSize bytes).
Definition: SeqFile.h:60
Belle2::SeqFile::read
int read(char *buf, int max)
Read a record from a file.
Definition: SeqFile.cc:170
Belle2::SeqFile
A class to manage I/O for a chain of blocked files.
Definition: SeqFile.h:22
Belle2::SeqFile::m_compressed
bool m_compressed
is file gzipped compressed?
Definition: SeqFile.h:61
Belle2::SeqFile::openFile
void openFile(std::string filename, bool readonly)
actually open the file
Definition: SeqFile.cc:77