npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
PtrBufferHandle.hh
1 #ifndef NPSTAT_PTRBUFFERHANDLE_HH_
2 #define NPSTAT_PTRBUFFERHANDLE_HH_
3 
4 //======================================================================
5 // PtrBufferHandle.hh
6 //
7 // This is an internal header which is subject to change without notice.
8 // Application code should never use the classes declared/defined in
9 // this header directly.
10 //
11 // Author: I. Volobouev
12 //
13 // June 2015
14 //======================================================================
15 
16 #include <cassert>
17 
18 namespace npstat {
19  namespace Private {
20  template <class T>
22  {
23  public:
24  inline PtrBufferHandle(T** buf, const unsigned len)
25  : buf_(buf), len_(len) {if (len_) assert(buf_);}
26 
27  inline ~PtrBufferHandle()
28  {
29  for (unsigned i=0; i<len_; ++i)
30  delete buf_[i];
31  }
32 
33  inline T** release()
34  {
35  T** b = buf_;
36  buf_ = 0;
37  len_ = 0U;
38  return b;
39  }
40 
41  private:
44  PtrBufferHandle& operator=(const PtrBufferHandle&);
45 
46  T** buf_;
47  unsigned len_;
48  };
49  }
50 }
51 
52 #endif // NPSTAT_PTRBUFFERHANDLE_HH_
Definition: PtrBufferHandle.hh:22
Definition: AbsArrayProjector.hh:14