Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:51

0001 #ifndef STORAGE_FACTORY_IO_POS_BUFFER_H
0002 #define STORAGE_FACTORY_IO_POS_BUFFER_H
0003 
0004 #include "Utilities/StorageFactory/interface/IOTypes.h"
0005 
0006 namespace edm::storage {
0007 
0008   /** Buffer for I/O operations. */
0009   struct IOPosBuffer {
0010   public:
0011     IOPosBuffer();
0012     IOPosBuffer(IOOffset offset, void *data, IOSize length);
0013     IOPosBuffer(IOOffset offset, const void *data, IOSize length);
0014 
0015     IOOffset offset() const;
0016     void *data() const;
0017     IOSize size() const;
0018 
0019     void set_offset(IOOffset new_offset);
0020     void set_data(void *new_buffer);
0021     void set_size(IOSize new_size);
0022 
0023   private:
0024     IOOffset m_offset;  //< File offset.
0025     void *m_data;       //< Data
0026     IOSize m_length;    //< Length of data in bytes.
0027   };
0028 
0029   /** Construct a null I/O buffer.  */
0030   inline IOPosBuffer::IOPosBuffer(void) : m_offset(0), m_data(nullptr), m_length(0) {}
0031 
0032   /** Construct a I/O buffer for reading.  */
0033   inline IOPosBuffer::IOPosBuffer(IOOffset offset, void *data, IOSize length)
0034       : m_offset(offset), m_data(data), m_length(length) {}
0035 
0036   /** Construct a I/O buffer for writing.  */
0037   inline IOPosBuffer::IOPosBuffer(IOOffset offset, const void *data, IOSize length)
0038       : m_offset(offset), m_data(const_cast<void *>(data)), m_length(length) {}
0039 
0040   /** Return the file offset where I/O is expected to occur.  */
0041   inline IOOffset IOPosBuffer::offset(void) const { return m_offset; }
0042 
0043   /** Return a pointer to the beginning of the buffer's data area.  */
0044   inline void *IOPosBuffer::data(void) const { return m_data; }
0045 
0046   /** Return the buffer's size.  */
0047   inline IOSize IOPosBuffer::size(void) const { return m_length; }
0048 
0049   /** Update the file offset */
0050   inline void IOPosBuffer::set_offset(IOOffset new_offset) { m_offset = new_offset; }
0051 
0052   /** Update the buffer's data area */
0053   inline void IOPosBuffer::set_data(void *new_data) { m_data = new_data; }
0054 
0055   /** Update the buffer's size */
0056   inline void IOPosBuffer::set_size(IOSize new_length) { m_length = new_length; }
0057 }  // namespace edm::storage
0058 #endif  // STORAGE_FACTORY_IO_POS_BUFFER_H