Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef STORAGE_FACTORY_IO_BUFFER_H
0002 #define STORAGE_FACTORY_IO_BUFFER_H
0003 
0004 #include "Utilities/StorageFactory/interface/IOTypes.h"
0005 
0006 namespace edm::storage {
0007 
0008   /** Buffer for I/O operations. */
0009   class IOBuffer {
0010   public:
0011     IOBuffer();
0012     IOBuffer(void *data, IOSize length);
0013     IOBuffer(const void *data, IOSize length);
0014 
0015     void *data() const;
0016     IOSize size() const;
0017 
0018   private:
0019     void *m_data;     //< Data
0020     IOSize m_length;  //< Length of data in bytes.
0021   };
0022 
0023   /** Construct a null I/O buffer.  */
0024   inline IOBuffer::IOBuffer(void) : m_data(nullptr), m_length(0) {}
0025 
0026   /** Construct a I/O buffer for reading.  */
0027   inline IOBuffer::IOBuffer(void *data, IOSize length) : m_data(data), m_length(length) {}
0028 
0029   /** Construct a I/O buffer for writing.  */
0030   inline IOBuffer::IOBuffer(const void *data, IOSize length) : m_data(const_cast<void *>(data)), m_length(length) {}
0031 
0032   /** Return a pointer to the beginning of the buffer's data area.  */
0033   inline void *IOBuffer::data(void) const { return m_data; }
0034 
0035   /** Return the buffer's size.  */
0036   inline IOSize IOBuffer::size(void) const { return m_length; }
0037 }  // namespace edm::storage
0038 #endif  // STORAGE_FACTORY_IO_BUFFER_H