Belle II Software  release-08-01-10
WrapArray2D.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 
12 namespace Belle2 {
17  namespace ECL {
18  template <typename T>
23  class WrapArray2D {
24  public:
26  WrapArray2D(int rows, int cols) :
27  m_data(new T[rows * cols]), m_ncols(cols)
28  {}
29 
31  WrapArray2D(const WrapArray2D&) = delete;
32 
34  WrapArray2D& operator=(const WrapArray2D&) = delete;
35 
38  { delete [] m_data; }
39 
41  T* operator[](int irow)
42  {
43  return m_data + irow * m_ncols;
44  }
45 
47  operator T* () { return m_data; }
48  private:
49 
50  T* m_data;
51  int m_ncols;
52  };
53  }
55 }
class to replace POD 2D array to save stack usage since it just allocates memory dynamically.
Definition: WrapArray2D.h:23
T * m_data
content of the 2d array
Definition: WrapArray2D.h:50
T * operator[](int irow)
return row
Definition: WrapArray2D.h:41
WrapArray2D(int rows, int cols)
replace POD 2D array
Definition: WrapArray2D.h:26
int m_ncols
number of columns
Definition: WrapArray2D.h:51
WrapArray2D(const WrapArray2D &)=delete
no copy
WrapArray2D & operator=(const WrapArray2D &)=delete
no assignment
~WrapArray2D()
destructor
Definition: WrapArray2D.h:37
Abstract base class for different kinds of events.