23 template <
typename T>
class UT_Array;
194 #define GA_MAX_ORDER 11
231 #define GA_PAGE_BITS 10
232 #define GA_PAGE_SIZE (1 << GA_PAGE_BITS)
233 #define GA_PAGE_MASK (GA_PAGE_SIZE - 1)
234 #define GA_DEFRAGMENT_OCCUPANCY 0.95
246 #if !defined(GA_STRICT_TYPES) && UT_ASSERT_LEVEL > 2
247 #define GA_STRICT_TYPES 0
250 #if defined(GA_STRICT_TYPES)
252 #if (UT_ASSERT_LEVEL >= UT_ASSERT_LEVEL_NORMAL)
253 #define GA_MAGIC_BAD_VALUE 0x7BADF00D7F00DBAD
256 #if (UT_ASSERT_LEVEL < UT_ASSERT_LEVEL_NORMAL)
266 #define GA_DEFINE_ORDINAL_METHODS_EXTRA \
267 size_t operator*(size_t v) const { return myVal * v; } \
268 friend size_t operator*(size_t v, const ThisType &a) { return v * a.myVal; }
270 #define GA_DEFINE_ORDINAL_METHODS_EXTRA
274 #define GA_DEFINE_ORDINAL_METHODS \
275 GA_DEFINE_ORDINAL_METHODS_EXTRA \
276 bool operator==(const ThisType &that) const { return (myVal == that.myVal); } \
277 bool operator!=(const ThisType &that) const { return (myVal != that.myVal); } \
278 bool operator<(const ThisType &that) const { return (myVal < that.myVal); } \
279 bool operator<=(const ThisType &that) const { return (myVal <= that.myVal); } \
280 bool operator>(const ThisType &that) const { return (myVal > that.myVal); } \
281 bool operator>=(const ThisType &that) const { return (myVal >= that.myVal); } \
282 exint operator&(exint v) const { return myVal & v; } \
283 exint operator&(int v) const { return myVal & v; } \
284 exint operator&(uint v) const { return myVal & v; } \
285 exint operator>>(exint v) const { return myVal >> v; } \
286 exint operator>>(int v) const { return myVal >> v; } \
287 exint operator>>(uint v) const { return myVal >> v; } \
288 exint operator*(exint v) const { return myVal * v; } \
289 exint operator*(int v) const { return myVal * v; } \
290 exint operator*(uint v) const { return myVal * v; } \
291 exint operator*(uint64 v) const { return exint(myVal * v); } \
292 ThisType operator+(const ThisType &that) const { return ThisType(myVal + that.myVal); } \
293 ThisType operator+(exint v) const { return ThisType(myVal + v); } \
294 ThisType operator+(uint64 v) const { return ThisType(myVal + v); } \
295 ThisType operator+(int v) const { return ThisType(myVal + v); } \
296 ThisType operator+(uint v) const { return ThisType(myVal + v); } \
297 friend ThisType operator+(exint v, const ThisType &a) { return ThisType(a.myVal + v); } \
298 friend ThisType operator+(uint64 v, const ThisType &a) { return ThisType(a.myVal + v); } \
299 friend ThisType operator+(int v, const ThisType &a) { return ThisType(a.myVal + v); } \
300 friend ThisType operator+(uint v, const ThisType &a) { return ThisType(a.myVal + v); } \
301 friend exint operator*(exint v, const ThisType &a) { return ThisType(a.myVal * v); } \
302 friend exint operator*(uint64 v, const ThisType &a) { return ThisType(a.myVal * v); } \
303 friend exint operator*(int v, const ThisType &a) { return ThisType(a.myVal * v); } \
304 friend exint operator*(uint v, const ThisType &a) { return ThisType(a.myVal * v); } \
307 exint operator/(uint v) const { return myVal/v; } \
308 exint operator/(int v) const { return myVal/v; } \
309 exint operator/(uint64 v) const { return myVal/v; } \
310 exint operator/(int64 v) const { return myVal/v; } \
311 ThisType operator-(const ThisType &that) const { return ThisType(myVal - that.myVal); } \
312 ThisType operator-(exint v) const { return ThisType(myVal - v); } \
313 ThisType operator-(uint64 v) const { return ThisType(myVal - v); } \
314 ThisType operator-(int v) const { return ThisType(myVal - v); } \
315 ThisType operator-(uint v) const { return ThisType(myVal - v); } \
316 ThisType operator+=(const ThisType &that) { myVal += that.myVal; return *this; } \
317 ThisType operator+=(exint v) { myVal += v; return *this; } \
318 ThisType operator+=(uint64 v){ myVal += v; return *this; } \
319 ThisType operator+=(int v) { myVal += v; return *this; } \
320 ThisType operator+=(uint v) { myVal += v; return *this; } \
321 ThisType operator-=(const ThisType &that) { myVal -= that.myVal; return *this; } \
322 ThisType operator-=(exint v) { myVal -= v; return *this; } \
323 ThisType operator-=(uint64 v){ myVal -= v; return *this; } \
324 ThisType operator-=(int v) { myVal -= v; return *this; } \
325 ThisType operator-=(uint v) { myVal -= v; return *this; } \
326 ThisType & operator++() { ++myVal; return *this; } \
327 ThisType operator++(int) { return ThisType(myVal++); } \
328 ThisType & operator--() { --myVal; return *this; } \
329 ThisType operator--(int) { return ThisType(myVal--); } \
330 ThisType operator-() { return ThisType(-myVal); } \
331 friend std::ostream &operator<< (std::ostream &stream, const ThisType &a) { return stream << a.myVal; } \
332 friend ThisType SYSmax(const ThisType &a, const ThisType &b) \
333 { return ThisType(SYSmax(a.myVal, b.myVal)); } \
334 friend ThisType SYSmin(const ThisType &a, const ThisType &b) \
335 { return ThisType(SYSmin(a.myVal, b.myVal)); } \
336 friend ThisType SYSclamp(const ThisType &a, const ThisType &b, const ThisType &c) \
337 { return ThisType(SYSclamp(a.myVal, b.myVal, c.myVal)); } \
338 friend ThisType UTbumpAlloc(const ThisType &a) \
339 { return ThisType(UTbumpAlloc(a.myVal)); } \
343 template <
typename TAG,
typename BASE_TYPE>
347 typedef GA_OrdinalType<TAG, BASE_TYPE> ThisType;
351 #if (UT_ASSERT_LEVEL >= UT_ASSERT_LEVEL_NORMAL)
352 : myVal(BASE_TYPE(GA_MAGIC_BAD_VALUE))
355 explicit GA_OrdinalType(
const BASE_TYPE &
val) : myVal(val) { }
357 operator BASE_TYPE()
const {
return myVal; }
359 GA_DEFINE_ORDINAL_METHODS
377 #if (UT_ASSERT_LEVEL >= UT_ASSERT_LEVEL_NORMAL)
378 : myVal(GA_MAGIC_BAD_VALUE)
383 operator int64()
const {
return myVal; }
384 operator uint64()
const {
return myVal; }
389 operator int32()
const {
return myVal; }
390 operator uint32()
const {
return myVal; }
391 operator int16()
const {
return myVal; }
392 operator uint16()
const {
return myVal; }
393 operator int8()
const {
return myVal; }
394 operator uint8()
const {
return myVal; }
399 operator long()
const {
return myVal; }
400 operator unsigned long()
const {
return myVal; }
403 GA_DEFINE_ORDINAL_METHODS
411 explicit operator bool()
const;
445 #if (UT_ASSERT_LEVEL >= UT_ASSERT_LEVEL_NORMAL)
446 : myVal(GA_MAGIC_BAD_VALUE)
451 operator int64()
const {
return myVal; }
452 operator uint64()
const {
return myVal; }
457 operator int32()
const {
return myVal; }
458 operator uint32()
const {
return myVal; }
459 operator int16()
const {
return myVal; }
460 operator uint16()
const {
return myVal; }
461 operator int8()
const {
return myVal; }
462 operator uint8()
const {
return myVal; }
466 operator long()
const {
return myVal; }
467 operator unsigned long()
const {
return myVal; }
470 GA_DEFINE_ORDINAL_METHODS
489 bool operator< (
int v)
const {
return (myVal < v); }
490 bool operator<=(
int v)
const {
return (myVal <= v); }
491 bool operator> (
int v)
const {
return (myVal > v); }
492 bool operator>=(
int v)
const {
return (myVal >= v); }
493 bool operator==(
int v)
const {
return (myVal == v); }
494 bool operator!=(
int v)
const {
return (myVal != v); }
504 bool operator< (
unsigned long v)
const {
return (myVal < v); }
505 bool operator<=(
unsigned long v)
const {
return (myVal <= v); }
506 bool operator> (
unsigned long v)
const {
return (myVal > v); }
507 bool operator>=(
unsigned long v)
const {
return (myVal >= v); }
508 bool operator==(
unsigned long v)
const {
return (myVal == v); }
509 bool operator!=(
unsigned long v)
const {
return (myVal != v); }
539 friend bool operator<(
unsigned long v,
const GA_Index &a) {
return (v < a.myVal); }
541 friend bool operator>(
unsigned long v,
const GA_Index &a) {
return (v > a.myVal); }
549 explicit operator bool()
const {
return myVal != 0; }
564 #undef GA_DEFINE_ORDINAL_BINARY_OPS
565 #undef GA_DEFINE_ORDINAL_METHODS
568 class GA_PageNumTag {};
569 typedef GA_OrdinalType<GA_PageNumTag, GA_Size>
GA_PageNum;
573 class GA_PageOffTag {};
574 typedef GA_OrdinalType<GA_PageOffTag, GA_Size>
GA_PageOff;
592 struct DefaultClearer;
601 static void clearConstruct(
GA_Offset *p) { clear(*p); }
603 static const bool clearNeedsDestruction =
false;
613 static void clearConstruct(
GA_Index *p) { clear(*p); }
615 static const bool clearNeedsDestruction =
false;
624 {
return std::hash<exint>()((
exint)v); }
629 size_t operator()(GA_Index v)
630 {
return std::hash<exint>()((
exint)v); }
664 #if defined(GA_STRICT_TYPES)
688 const GA_Offset &
end)
693 #define GA_INVALID_INDEX GA_Index(-1)
694 #define GA_INVALID_OFFSET GA_Offset(-1)
697 #define GA_DETAIL_INDEX GA_Index(0)
698 #define GA_DETAIL_OFFSET GA_Offset(0)
704 #define GA_INVALID_DATAID GA_DataId(-1)
712 #define GA_INVALID_INTRINSIC_HANDLE -1
713 static inline bool GAisValidGlobalIntrinsic(GA_GlobalIntrinsic
h)
715 static inline bool GAisValidLocalIntrinsic(GA_LocalIntrinsic
h)
786 static inline bool GAisStorageType(
int s)
811 static inline bool GAisNumericStorage(
GA_Storage s)
813 return GAisFloatStorage(s) || GAisIntStorage(s);
GA_API const char * GAtypeinfoLabel(GA_TypeInfo type)
Lookup the type-info label (descriptive name) from the type-info type.
GA_API const char * GAstorageClass(GA_StorageClass store)
Lookup the storage name from the storage type.
bool GAisFullPage(GA_Offset start, GA_Offset end)
GLenum GLuint GLenum GLsizei const GLchar * buf
Data has no numeric representation.
GLenum GLuint GLsizei bufsize
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
constexpr size_t SYShash(const SYS_Flicks f)
UT_Array< GA_Index > GA_IndexArray
GA_API const char * GAowner(GA_AttributeOwner owner)
Lookup the owner name from the owner type.
GA_API const char * GAgroupType(GA_GroupType owner)
Lookup the owner name from the owner type.
Data represents a color. Token "color".
GA_API const char * GAtypeinfo(GA_TypeInfo type)
Lookup the type-info name from the type-info type.
GLboolean GLboolean GLboolean GLboolean a
std::size_t SYS_HashType
Define the type for hash values.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Standard user attribute level.
unsigned long long uint64
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
exint GA_Size
Defines the bit width for index and offset types in GA.
SYS_FORCE_INLINE GA_PageOff GAgetPageOff(GA_Offset v)
OIIO_FORCEINLINE vbool4 operator>=(const vint4 &a, const vint4 &b)
GA_API GA_Precision GAprecision(GA_Storage a)
Return the precision associated with the storage.
UT_Array< GA_Offset > GA_OffsetArray
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
GA_API const char * GAstorage(GA_Storage store)
Lookup the storage name from the storage type.
OIIO_FORCEINLINE vbool4 operator>(const vint4 &a, const vint4 &b)
OIIO_FORCEINLINE vbool4 operator<=(const vint4 &a, const vint4 &b)
GLint GLint GLsizei GLint GLenum GLenum type
SYS_FORCE_INLINE GA_PageNum GAgetPageNum(GA_Offset v)
#define SYS_DECLARE_IS_POD(T)
Declare a type as POD.
GA_API int GAprecisionBits(GA_Precision precision)
Returns the nominal bits of provided precision, 0 for invalid.
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
Data has no numeric representation.
GA_API const char * GAstorageLabel(GA_Storage store)
Lookup the storage label (descriptive name) from the storage type.
GLboolean GLboolean GLboolean b
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
GA_API size_t UTformatBuffer(char *buffer, size_t buffer_size, const GA_AttributeOwner &v)
GA_API int GAcomparePrecision(GA_Storage a, GA_Storage b)
GLenum GLint GLint * precision
Data represents a quaternion. Token "quaternion".
GLfloat GLfloat GLfloat GLfloat h
GA_API const char * GAscope(GA_AttributeScope scope)
Lookup the scope name from the scope type.
Data represents a normal vector. Token "normal".
GA_GroupType
An ordinal enum for the different types of groups in GA.
#define GA_PAGE_BITS
Attributes may paritition their data in pages of GA_PAGE_SIZE offsets.
Data represents a direction vector. Token "vector".
Data represents a position in space. Token "point".
#define UT_IFNOT_ASSERT(ZZ)
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Data represents an index-pair. Token "indexpair".
GA_API unsigned GAsizeof(GA_Storage store)
Lookup the size in bytes of a storage type (inaccurate for bool)
size_t hash_value(const CH_ChannelRef &ref)
Data represents a transform matrix. Token "matrix".
GA_Offset GAgetPageBoundary(const GA_Offset &start, const GA_Offset &end)