ATLAS Offline Software
Loading...
Searching...
No Matches
ByteStreamDataWriter Class Referenceabstract

This class defines abstract interface for data writing. More...

#include <ByteStreamDataWriter.h>

Collaboration diagram for ByteStreamDataWriter:

Public Member Functions

 ByteStreamDataWriter ()
virtual ~ByteStreamDataWriter ()=default
 ByteStreamDataWriter (const ByteStreamDataWriter &)=delete
ByteStreamDataWriteroperator= (const ByteStreamDataWriter &)=delete
virtual EventStorage::DWError putData (unsigned int dataSize, const void *data)=0
 Write a single block of data.
virtual bool good () const =0
 Feedback to user, check if open and last write went OK.

Static Public Member Functions

static std::unique_ptr< ByteStreamDataWritermakeWriter (int version, const std::string &writingPath, const std::string &fileNameCore, const EventStorage::run_parameters_record &rPar, const std::vector< std::string > &fmdStrings, unsigned int maxFileNE=0, unsigned int maxFileMB=0, unsigned int startIndex=1, EventStorage::CompressionType compression=EventStorage::NONE, unsigned int compLevel=1)
 Factory method returning data writer instance for specified version.
static std::unique_ptr< ByteStreamDataWritermakeWriter (int version, const std::string &writingPath, boost::shared_ptr< EventStorage::FileNameCallback > theFNCB, const EventStorage::run_parameters_record &rPar, const std::string &project, const std::string &streamType, const std::string &streamName, const std::string &stream, unsigned int lumiBlockNumber, const std::string &applicationName, const std::vector< std::string > &fmdStrings, unsigned int maxFileNE=0, unsigned int maxFileMB=0, EventStorage::CompressionType compression=EventStorage::NONE, unsigned int compLevel=1)
 Factory method returning data writer instance for specified version.
static std::unique_ptr< ByteStreamDataWritermakeWriter (const DataWriterParameters &parameters)
 Factory method returning data writer instance for specified version.

Detailed Description

This class defines abstract interface for data writing.

Main purpose of this class is to provide interface for writing different versions of output ByteStream files. This interface will be implemented on top of the EventStorage/DataWriter (from tdaq-common) and it will only provide few methods relevant to this package. The interface is defined in terms of data structures of the current version of the EventStorage, implementations for older versions will need to translate those structures into their version-specific data.

In addition to abstract methods this class defines few factory methods which return instances implementing this interface.

Definition at line 41 of file ByteStreamDataWriter.h.

Constructor & Destructor Documentation

◆ ByteStreamDataWriter() [1/2]

ByteStreamDataWriter::ByteStreamDataWriter ( )
inline

Definition at line 121 of file ByteStreamDataWriter.h.

121{}

◆ ~ByteStreamDataWriter()

virtual ByteStreamDataWriter::~ByteStreamDataWriter ( )
virtualdefault

◆ ByteStreamDataWriter() [2/2]

ByteStreamDataWriter::ByteStreamDataWriter ( const ByteStreamDataWriter & )
delete

Member Function Documentation

◆ good()

virtual bool ByteStreamDataWriter::good ( ) const
pure virtual

Feedback to user, check if open and last write went OK.

◆ makeWriter() [1/3]

std::unique_ptr< ByteStreamDataWriter > ByteStreamDataWriter::makeWriter ( const DataWriterParameters & parameters)
static

Factory method returning data writer instance for specified version.

Throws exception in case of problems, never returns zero pointer.

Parameters
parametersset of parameters needed to initiate DataWriter
Exceptions
std::exception(or sub-class) is thrown in case of problems.

Definition at line 142 of file ByteStreamDataWriter.cxx.

142 {
143 // initiate with production file name
144 if (parameters.theFNCB == nullptr)
145 return makeWriter(
146 parameters.version,
147 parameters.writingPath,
148 parameters.fileNameCore,
149 parameters.rPar,
150 parameters.fmdStrings,
151 parameters.maxFileNE,
152 parameters.maxFileMB,
153 parameters.startIndex,
154 parameters.compression,
155 parameters.compLevel);
156
157 // initiate for user-defined file name
158 return makeWriter(
159 parameters.version,
160 parameters.writingPath,
161 parameters.theFNCB,
162 parameters.rPar,
163 parameters.project,
164 parameters.streamType,
165 parameters.streamName,
166 parameters.stream,
167 parameters.lumiBlockNumber,
168 parameters.applicationName,
169 parameters.fmdStrings,
170 parameters.maxFileNE,
171 parameters.maxFileMB,
172 parameters.compression,
173 parameters.compLevel);
174}
static std::unique_ptr< ByteStreamDataWriter > makeWriter(int version, const std::string &writingPath, const std::string &fileNameCore, const EventStorage::run_parameters_record &rPar, const std::vector< std::string > &fmdStrings, unsigned int maxFileNE=0, unsigned int maxFileMB=0, unsigned int startIndex=1, EventStorage::CompressionType compression=EventStorage::NONE, unsigned int compLevel=1)
Factory method returning data writer instance for specified version.

◆ makeWriter() [2/3]

std::unique_ptr< ByteStreamDataWriter > ByteStreamDataWriter::makeWriter ( int version,
const std::string & writingPath,
boost::shared_ptr< EventStorage::FileNameCallback > theFNCB,
const EventStorage::run_parameters_record & rPar,
const std::string & project,
const std::string & streamType,
const std::string & streamName,
const std::string & stream,
unsigned int lumiBlockNumber,
const std::string & applicationName,
const std::vector< std::string > & fmdStrings,
unsigned int maxFileNE = 0,
unsigned int maxFileMB = 0,
EventStorage::CompressionType compression = EventStorage::NONE,
unsigned int compLevel = 1 )
static

Factory method returning data writer instance for specified version.

Throws exception in case of problems, never returns zero pointer.

Parameters
versionwriter version to instantiate, 0 for most current version. Exception is thrown is version is not supported.
writingPathdirectory where to write data
theFNCBcallback method for generating file names
rParother parameters from IS including the run number
fmdStringsoptional vector of strings containing metadata
maxFileNEmax size of a file in number of data blocks (or events)
maxFileMBmax size of a file in MB. The file is closed before this limit is overrun.
startIndexinitial file sequence index
compressionCompression type
compLevelCompression level
Exceptions
std::exception(or sub-class) is thrown in case of problems.

Definition at line 100 of file ByteStreamDataWriter.cxx.

115{
116 ByteStreamDataWriter* res = nullptr;
117 if (version == 0 or version == FILE_FORMAT_VERSION) {
118 // Use current version
119 res = new ByteStreamDataWriterCurrent(writingPath,
120 theFNCB,
121 rPar,
122 project,
123 streamType,
124 streamName,
125 stream,
126 lumiBlockNumber,
127 applicationName,
128 fmdStrings,
129 maxFileNE,
130 maxFileMB,
131 compression,
132 compLevel);
133 } else {
134 // Unexpected something
135 versionException(version);
136 }
137
138 return std::unique_ptr<ByteStreamDataWriter>(res);
139}
std::pair< std::vector< unsigned int >, bool > res
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)

◆ makeWriter() [3/3]

std::unique_ptr< ByteStreamDataWriter > ByteStreamDataWriter::makeWriter ( int version,
const std::string & writingPath,
const std::string & fileNameCore,
const EventStorage::run_parameters_record & rPar,
const std::vector< std::string > & fmdStrings,
unsigned int maxFileNE = 0,
unsigned int maxFileMB = 0,
unsigned int startIndex = 1,
EventStorage::CompressionType compression = EventStorage::NONE,
unsigned int compLevel = 1 )
static

Factory method returning data writer instance for specified version.

Throws exception in case of problems, never returns zero pointer.

Parameters
versionwriter version to instantiate, 0 for most current version Exception is thrown if version is not supported.
writingPathdirectory where to write data
fileNameCorefile name not including the ending "._NNNN.data"
rParother parameters from IS including the run number
fmdStringsoptional vector of strings containing metadata
maxFileNEmax size of a file in number of data blocks (or events)
maxFileMBmax size of a file in MB. The file is closed before this limit is overrun.
startIndexinitial file sequence index
compressionCompression type
compLevelCompression level
Exceptions
std::exception(or sub-class) is thrown in case of problems.

Definition at line 68 of file ByteStreamDataWriter.cxx.

78{
79 ByteStreamDataWriter* res = nullptr;
80 if (version == 0 or version == FILE_FORMAT_VERSION) {
81 // Use current version
82 res = new ByteStreamDataWriterCurrent(writingPath,
83 fileNameCore,
84 rPar,
85 fmdStrings,
86 maxFileNE,
87 maxFileMB,
88 startIndex,
89 compression,
90 compLevel);
91 } else {
92 // Unexpected something
93 versionException(version);
94 }
95
96 return std::unique_ptr<ByteStreamDataWriter>(res);
97}

◆ operator=()

ByteStreamDataWriter & ByteStreamDataWriter::operator= ( const ByteStreamDataWriter & )
delete

◆ putData()

virtual EventStorage::DWError ByteStreamDataWriter::putData ( unsigned int dataSize,
const void * data )
pure virtual

Write a single block of data.

If one of the size limits would be exceeded, the current file will be closed and another one will be opened automatically.

Parameters
dataSizesize of the data block in bytes
datastart of the event data in memory

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