Belle II Software light-2406-ragdoll
SeqFile.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <iosfwd>
12#include <memory>
13#include <string>
14
15namespace Belle2 {
22 class SeqFile {
23 public:
34 SeqFile(const std::string& filename, const std::string& rwflag,
35 char* streamerinfo = nullptr, int streamerinfo_size = 0,
36 bool filenameIsPattern = false);
38 ~SeqFile();
40 SeqFile(const SeqFile&) = delete;
42 SeqFile& operator=(const SeqFile&) = delete;
44 int status() const;
45
47 int write(const char* buf);
49 int read(char* buf, int max);
50
51 private:
53 void openFile(std::string filename, bool readonly);
54
55 private:
57 const static int c_MaxFileSize {512000000 * 4};
58
59 std::string m_filename;
60 std::string m_filenamePattern;
61 int m_fd{ -1};
62 int m_nb{0};
63 int m_nfile{0};
64 bool m_compressed{false};
65 std::unique_ptr<std::ios> m_stream;
69
72
73 };
74
76}
A class to manage I/O for a chain of blocked files.
Definition: SeqFile.h:22
~SeqFile()
Destructor.
Definition: SeqFile.cc:128
std::string m_filenamePattern
Pattern for creating the file from the sequence number.
Definition: SeqFile.h:60
SeqFile(const SeqFile &)=delete
No copying.
SeqFile & operator=(const SeqFile &)=delete
No assignment.
int m_nb
when saving a file, the total number of bytes written, 0 when reading.
Definition: SeqFile.h:62
void openFile(std::string filename, bool readonly)
actually open the file
Definition: SeqFile.cc:81
int m_streamerinfo_size
size(bytes) of StreamerInfo
Definition: SeqFile.h:71
std::unique_ptr< std::ios > m_stream
pointer to the filtering input or output stream
Definition: SeqFile.h:65
bool m_compressed
is file gzipped compressed?
Definition: SeqFile.h:64
int status() const
Returns status after constructor call.
Definition: SeqFile.cc:135
static const int c_MaxFileSize
maximal size of one file (in Bytes).
Definition: SeqFile.h:57
std::string m_filename
Name of the opened file.
Definition: SeqFile.h:59
int m_fd
file descriptor.
Definition: SeqFile.h:61
int m_nfile
file counter, starting at 0 (files are split after c_MaxFileSize bytes).
Definition: SeqFile.h:63
int write(const char *buf)
Write a record to a file.
Definition: SeqFile.cc:140
char * m_streamerinfo
StreamerInfo.
Definition: SeqFile.h:68
int read(char *buf, int max)
Read a record from a file.
Definition: SeqFile.cc:174
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24