36#include "foundation/Px.h"
71template <
typename enumtype,
typename storagetype = u
int32_t>
75 typedef storagetype InternalType;
85 PX_CUDA_CALLABLE
PX_INLINE bool operator==(enumtype e)
const;
87 PX_CUDA_CALLABLE
PX_INLINE bool operator==(
bool b)
const;
88 PX_CUDA_CALLABLE
PX_INLINE bool operator!=(enumtype e)
const;
111 PX_CUDA_CALLABLE
PX_INLINE operator bool(
void)
const;
112 PX_CUDA_CALLABLE
PX_INLINE operator uint8_t(
void)
const;
113 PX_CUDA_CALLABLE
PX_INLINE operator uint16_t(
void)
const;
114 PX_CUDA_CALLABLE
PX_INLINE operator uint32_t(
void)
const;
116 PX_CUDA_CALLABLE
PX_INLINE void clear(enumtype e);
117 PX_CUDA_CALLABLE
PX_INLINE void raise(enumtype e);
118 PX_CUDA_CALLABLE
PX_INLINE bool isSet(enumtype e)
const;
125 out.mBits = a & b.mBits;
135#define PX_FLAGS_OPERATORS(enumtype, storagetype) \
136 PX_CUDA_CALLABLE PX_INLINE PxFlags<enumtype, storagetype> operator|(enumtype a, enumtype b) \
138 PxFlags<enumtype, storagetype> r(a); \
142 PX_CUDA_CALLABLE PX_INLINE PxFlags<enumtype, storagetype> operator&(enumtype a, enumtype b) \
144 PxFlags<enumtype, storagetype> r(a); \
148 PX_CUDA_CALLABLE PX_INLINE PxFlags<enumtype, storagetype> operator~(enumtype a) \
150 return ~PxFlags<enumtype, storagetype>(a); \
153#define PX_FLAGS_TYPEDEF(x, y) \
154 typedef PxFlags<x::Enum, y> x##s; \
155 PX_FLAGS_OPERATORS(x::Enum, y)
157template <
typename enumtype,
typename storagetype>
163template <
typename enumtype,
typename storagetype>
164PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::PxFlags(enumtype e)
166 mBits =
static_cast<storagetype
>(e);
169template <
typename enumtype,
typename storagetype>
170PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::PxFlags(
const PxFlags<enumtype, storagetype>& f)
175template <
typename enumtype,
typename storagetype>
176PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::PxFlags(storagetype b)
181template <
typename enumtype,
typename storagetype>
182PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::operator==(enumtype e)
const
184 return mBits ==
static_cast<storagetype
>(e);
187template <
typename enumtype,
typename storagetype>
188PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::operator==(
const PxFlags<enumtype, storagetype>& f)
const
190 return mBits == f.mBits;
193template <
typename enumtype,
typename storagetype>
194PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::operator==(
bool b)
const
196 return bool(*
this) == b;
199template <
typename enumtype,
typename storagetype>
200PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::operator!=(enumtype e)
const
202 return mBits !=
static_cast<storagetype
>(e);
205template <
typename enumtype,
typename storagetype>
206PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::operator!=(
const PxFlags<enumtype, storagetype>& f)
const
208 return mBits != f.mBits;
211template <
typename enumtype,
typename storagetype>
212PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::operator=(enumtype e)
214 mBits =
static_cast<storagetype
>(e);
218template <
typename enumtype,
typename storagetype>
219PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::operator=(
const PxFlags<enumtype, storagetype>& f)
225template <
typename enumtype,
typename storagetype>
226PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::operator|=(enumtype e)
228 mBits |=
static_cast<storagetype
>(e);
232template <
typename enumtype,
typename storagetype>
233PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::
234operator|=(
const PxFlags<enumtype, storagetype>& f)
240template <
typename enumtype,
typename storagetype>
241PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::operator|(enumtype e)
const
243 PxFlags<enumtype, storagetype> out(*
this);
248template <
typename enumtype,
typename storagetype>
249PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::
250operator|(
const PxFlags<enumtype, storagetype>& f)
const
252 PxFlags<enumtype, storagetype> out(*
this);
257template <
typename enumtype,
typename storagetype>
258PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::operator&=(enumtype e)
260 mBits &=
static_cast<storagetype
>(e);
264template <
typename enumtype,
typename storagetype>
265PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::
266operator&=(
const PxFlags<enumtype, storagetype>& f)
272template <
typename enumtype,
typename storagetype>
273PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::operator&(enumtype e)
const
275 PxFlags<enumtype, storagetype> out = *
this;
276 out.mBits &=
static_cast<storagetype
>(e);
280template <
typename enumtype,
typename storagetype>
281PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::
282operator&(
const PxFlags<enumtype, storagetype>& f)
const
284 PxFlags<enumtype, storagetype> out = *
this;
285 out.mBits &= f.mBits;
289template <
typename enumtype,
typename storagetype>
290PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::operator^=(enumtype e)
292 mBits ^=
static_cast<storagetype
>(e);
296template <
typename enumtype,
typename storagetype>
297PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::
298operator^=(
const PxFlags<enumtype, storagetype>& f)
304template <
typename enumtype,
typename storagetype>
305PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::operator^(enumtype e)
const
307 PxFlags<enumtype, storagetype> out = *
this;
308 out.mBits ^=
static_cast<storagetype
>(e);
312template <
typename enumtype,
typename storagetype>
313PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::
314operator^(
const PxFlags<enumtype, storagetype>& f)
const
316 PxFlags<enumtype, storagetype> out = *
this;
317 out.mBits ^= f.mBits;
321template <
typename enumtype,
typename storagetype>
322PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype> PxFlags<enumtype, storagetype>::operator~(
void)
const
324 PxFlags<enumtype, storagetype> out;
325 out.mBits = storagetype(~mBits);
329template <
typename enumtype,
typename storagetype>
330PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::operator bool(
void)
const
332 return mBits ? true :
false;
335template <
typename enumtype,
typename storagetype>
336PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::operator
uint8_t(
void)
const
338 return static_cast<uint8_t>(mBits);
341template <
typename enumtype,
typename storagetype>
342PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::operator
uint16_t(
void)
const
344 return static_cast<uint16_t>(mBits);
347template <
typename enumtype,
typename storagetype>
348PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>::operator
uint32_t(
void)
const
350 return static_cast<uint32_t>(mBits);
353template <
typename enumtype,
typename storagetype>
354PX_CUDA_CALLABLE
PX_INLINE void PxFlags<enumtype, storagetype>::clear(enumtype e)
356 mBits &= ~static_cast<storagetype>(e);
359template <
typename enumtype,
typename storagetype>
360PX_CUDA_CALLABLE
PX_INLINE void PxFlags<enumtype, storagetype>::raise(enumtype e)
362 mBits |=
static_cast<storagetype
>(e);
365template <
typename enumtype,
typename storagetype>
366PX_CUDA_CALLABLE
PX_INLINE bool PxFlags<enumtype, storagetype>::isSet(enumtype e)
const
368 return (mBits &
static_cast<storagetype
>(e)) ==
static_cast<storagetype
>(e);
371template <
typename enumtype,
typename storagetype>
372PX_CUDA_CALLABLE
PX_INLINE PxFlags<enumtype, storagetype>& PxFlags<enumtype, storagetype>::setAll(enumtype e)
374 mBits =
static_cast<storagetype
>(e);
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
#define PX_INLINE
Definition PxPreprocessor.h:320
uint32 uint32_t
Definition fwd.hpp:131
uint8 uint8_t
Definition fwd.hpp:103
uint16 uint16_t
Definition fwd.hpp:117
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxEMPTY
Definition Px.h:87