HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_PageArray.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GA_PageArray.h (GA Library, C++)
7  *
8  * COMMENTS: An array class with special handling of constant pages and
9  * shared page data, specialized for GA_Offset.
10  */
11 
12 #pragma once
13 
14 #ifndef __GA_PageArray__
15 #define __GA_PageArray__
16 
17 #include "GA_Defaults.h"
18 #include "GA_Iterator.h"
19 #include "GA_Range.h"
20 #include "GA_Types.h"
21 #include <UT/UT_Assert.h>
22 #include <UT/UT_BitArray.h>
23 #include <UT/UT_FixedVector.h>
24 #include <UT/UT_JSONDefines.h>
25 #include <UT/UT_PageArray.h>
26 #include <UT/UT_Storage.h>
27 #include <UT/UT_UniquePtr.h>
28 #include <UT/UT_VectorTypes.h>
29 #include <SYS/SYS_Inline.h>
30 #include <SYS/SYS_Math.h>
31 #include <SYS/SYS_Types.h>
32 #include <SYS/SYS_TypeTraits.h>
33 
34 class GA_Defragment;
35 class GA_LoadMap;
36 class GA_MergeMap;
37 class GA_SaveOptions;
38 class UT_JSONParser;
39 class UT_JSONWriter;
40 template <typename T> class UT_Array;
41 
44 {
45  switch (storage)
46  {
48  return GA_STORE_INVALID;
49  case UT_Storage::INT8:
50  return GA_STORE_INT8;
51  case UT_Storage::INT16:
52  return GA_STORE_INT16;
53  case UT_Storage::INT32:
54  return GA_STORE_INT32;
55  case UT_Storage::INT64:
56  return GA_STORE_INT64;
57  case UT_Storage::REAL16:
58  return GA_STORE_REAL16;
59  case UT_Storage::REAL32:
60  return GA_STORE_REAL32;
61  case UT_Storage::REAL64:
62  return GA_STORE_REAL64;
63  }
64  UT_ASSERT_MSG_P(0, "Unhandled UT_Storage value!");
65  return GA_STORE_INVALID;
66 }
67 
70 {
71  switch (storage)
72  {
73  case GA_STORE_BOOL:
74  case GA_STORE_INVALID:
75  case GA_STORE_STRING:
76  return UT_Storage::INVALID;
77  case GA_STORE_INT8:
78  case GA_STORE_UINT8:
79  return UT_Storage::INT8;
80  case GA_STORE_INT16:
81  return UT_Storage::INT16;
82  case GA_STORE_INT32:
83  return UT_Storage::INT32;
84  case GA_STORE_INT64:
85  return UT_Storage::INT64;
86  case GA_STORE_REAL16:
87  return UT_Storage::REAL16;
88  case GA_STORE_REAL32:
89  return UT_Storage::REAL32;
90  case GA_STORE_REAL64:
91  return UT_Storage::REAL64;
92  }
93  UT_ASSERT_MSG_P(0, "Unhandled GA_Storage value!");
94  return UT_Storage::INVALID;
95 }
96 
97 template<typename DATA_T=void,exint TSIZE=-1,bool TABLEHARDENED=true,bool PAGESHARDENED=false>
98 class GA_PageArray : public UT_PageArray<DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, GA_PAGE_BITS, GA_Offset>
99 {
100 public:
103  using Base::get;
104  using Base::getPageData;
105  using Base::getRange;
106  using Base::getTupleSize;
107  using Base::getVector;
108  using Base::hardenPage;
110  using Base::isPageConstant;
111  using Base::moveRange;
112  using Base::numPages;
113  using Base::set;
114  using Base::setConstant;
115  using Base::setPageConstant;
116  using Base::setRange;
117  using Base::setSize;
118  using Base::setVector;
119  using Base::size;
120  using Base::swapRange;
121  using Base::thePageSize;
122  using Base::thePageMask;
123  using Base::tryCompressPage;
124  using Base::hardenTable;
125 private:
126  using typename Base::NotVoidType;
128  using Base::isEqual;
129  using Base::isZero;
130 public:
131 
132  /// The default constructor can only be used if the tuple size
133  /// and storage type are known at compile time.
134  /// Unfortunately, this can't be asserted at compile time, because
135  /// compilers aren't all that bright, but Base asserts it at runtime
136  /// if paranoid asserts are on.
138  {}
139 
140  /// This constructor can only be used if the storage type is
141  /// known at compile time, but the tuple size is not.
142  GA_PageArray(exint tuplesize) : Base(tuplesize)
143  {}
144 
145  /// This constructor can only be used if the storage type is
146  /// known at compile time, but the tuple size is not.
148  {}
149 
150  /// This constructor can only be used if the tuple size and
151  /// storage type are unknown at compile time.
152  GA_PageArray(exint tuplesize, UT_Storage storage) : Base(tuplesize, storage)
153  {}
154 
155  /// This constructor can only be used if the tuple size and
156  /// storage type are unknown at compile time.
157  GA_PageArray(exint tuplesize, GA_Storage storage) : Base(tuplesize, GAStorageToUTStorage(storage))
158  {}
159 
160  /// Get the storage type for each component of this GA_PageArray
163  {
165  return UTStorageToGAStorage(storage);
166  }
167  /// Set the storage type for each component of this GA_PageArray
169  {
170  UT_Storage utstorage = GAStorageToUTStorage(storage);
171  Base::setStorage(utstorage);
172  }
173 
174  template<typename SRC_T>
175  void setConstant(const GA_Range &range, SRC_T val)
176  {
177  if (!SYSisSame<DATA_T,void>())
178  {
179  // Easy case, where the storage type is known at compile time.
180  NotVoidType dval(val);
181 
183  GA_Offset end;
184  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
185  {
186  Base::setConstant(start, end, dval);
187  }
188  return;
189  }
190 
191  // Hard case, where the storage type is not known at compile time.
193  switch (storage)
194  {
195  case UT_Storage::INT8:
196  castType<int8>().setConstant(range, int8(val)); return;
197  case UT_Storage::INT16:
198  castType<int16>().setConstant(range, int16(val)); return;
199  case UT_Storage::INT32:
200  castType<int32>().setConstant(range, int32(val)); return;
201  case UT_Storage::INT64:
202  castType<int64>().setConstant(range, int64(val)); return;
203  case UT_Storage::REAL16:
204  castType<fpreal16>().setConstant(range, fpreal16(val)); return;
205  case UT_Storage::REAL32:
206  castType<fpreal32>().setConstant(range, fpreal32(val)); return;
207  case UT_Storage::REAL64:
208  castType<fpreal64>().setConstant(range, fpreal64(val)); return;
209  case UT_Storage::INVALID:
210  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
211  return;
212  }
213  }
214 
215  void setConstant(const GA_Range &range, const GA_Defaults &defaults)
216  {
217  if (!SYSisSame<DATA_T,void>())
218  {
220  GA_Offset end;
221  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
222  {
223  Base::setConstant(start, end, defaults);
224  }
225  return;
226  }
227 
228  // Hard case, where the storage type is not known at compile time.
230  switch (storage)
231  {
232  case UT_Storage::INT8:
233  castType<int8>().setConstant(range, defaults); return;
234  case UT_Storage::INT16:
235  castType<int16>().setConstant(range, defaults); return;
236  case UT_Storage::INT32:
237  castType<int32>().setConstant(range, defaults); return;
238  case UT_Storage::INT64:
239  castType<int64>().setConstant(range, defaults); return;
240  case UT_Storage::REAL16:
241  castType<fpreal16>().setConstant(range, defaults); return;
242  case UT_Storage::REAL32:
243  castType<fpreal32>().setConstant(range, defaults); return;
244  case UT_Storage::REAL64:
245  castType<fpreal64>().setConstant(range, defaults); return;
246  case UT_Storage::INVALID:
247  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
248  return;
249  }
250  }
251 
254  {
255  Base::setConstant(start, end, v);
256  }
257 
258  template<typename SRC_T>
260  {
261  if (!SYSisSame<DATA_T,void>())
262  {
263  // Easy case, where the storage type is known at compile time.
264  NotVoidType dval(val);
265 
266  Base::setConstant(start, end, dval);
267  return;
268  }
269 
270  // Hard case, where the storage type is not known at compile time.
272  switch (storage)
273  {
274  case UT_Storage::INT8:
275  castType<int8>().setConstant(start, end, int8(val)); return;
276  case UT_Storage::INT16:
277  castType<int16>().setConstant(start, end, int16(val)); return;
278  case UT_Storage::INT32:
279  castType<int32>().setConstant(start, end, int32(val)); return;
280  case UT_Storage::INT64:
281  castType<int64>().setConstant(start, end, int64(val)); return;
282  case UT_Storage::REAL16:
283  castType<fpreal16>().setConstant(start, end, fpreal16(val)); return;
284  case UT_Storage::REAL32:
285  castType<fpreal32>().setConstant(start, end, fpreal32(val)); return;
286  case UT_Storage::REAL64:
287  castType<fpreal64>().setConstant(start, end, fpreal64(val)); return;
288  case UT_Storage::INVALID:
289  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
290  return;
291  }
292  }
293 
294  template<typename SRC_T>
296  {
297  if (!SYSisSame<DATA_T,void>())
298  {
299  // Easy case, where the storage type is known at compile time.
301 
303  GA_Offset end;
304  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
305  {
306  Base::setConstant(start, end, dval);
307  }
308  return;
309  }
310 
311  // Hard case, where the storage type is not known at compile time.
313  switch (storage)
314  {
315  case UT_Storage::INT8:
316  castType<int8>().setConstantVector(range, UT_FixedVector<int8,theSafeTupleSize>(val)); return;
317  case UT_Storage::INT16:
318  castType<int16>().setConstantVector(range, UT_FixedVector<int16,theSafeTupleSize>(val)); return;
319  case UT_Storage::INT32:
320  castType<int32>().setConstantVector(range, UT_FixedVector<int32,theSafeTupleSize>(val)); return;
321  case UT_Storage::INT64:
322  castType<int64>().setConstantVector(range, UT_FixedVector<int64,theSafeTupleSize>(val)); return;
323  case UT_Storage::REAL16:
324  castType<fpreal16>().setConstantVector(range, UT_FixedVector<fpreal16,theSafeTupleSize>(val)); return;
325  case UT_Storage::REAL32:
326  castType<fpreal32>().setConstantVector(range, UT_FixedVector<fpreal32,theSafeTupleSize>(val)); return;
327  case UT_Storage::REAL64:
328  castType<fpreal64>().setConstantVector(range, UT_FixedVector<fpreal64,theSafeTupleSize>(val)); return;
329  case UT_Storage::INVALID:
330  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
331  return;
332  }
333  }
334 
335  template<typename SRC_T>
337  {
338  if (!SYSisSame<DATA_T,void>())
339  {
340  // Easy case, where the storage type is known at compile time.
342 
343  Base::setConstant(start, end, dval);
344  return;
345  }
346 
347  // Hard case, where the storage type is not known at compile time.
349  switch (storage)
350  {
351  case UT_Storage::INT8:
352  castType<int8>().setConstantVector(start, end, UT_FixedVector<int8,theSafeTupleSize>(val)); return;
353  case UT_Storage::INT16:
354  castType<int16>().setConstantVector(start, end, UT_FixedVector<int16,theSafeTupleSize>(val)); return;
355  case UT_Storage::INT32:
356  castType<int32>().setConstantVector(start, end, UT_FixedVector<int32,theSafeTupleSize>(val)); return;
357  case UT_Storage::INT64:
358  castType<int64>().setConstantVector(start, end, UT_FixedVector<int64,theSafeTupleSize>(val)); return;
359  case UT_Storage::REAL16:
360  castType<fpreal16>().setConstantVector(start, end, UT_FixedVector<fpreal16,theSafeTupleSize>(val)); return;
361  case UT_Storage::REAL32:
362  castType<fpreal32>().setConstantVector(start, end, UT_FixedVector<fpreal32,theSafeTupleSize>(val)); return;
363  case UT_Storage::REAL64:
364  castType<fpreal64>().setConstantVector(start, end, UT_FixedVector<fpreal64,theSafeTupleSize>(val)); return;
365  case UT_Storage::INVALID:
366  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
367  return;
368  }
369  }
370 
371  /// NOTE: values must have a number of values equal to the tuple size.
372  template<typename SRC_T>
373  void setConstant(const GA_Range &range, const SRC_T *values)
374  {
375  if (!SYSisSame<DATA_T,void>())
376  {
378  GA_Offset end;
379  for (GA_Iterator it(range); it.fullBlockAdvance(start, end); )
380  {
381  Base::setConstant(start, end, values);
382  }
383 
384  return;
385  }
386 
387  // Hard case, where the storage type is not known at compile time.
389  switch (storage)
390  {
391  case UT_Storage::INT8:
392  castType<int8>().setConstant(range, values); return;
393  case UT_Storage::INT16:
394  castType<int16>().setConstant(range, values); return;
395  case UT_Storage::INT32:
396  castType<int32>().setConstant(range, values); return;
397  case UT_Storage::INT64:
398  castType<int64>().setConstant(range, values); return;
399  case UT_Storage::REAL16:
400  castType<fpreal16>().setConstant(range, values); return;
401  case UT_Storage::REAL32:
402  castType<fpreal32>().setConstant(range, values); return;
403  case UT_Storage::REAL64:
404  castType<fpreal64>().setConstant(range, values); return;
405  case UT_Storage::INVALID:
406  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
407  return;
408  }
409  }
410 
411  /// NOTE: values must have a number of values equal to the tuple size.
412  template<typename SRC_T>
415  {
416  Base::setConstant(start, end, values);
417  }
418 
419  /// Include GA_PageArrayImpl.h to call this.
420  void defragment(const GA_Defragment &defrag);
421 
422  /// Include GA_PageArrayImpl.h to call this.
423  template<typename SRC_DATA_T,exint SRC_TSIZE,bool SRC_TABLEHARDENED,bool SRC_PAGESHARDENED>
425 
426  template<typename SRC_DATA_T,exint SRC_TSIZE,bool SRC_TABLEHARDENED,bool SRC_PAGESHARDENED>
428  {
429  GA_Iterator destit(destrange);
430  GA_Iterator srcit(srcrange);
431 
432  GA_Offset deststart = GA_INVALID_OFFSET;
433  GA_Offset destend = GA_INVALID_OFFSET;
434  GA_Offset srcstart = GA_INVALID_OFFSET;
435  GA_Offset srcend = GA_INVALID_OFFSET;
436 
437  while (true)
438  {
439  // If either range runs out, stop.
440  if (deststart == destend)
441  {
442  if (!destit.fullBlockAdvance(deststart, destend))
443  break;
444  }
445  if (srcstart == srcend)
446  {
447  if (!srcit.fullBlockAdvance(srcstart, srcend))
448  break;
449  }
450 
451  GA_Offset nelements = SYSmin(destend-deststart, srcend-srcstart);
452 
453  moveRange(src, srcstart, deststart, nelements);
454 
455  deststart += nelements;
456  srcstart += nelements;
457  }
458  }
459 
460  template<typename T>
461  void getRange(const GA_Range &srcrange, T *dest) const
462  {
463  if (SYSisSame<DATA_T,void>())
464  {
465  // Hard case, where the storage type is not known at compile time.
467  switch (storage)
468  {
469  case UT_Storage::INT8:
470  castType<int8>().getRange(srcrange, dest); return;
471  case UT_Storage::INT16:
472  castType<int16>().getRange(srcrange, dest); return;
473  case UT_Storage::INT32:
474  castType<int32>().getRange(srcrange, dest); return;
475  case UT_Storage::INT64:
476  castType<int64>().getRange(srcrange, dest); return;
477  case UT_Storage::REAL16:
478  castType<fpreal16>().getRange(srcrange, dest); return;
479  case UT_Storage::REAL32:
480  castType<fpreal32>().getRange(srcrange, dest); return;
481  case UT_Storage::REAL64:
482  castType<fpreal64>().getRange(srcrange, dest); return;
483  case UT_Storage::INVALID:
484  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
485  return;
486  }
487  return;
488  }
489 
490  int tuplesize = getTupleSize();
491 
492  // Cast to optimize for small tuple sizes
493  if (TSIZE == -1 && tuplesize <= 3)
494  {
495  if (tuplesize == 1)
496  castTupleSize<1>().getRange(srcrange, dest);
497  else if (tuplesize == 2)
498  castTupleSize<2>().getRange(srcrange, dest);
499  else if (tuplesize == 3)
500  castTupleSize<3>().getRange(srcrange, dest);
501  return;
502  }
503 
505  GA_Offset end;
506  for (GA_Iterator it(srcrange); it.fullBlockAdvance(start, end); )
507  {
508  GA_Offset nelements = end-start;
509  getRange(start, nelements, dest);
510  dest += GA_Size(nelements);
511  }
512  }
513 
514  template<typename T>
515  void setRange(const GA_Range &destrange, const T *src)
516  {
517  if (SYSisSame<DATA_T,void>())
518  {
519  // Hard case, where the storage type is not known at compile time.
521  switch (storage)
522  {
523  case UT_Storage::INT8:
524  castType<int8>().setRange(destrange, src); return;
525  case UT_Storage::INT16:
526  castType<int16>().setRange(destrange, src); return;
527  case UT_Storage::INT32:
528  castType<int32>().setRange(destrange, src); return;
529  case UT_Storage::INT64:
530  castType<int64>().setRange(destrange, src); return;
531  case UT_Storage::REAL16:
532  castType<fpreal16>().setRange(destrange, src); return;
533  case UT_Storage::REAL32:
534  castType<fpreal32>().setRange(destrange, src); return;
535  case UT_Storage::REAL64:
536  castType<fpreal64>().setRange(destrange, src); return;
537  case UT_Storage::INVALID:
538  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
539  return;
540  }
541  return;
542  }
543 
544  int tuplesize = getTupleSize();
545 
546  // Cast to optimize for small tuple sizes
547  if (TSIZE == -1 && tuplesize <= 3)
548  {
549  if (tuplesize == 1)
550  castTupleSize<1>().setRange(destrange, src);
551  else if (tuplesize == 2)
552  castTupleSize<2>().setRange(destrange, src);
553  else if (tuplesize == 3)
554  castTupleSize<3>().setRange(destrange, src);
555  return;
556  }
557 
559  GA_Offset end;
560  for (GA_Iterator it(destrange); it.fullBlockAdvance(start, end); )
561  {
562  GA_Offset nelements = end-start;
563  setRange(start, nelements, src);
564  src += GA_Size(nelements);
565  }
566  }
567 
568  /// For each page, this sets a bit in bits iff there's a chance that
569  /// the data in a page of this may be different from the data in the
570  /// corresponding page of that. It will not clear bits.
571  /// bits must be pre-sized to at least the number of pages in
572  /// this, (which must be equal to the size of that). that must
573  /// have the same tuple size and storage type as this.
574  /// It will only check pointers and constant values. It will not
575  /// compare full pages of data.
576  void comparePages(UT_BitArray &bits, const ThisType &that) const
577  {
578  // Calling getPageData requires that DATA_T be defined, so switch.
579  if (SYSisSame<DATA_T,void>())
580  {
581  // Hard case, where the storage type is not known at compile time.
583  switch (storage)
584  {
585  case UT_Storage::INT8:
586  castType<int8>().comparePages(bits, that.castType<int8>()); return;
587  case UT_Storage::INT16:
588  castType<int16>().comparePages(bits, that.castType<int16>()); return;
589  case UT_Storage::INT32:
590  castType<int32>().comparePages(bits, that.castType<int32>()); return;
591  case UT_Storage::INT64:
592  castType<int64>().comparePages(bits, that.castType<int64>()); return;
593  case UT_Storage::REAL16:
594  castType<fpreal16>().comparePages(bits, that.castType<fpreal16>()); return;
595  case UT_Storage::REAL32:
596  castType<fpreal32>().comparePages(bits, that.castType<fpreal32>()); return;
597  case UT_Storage::REAL64:
598  castType<fpreal64>().comparePages(bits, that.castType<fpreal64>()); return;
599  case UT_Storage::INVALID:
600  UT_ASSERT_MSG(0, "Can't have a GA_PageArray with invalid storage!");
601  return;
602  }
603  return;
604  }
605 
606  UT_ASSERT(getTupleSize() == that.getTupleSize());
607  UT_ASSERT(getStorage() == that.getStorage());
608 
609  UT_PageNum npages = numPages(size());
610  UT_ASSERT(npages == numPages(that.size()));
611  for (UT_PageNum pagei = 0; pagei < npages; ++pagei)
612  {
613  const NotVoidType *thisdata = getPageData(pagei);
614  const NotVoidType *thatdata = that.getPageData(pagei);
615  if (thisdata == thatdata)
616  continue;
617 
618  if (!thisdata || !thatdata ||
619  !isPageConstant(pagei) || !that.isPageConstant(pagei) ||
620  !isEqual(thisdata, thatdata, getTupleSize()))
621  {
622  bits.setBitFast(pagei, true);
623  }
624  }
625  }
626 
627  /// Save data to a JSON stream
628  /// Include GA_PageArrayImpl.h to call this.
629  bool jsonSave(UT_JSONWriter &w, const GA_Range &range,
630  const GA_SaveOptions *options = nullptr,
631  const UT_IntArray *map = nullptr, int defvalue=-1) const;
632 
633  /// Load data from a JSON stream
634  /// Include GA_PageArrayImpl.h to call this.
635  bool jsonLoad(UT_JSONParser &p,
636  const GA_LoadMap &map, GA_AttributeOwner owner);
637 
638 private:
639  /// These are just used internally by jsonSave
640  /// @{
641  template<typename MAP_ARRAY_CLASS>
642  bool jsonSaveConstantOutputPageFlags(
643  UT_JSONWriter &w, const GA_Range &range,
644  UT_UniquePtr<UT_BitArray> &const_page_flags) const;
645  static bool
646  jsonWriteDataSpan(
647  UT_JSONWriter &w,
648  const NotVoidType *page_data,
649  exint length, exint tuplesize,
650  bool const_output, bool const_input,
651  const UT_IntArray *map, int defvalue,
653  bool jsonSaveRawPageData(
654  UT_JSONWriter &w, const GA_Range &range,
655  const UT_BitArray *const_page_flags,
656  UT_JID jid_storage,
657  const UT_IntArray *map, int defvalue) const;
658 
659  class ga_SubPageBlock;
660 
661  static void buildOutputToInternalPageMap(
662  const GA_Range &range,
663  UT_Array<GA_PageNum> &map);
664  static void buildOutputToInternalPageMap(
665  const GA_Range &range,
667  GA_Size marshallConstantFlagsForOutputPages(
668  const UT_Array<GA_PageNum> &map,
669  UT_BitArray &flags) const;
670  GA_Size marshallConstantFlagsForOutputPages(
671  const UT_Array<ga_SubPageBlock> &map,
672  UT_BitArray &flags) const;
674  static bool isSubPageConstant(
675  const NotVoidType *page,
677  const exint tuplesize,
678  const NotVoidType *value);
679 
680  template<bool ARRAY_OF_ARRAYS>
681  bool jsonSaveAsArray(UT_JSONWriter &w, const GA_Range &range, UT_JID jid_storage,
682  const UT_IntArray *map, int defvalue) const;
683  /// @}
684 
685 
686  /// These are just used internally by jsonLoad
687  /// @{
688  class LoadComponentArrayFunctor;
689 
690  bool jsonLoadRawPageData(
691  UT_JSONParser &p,
692  const GA_LoadMap &map,
693  GA_AttributeOwner owner,
694  GA_Size page_size,
695  const int *packing,
696  int n_packing_entries,
697  const UT_UniquePtr<UT_BitArray> *const constant_page_flags);
698  /// @}
699 
701  static UT_JID GAStorageToJID(GA_Storage storage);
702 
703 public:
704 
705  /// This is for setting the DATA_T template after checking getStorage(),
706  /// if DATA_T wasn't already known.
707  /// @{
708  template<typename DEST_DATA_T>
710  castType() const
711  {
715  }
716  template<typename DEST_DATA_T>
719  {
723  }
724  /// @}
725 
726  /// This is for setting the TSIZE template after checking getTupleSize(),
727  /// if TSIZE wasn't already known.
728  /// @{
729  template<exint DEST_TSIZE>
732  {
733  UT_ASSERT_P(TSIZE == -1 || TSIZE == DEST_TSIZE);
734  UT_ASSERT_P(getTupleSize() == DEST_TSIZE);
736  }
737  template<exint DEST_TSIZE>
740  {
741  UT_ASSERT_P(TSIZE == -1 || TSIZE == DEST_TSIZE);
742  UT_ASSERT_P(getTupleSize() == DEST_TSIZE);
744  }
745  /// @}
746 };
747 
748 #endif
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
GLenum GLint * range
Definition: glew.h:3500
GLenum src
Definition: glew.h:2410
SYS_FORCE_INLINE GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize()
Definition: GA_PageArray.h:739
UT_Storage
Definition: UT_Storage.h:26
GA_Size GA_PageOff
Definition: GA_Types.h:641
Iteration over a range of elements.
Definition: GA_Iterator.h:28
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, GA_PAGE_BITS, GA_Offset > Base
Definition: GA_PageArray.h:101
UT_JID
The UT_JID enums are used in byte-stream encoding of binary JSON.
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:35
bool jsonSave(UT_JSONWriter &w, const GA_Range &range, const GA_SaveOptions *options=nullptr, const UT_IntArray *map=nullptr, int defvalue=-1) const
void setConstant(const GA_Range &range, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
Definition: GA_PageArray.h:373
GLuint const GLfloat * val
Definition: glew.h:2794
void comparePages(UT_BitArray &bits, const ThisType &that) const
Definition: GA_PageArray.h:576
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
GLint GLsizei const GLuint64 * values
Definition: glew.h:3612
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
SYS_FORCE_INLINE DEST_DATA_T get(GA_Offseti, exint component=0) const
Definition: UT_PageArray.h:491
exint UT_PageNum
Definition: UT_PageArray.h:40
SYS_FORCE_INLINE GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType()
Definition: GA_PageArray.h:718
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
void setConstantVector(const GA_Range &range, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
Definition: GA_PageArray.h:295
void defragment(const GA_Defragment &defrag)
Include GA_PageArrayImpl.h to call this.
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
const GLdouble * v
Definition: glew.h:1391
#define UT_ASSERT_MSG_P(ZZ,...)
Definition: UT_Assert.h:137
bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &map, GA_AttributeOwner owner)
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(GA_Offseti) const
Definition: UT_PageArray.h:501
GA_PageArray(exint tuplesize)
Definition: GA_PageArray.h:142
SYS_FORCE_INLINE void set(GA_Offseti, SRC_DATA_T v)
component == 0 in this version
Definition: UT_PageArray.h:612
void setConstant(const GA_Range &range, SRC_T val)
Definition: GA_PageArray.h:175
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:231
void copy(const GA_Range &destrange, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Range &srcrange)
Definition: GA_PageArray.h:427
#define GA_INVALID_OFFSET
Definition: GA_Types.h:674
A range of elements in an index-map.
Definition: GA_Range.h:42
signed char int8
Definition: SYS_Types.h:35
#define UT_ASSERT_MSG(ZZ,...)
Definition: UT_Assert.h:138
GA_Size GA_Offset
Definition: GA_Types.h:637
void setConstantVector(GA_Offset start, GA_Offset end, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
Definition: GA_PageArray.h:336
long long int64
Definition: SYS_Types.h:111
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const GA_Defaults &v)
Definition: GA_PageArray.h:253
GA_PageArray(GA_Storage storage)
Definition: GA_PageArray.h:147
static SYS_FORCE_INLINE bool isEqual(const T0 *a, const T1 *b, exint tuplesize)
int64 exint
Definition: SYS_Types.h:120
SYS_FORCE_INLINE void getRange(GA_Offsetsrcstart, GA_Offsetnelements, T *dest) const
GLuint buffer
Definition: glew.h:1680
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
double fpreal64
Definition: SYS_Types.h:196
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
GLuint GLuint end
Definition: glew.h:1253
void setConstant(GA_Offset start, GA_Offset end, SRC_T val)
Definition: GA_PageArray.h:259
void
Definition: png.h:1083
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
void setBitFast(exint index, bool value)
Definition: UT_BitArray.h:326
Options during loading.
Definition: GA_LoadMap.h:42
GA_PageArray(exint tuplesize, GA_Storage storage)
Definition: GA_PageArray.h:157
SYS_FORCE_INLINE void setVector(GA_Offseti, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE, SRC_INSTANTIATED > &v)
Definition: UT_PageArray.h:719
SYS_FORCE_INLINE GA_Storage UTStorageToGAStorage(UT_Storage storage)
Definition: GA_PageArray.h:43
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
int int32
Definition: SYS_Types.h:39
void getRange(const GA_Range &srcrange, T *dest) const
Definition: GA_PageArray.h:461
void mergeGrowArrayAndCopy(const GA_MergeMap &map, GA_AttributeOwner owner, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Defaults &defaults)
Include GA_PageArrayImpl.h to call this.
void setConstant(const GA_Range &range, const GA_Defaults &defaults)
Definition: GA_PageArray.h:215
GLuint start
Definition: glew.h:1253
unsigned short fpreal16
Definition: SYS_Types.h:202
GA_PageArray(exint tuplesize, UT_Storage storage)
Definition: GA_PageArray.h:152
void moveRange(GA_Offsetsrcstart, GA_Offsetdeststart, GA_Offsetnelements)
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
Definition: GA_PageArray.h:414
void setRange(const GA_Range &destrange, const T *src)
Definition: GA_PageArray.h:515
GLfloat GLfloat p
Definition: glew.h:16321
SYS_FORCE_INLINE UT_Storage GAStorageToUTStorage(GA_Storage storage)
Definition: GA_PageArray.h:69
GA_AttributeOwner
Definition: GA_Types.h:33
void swapRange(GA_Offsetastart, GA_Offsetbstart, GA_Offsetnelements)
SYS_FORCE_INLINE GA_Storage getStorage() const
Get the storage type for each component of this GA_PageArray.
Definition: GA_PageArray.h:162
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:47
GA_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > ThisType
Definition: GA_PageArray.h:102
SYS_FORCE_INLINE void setRange(GA_Offsetdeststart, GA_Offsetnelements, const T *src)
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, PAGESHARDENED, THEPAGEBITS, GA_Offset > & hardenTable()
SYS_FORCE_INLINE const GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize() const
Definition: GA_PageArray.h:731
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
SYS_FORCE_INLINE const GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType() const
Definition: GA_PageArray.h:710
short int16
Definition: SYS_Types.h:37
#define SYSmin(a, b)
Definition: SYS_Math.h:1448
GLsizei const GLfloat * value
Definition: glew.h:1849
float fpreal32
Definition: SYS_Types.h:195
GA_Storage
Definition: GA_Types.h:49
bool fullBlockAdvance(GA_Offset &start, GA_Offset &end)
void setStorage(GA_Storage storage)
Set the storage type for each component of this GA_PageArray.
Definition: GA_PageArray.h:168