NvBlastFixedBoolArray.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef NVBLASTFIXEDBOOLARRAY_H
30 #define NVBLASTFIXEDBOOLARRAY_H
31 
32 #include "NvBlastAssert.h"
33 #include "NvBlastMemory.h"
34 #include <cstring>
35 
36 namespace Nv
37 {
38 namespace Blast
39 {
40 
64 {
65 public:
66  explicit FixedBoolArray(uint32_t size)
67  {
68  m_size = size;
69  }
70 
71  static size_t requiredMemorySize(uint32_t size)
72  {
73  return align16(sizeof(FixedBoolArray)) + align16(size);
74  }
75 
76  void clear()
77  {
78  memset(data(), 0, m_size);
79  }
80 
81  void fill()
82  {
83  memset(data(), 1, m_size);
84  }
85 
86  int test(uint32_t index) const
87  {
88  NVBLAST_ASSERT(index < m_size);
89  return data()[index];
90  }
91 
92  void set(uint32_t index)
93  {
94  NVBLAST_ASSERT(index < m_size);
95  data()[index] = 1;
96  }
97 
98  void reset(uint32_t index)
99  {
100  NVBLAST_ASSERT(index < m_size);
101  data()[index] = 0;
102  }
103 
104 private:
105  uint32_t m_size;
106 
107  NV_FORCE_INLINE char* data()
108  {
109  return ((char*)this + sizeof(FixedBoolArray));
110  }
111 
112  NV_FORCE_INLINE const char* data() const
113  {
114  return ((char*)this + sizeof(FixedBoolArray));
115  }
116 
117 private:
118  FixedBoolArray(const FixedBoolArray& that);
119 };
120 
121 } // namespace Blast
122 } // namespace Nv
123 
124 #endif // ifndef NVBLASTFIXEDBOOLARRAY_H
Definition: NvBlastFixedBoolArray.h:63
int test(uint32_t index) const
Definition: NvBlastFixedBoolArray.h:86
static size_t requiredMemorySize(uint32_t size)
Definition: NvBlastFixedBoolArray.h:71
FixedBoolArray(uint32_t size)
Definition: NvBlastFixedBoolArray.h:66
#define NVBLAST_ASSERT(exp)
Definition: NvBlastAssert.h:37
void fill()
Definition: NvBlastFixedBoolArray.h:81
NV_INLINE T align16(T value)
Definition: NvBlastMemory.h:46
void clear()
Definition: NvBlastFixedBoolArray.h:76
Definition: NvBlastArray.h:37
void reset(uint32_t index)
Definition: NvBlastFixedBoolArray.h:98
#define NV_FORCE_INLINE
Definition: NvPreprocessor.h:365