OpenBarnyard
 
Loading...
Searching...
No Matches
T2Array.h
Go to the documentation of this file.
1#pragma once
2
4
5template <class T, TINT Capacity>
6class T2Array
7{
8public:
9 void InitialiseAll( const T& a_oValue )
10 {
11 for ( TINT i = 0; i < Capacity; i++ )
12 {
13 this->operator[]( i ) = a_oValue;
14 }
15 }
16
18 {
19 return Capacity;
20 }
21
22 T* GetArray() const
23 {
24 return TREINTERPRETCAST( T*, m_pData );
25 }
26
27 T& operator[]( TINT a_iIndex )
28 {
29 TASSERT( a_iIndex >= 0 && a_iIndex < Capacity );
30 return *( TREINTERPRETCAST( T*, m_pData ) + a_iIndex );
31 }
32
33 const T& operator[]( TINT a_iIndex ) const
34 {
35 TASSERT( a_iIndex >= 0 && a_iIndex < Capacity );
36 return *( TREINTERPRETCAST( T*, m_pData ) + a_iIndex );
37 }
38
39private:
40 TCHAR m_pData[ sizeof( T ) * Capacity ];
41};
42
#define TASSERT(X,...)
Definition Defines.h:138
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
char TCHAR
Definition Typedefs.h:20
int TINT
Definition Typedefs.h:7
const T & operator[](TINT a_iIndex) const
Definition T2Array.h:33
void InitialiseAll(const T &a_oValue)
Definition T2Array.h:9
T & operator[](TINT a_iIndex)
Definition T2Array.h:27
TINT GetCapacity() const
Definition T2Array.h:17
T * GetArray() const
Definition T2Array.h:22