ATLAS Offline Software
v5_DataBuffer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "v5_DataBuffer.h"
7 
8 #include <string.h>
9 
11 
12 public:
13 
15  m_buffer(0),
16  m_buffersize(0){}
17 
19  m_buffer(0),
20  m_buffersize(0){
21  m_buffer = new char[size];
23  }
24 
25  implementation (const implementation&) = delete;
27 
29  { delete[] m_buffer; }
30 
31 
32  void realloc(const uint32_t& newsize)
33  {
34  delete[] m_buffer;
35  m_buffer = new char[newsize];
36  m_buffersize = newsize;
37  }
38 
39  void grow(const uint32_t& newsize)
40  {
41  if(newsize <= m_buffersize)
42  return;
43 
44  char * new_buffer = new char[newsize];
45  ::memcpy(new_buffer, m_buffer, m_buffersize);
46  delete[] m_buffer;
47 
48  m_buffer = new_buffer;
49  m_buffersize = newsize;
50  }
51 
52  void * handle()
53  { return m_buffer; }
54 
56  { return m_buffersize; }
57 
58 private:
59  char* m_buffer;
61 
62 };
63 
65  m_rep(new implementation())
66 {}
67 
69  m_rep(new implementation(size))
70 {}
71 
73 { delete m_rep; }
74 
76 { return m_rep->realloc(newsize); }
77 
79 { return m_rep->grow(newsize); }
80 
82 { return m_rep->handle(); }
83 
85 { return m_rep->buffersize(); }
offline_EventStorage_v5::DataBuffer::implementation::implementation
implementation(const uint32_t &size)
Definition: v5_DataBuffer.cxx:18
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
offline_EventStorage_v5::DataBuffer::~DataBuffer
virtual ~DataBuffer()
Definition: v5_DataBuffer.cxx:72
offline_EventStorage_v5::DataBuffer::implementation::handle
void * handle()
Definition: v5_DataBuffer.cxx:52
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
v5_DataBuffer.h
offline_EventStorage_v5::DataBuffer::implementation::m_buffer
char * m_buffer
Definition: v5_DataBuffer.cxx:59
offline_EventStorage_v5::DataBuffer::grow
void grow(const uint32_t &newsize)
Definition: v5_DataBuffer.cxx:78
offline_EventStorage_v5::DataBuffer::handle
void * handle()
Definition: v5_DataBuffer.cxx:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
offline_EventStorage_v5::DataBuffer::implementation
Definition: v5_DataBuffer.cxx:10
offline_EventStorage_v5::DataBuffer::implementation::operator=
implementation & operator=(const implementation &)=delete
offline_EventStorage_v5::DataBuffer::implementation::~implementation
~implementation()
Definition: v5_DataBuffer.cxx:28
offline_EventStorage_v5::DataBuffer::DataBuffer
DataBuffer()
Definition: v5_DataBuffer.cxx:64
offline_EventStorage_v5::DataBuffer::implementation::implementation
implementation()
Definition: v5_DataBuffer.cxx:14
offline_EventStorage_v5::DataBuffer::realloc
void realloc(const uint32_t &newsize)
Definition: v5_DataBuffer.cxx:75
offline_EventStorage_v5::DataBuffer::implementation::grow
void grow(const uint32_t &newsize)
Definition: v5_DataBuffer.cxx:39
offline_EventStorage_v5::DataBuffer::implementation::realloc
void realloc(const uint32_t &newsize)
Definition: v5_DataBuffer.cxx:32
offline_EventStorage_v5::DataBuffer::implementation::buffersize
uint32_t buffersize() const
Definition: v5_DataBuffer.cxx:55
offline_EventStorage_v5::DataBuffer::buffersize
uint32_t buffersize() const
Definition: v5_DataBuffer.cxx:84
offline_EventStorage_v5::DataBuffer::implementation::implementation
implementation(const implementation &)=delete
offline_EventStorage_v5::DataBuffer::implementation::m_buffersize
uint32_t m_buffersize
Definition: v5_DataBuffer.cxx:60