GenApi  3.5.1
GCArray.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2014 by Teledyne DALSA
3 // Author: Eric Bourbonnais
4 //
5 // License: This file is published under the license of the EMVA GenICam Standard Group.
6 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
7 // If for some reason you are missing this file please contact the EMVA or visit the website
8 // (http://www.genicam.org) for a full copy.
9 //
10 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
11 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
12 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
13 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
14 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
15 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
17 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
18 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20 // POSSIBILITY OF SUCH DAMAGE.
21 //
22 //-----------------------------------------------------------------------------
28 #ifndef GCBASE_GCARRAY_H
29 #define GCBASE_GCARRAY_H
30 
31 #include <Base/GCTypes.h>
32 #include <Base/GCException.h>
33 namespace GENICAM_NAMESPACE
34 {
35  template< class T>
36  class gcarray
37  {
38  public:
39  gcarray(size_t size) : m_p(NULL)
40  {
41  if (size)
42  {
43  m_p = new T[size];
44  if (!m_p)
45  {
46  throw BAD_ALLOC_EXCEPTION("Unable to create gcarray");
47  }
48  }
49  };
50  ~gcarray(){ if(m_p) delete [] m_p;};
51  T* get() const {return m_p;} ;
52  T* operator *() {return m_p;} ;
53  T operator[](size_t idx) {return m_p[idx];} ;
54  private:
55  gcarray(const gcarray&); // copy constructor is not implemented
56  gcarray& operator =(const gcarray&); // assignment operator is not implemented
57  private:
58  T* m_p;
59  };
60 
61 }
62 
63 #endif // GCBASE_GCARRAY_H
#define BAD_ALLOC_EXCEPTION
Fires a bad alloc exception, e.g. throw BAD_ALLOC_EXCEPTION();.
Definition: GCException.h:234
Definition: GCArray.h:33
Standard GenICam Exceptions.
Platform-dependent type definitions.