Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:11

0001 #ifndef IOPool_Streamer_StreamerFileIO_h
0002 #define IOPool_Streamer_StreamerFileIO_h
0003 
0004 /**
0005 This file contains Class definitions for the 
0006 Class representing Output (Streamer) file.
0007 */
0008 
0009 #include "IOPool/Streamer/interface/MsgTools.h"
0010 #include "FWCore/Utilities/interface/propagate_const.h"
0011 #include <memory>
0012 #include <iosfwd>
0013 #include <string>
0014 
0015 //-------------------------------------------------------
0016 namespace edm::streamer {
0017   class OutputFile
0018   /**
0019   Class representing Output (Streamer) file.
0020   */
0021   {
0022   public:
0023     explicit OutputFile(const std::string& name, uint32 padding = 0);
0024     /**
0025       CTOR, takes file path name as argument
0026      */
0027     ~OutputFile();
0028 
0029     bool write(const char* ptr, size_t n, bool doPadding = false);
0030     bool writePadding();
0031 
0032     std::string fileName() const { return filename_; }
0033     uint64 current_offset() const { return current_offset_; }
0034     uint32 adler32() const { return (adlerb_ << 16) | adlera_; }
0035 
0036     void set_do_adler(bool v) { do_adler_ = v; }
0037     void set_current_offset(uint64 v) { current_offset_ = v; }
0038     void close();
0039 
0040   private:
0041     uint64 current_offset_; /** Location of current ioptr */
0042 
0043     bool do_adler_;
0044     uint32 adlera_;
0045     uint32 adlerb_;
0046     uint32 padding_;
0047 
0048     edm::propagate_const<std::shared_ptr<std::ofstream>> ost_;
0049     std::string filename_;
0050     std::unique_ptr<char[]> paddingBuf_;
0051   };
0052 }  // namespace edm::streamer
0053 #endif