AGX Dynamics  2.35.0.1
agxData/StackArray.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXDATA_STACKARRAY_H
18 #define AGXDATA_STACKARRAY_H
19 
20 #include <agxData/Array.h>
21 
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning (disable: 4324) // : 'agxData::StackArray<T,N>' : structure was padded due to __declspec(align()))
25 #endif
26 
27 namespace agxData
28 {
29  template <typename T, size_t N>
30  class StackArray : public Array<T>
31  {
32 
33  public:
34  StackArray(const T& defaultValue = T());
35 
36  private:
37  T m_elements[N];
38  };
39 
40 
41 
42  /* Implementation */
43  template <typename T, size_t N>
45  {
46  this->m_ptr = m_elements;
47  this->m_buffer = nullptr;
48  this->m_range = agx::IndexRange32(0, N);
49 
50  for (size_t i = 0; i < N; ++i)
51  m_elements[i] = defaultValue;
52  }
53 
54  #if 0
55  template <typename T>
56  class Array2 : public StackArray<T, 2>
57  {
58  public:
59  Array2(const T& val0, const T& val1);
60  };
61 
62  template <typename T>
63  AGX_FORCE_INLINE Array2<T>::Array2(const T& val0, const T& val1)
64  {
65  (*this)[0] = val0;
66  (*this)[1] = val1;
67  }
68  #endif
69 
70 }
71 
72 #ifdef _MSC_VER
73 #pragma warning(pop)
74 #endif
75 
76 
77 #endif /* AGXDATA_STACKARRAY_H */
#define m_elements
Definition: agx/Vector.h:428
Type-specific Array used for fast access into the data held by a Buffer.
Definition: Array.h:107
StackArray(const T &defaultValue=T())
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contains classes for low level data storage for AGX.
Definition: Container.h:23
IndexRangeT< agx::UInt32 > IndexRange32
Definition: IndexRange.h:141