HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_AttributeSet.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_AttributeSet.h ( GA Library, C++)
7  *
8  * COMMENTS: A set of attributes.
9  */
10 
11 #pragma once
12 
13 #ifndef __GA_AttributeSet__
14 #define __GA_AttributeSet__
15 
16 #include "GA_API.h"
17 #include "GA_ATINumeric.h"
18 #include "GA_AttributeProxy.h"
19 #include "GA_AttributeDict.h"
20 #include "GA_Defaults.h"
21 #include "GA_ReuseStrategy.h"
22 #include "GA_Types.h"
23 
24 #include <SYS/SYS_Inline.h>
25 #include <SYS/SYS_Types.h>
26 
27 #include "UT/UT_UniquePtr.h"
28 
29 #include <iosfwd>
30 #include <stddef.h>
31 
32 
33 class GA_AIFFileH9;
34 class GA_ATINumeric;
35 class GA_ATITopology;
38 class GA_AttribXlateH9;
39 class GA_Attribute;
40 class GA_AttributeFilter;
41 class GA_AttributeType;
42 class GA_Defragment;
43 class GA_Detail;
44 class GA_ElementGroup;
45 class GA_IndexMap;
46 class GA_LoadMap;
47 class GA_MergeMap;
48 class GA_SaveMap;
49 class GA_Stat;
50 template <typename AIF_TYPE> class GA_AIFDefinition;
51 
52 class UT_IStream;
53 class UT_JSONParser;
54 class UT_JSONWriter;
55 class UT_MemoryCounter;
56 class UT_Options;
57 class UT_StringHolder;
58 class UT_StringRef;
59 class UT_WorkBuffer;
60 template <typename T> class UT_Array;
61 
62 
64 {
65 private:
66  /// Only GA_Detail can create attribute sets because the attributes
67  /// rely on the existense of the detail for index maps and otherwise it
68  /// may be too easy to create a attributes without a detail.
69  friend class GA_Detail;
70  /// Group table requires friendship to be able to reach the
71  /// GA_AttributeDict that it is tightly coupled to.
72  friend class GA_GroupTable;
73  GA_AttributeSet(GA_Detail &detail);
74 
75  GA_AttributeSet(const GA_AttributeSet &set) = delete;
76  GA_AttributeSet &operator=(const GA_AttributeSet &set) = delete;
77 
78 public:
79  ~GA_AttributeSet();
80 
82  {
83  // Used to certify that a name has already been
84  // screened for validity
85  public:
87  };
88 
90  {
91  // Used to certify that a name has already been
92  // screened for validity and collision.
93  public:
95  };
96 
97  // --- Attribute Management ----
98  /// Create a new named attribute for the @c owner with the given @scope
99  ///
100  /// The @c creation_options are used to pass intrinsic properties to the
101  /// attribute. The @c creation_options are not generally stored with the
102  /// attribute itself, but are used to determine the intrinsic behaviour of
103  /// the attribute (i.e. specifying storage types for numeric attributes).
104  ///
105  /// The @c attribute_options are stored on the attribute.
106  ///
107  /// The @c attribtype argument is used to look up the attribute type. Common
108  /// values include @c numeric, @c "string" and @c "indexpair"
109  GA_Attribute *createAttribute(GA_AttributeOwner owner,
110  GA_AttributeScope scope,
111  const UT_StringHolder &name,
112  const UT_Options *creation_args,
113  const GA_AttributeOptions *attribute_options,
114  const UT_StringRef &attribtype,
115  const GA_ReuseStrategy &r = GA_ReuseStrategy());
116  /// Create a detached attribute.
117  GA_AttributeUPtr createDetachedAttribute(
118  GA_AttributeOwner owner,
119  const UT_StringRef &attribtype,
120  const UT_Options *creation_args,
121  const GA_AttributeOptions *attribute_options) const;
122  GA_AttributeUPtr createDetachedAttribute(
123  GA_AttributeOwner owner,
124  const GA_AttributeType &attribtype,
125  const UT_Options *creation_args,
126  const GA_AttributeOptions *attribute_options) const;
127 
128  /// Convenience method to add a public attribute
131  const UT_StringHolder &name,
132  const UT_Options *creation_args,
133  const GA_AttributeOptions *attribute_options,
134  const UT_StringRef &attribtype,
136  {
137  return createAttribute(owner, GA_SCOPE_PUBLIC,
138  name, creation_args,
139  attribute_options, attribtype);
140  }
141 
142  /// Create an attribute that has the same definition as the source.
143  /// @note This will fail for group attributes!
144  /// @{
145  GA_Attribute *cloneAttribute(GA_AttributeOwner owner,
146  const UT_StringHolder &name, namevalidcertificate,
147  const GA_Attribute &src,
148  bool clone_options,
149  GA_DataIdStrategy data_id_strategy
150  = GA_DATA_ID_BUMP,
151  const GA_ReuseStrategy &reuse = GA_ReuseStrategy());
152  GA_Attribute *cloneAttribute(GA_AttributeOwner owner,
153  const UT_StringHolder &name,
154  const GA_Attribute &src,
155  bool clone_options,
156  GA_DataIdStrategy data_id_strategy
157  = GA_DATA_ID_BUMP,
158  const GA_ReuseStrategy &reuse = GA_ReuseStrategy());
159  /// @}
160 
161  /// Create an attribute that has the same definition as the source,
162  /// promoting Tuple attributes into Array of Tuple attributes.
163  /// If the base attribute is not a tuple or lacks an array equivalent,
164  /// fails and returns nullptr.
165  /// @note This will fail for group attributes!
166  /// @{
167  GA_Attribute *cloneTupleAsArrayAttribute(GA_AttributeOwner owner,
168  const UT_StringHolder &name, namevalidcertificate,
169  const GA_Attribute &src,
170  bool clone_options,
171  const GA_ReuseStrategy &reuse = GA_ReuseStrategy());
172  GA_Attribute *cloneTupleAsArrayAttribute(GA_AttributeOwner owner,
173  const UT_StringHolder &name,
174  const GA_Attribute &src,
175  bool clone_options,
176  const GA_ReuseStrategy &reuse = GA_ReuseStrategy());
177  /// @}
178 
179  /// Create a temporary attribute.
180  /// See @c createAttribute() for details on arguments
181  GA_Attribute *createTempAttribute(GA_AttributeOwner owner,
182  const UT_Options *creation_args,
183  const GA_AttributeOptions *attribute_options,
184  const UT_StringRef &attribtype);
185  GA_Attribute *cloneTempAttribute(GA_AttributeOwner owner,
186  const GA_Attribute &src,
187  bool clone_options);
188 
191  const UT_StringRef &name,
192  const GA_AttributeOwner search_order[],
193  int search_order_size) const
194  {
195  if (!UTisstring(name))
196  return nullptr;
197 
198  for (int i = 0; i < search_order_size; i++)
199  {
200  const GA_Attribute *atr = find(search_order[i], scope, name);
201  if (atr)
202  return atr;
203  }
204  return nullptr;
205  }
206 
209  const UT_StringRef &name,
210  const GA_AttributeOwner search_order[],
211  int search_order_size)
212  {
213  return const_cast<GA_Attribute *>(
214  static_cast<const GA_AttributeSet *>
215  (this)->findAttribute(scope, name,
216  search_order,
217  search_order_size));
218  }
221  const GA_AttributeOwner search_order[],
222  int search_order_size) const
223  {
224  return findAttribute(GA_SCOPE_PUBLIC, name,
225  search_order,
226  search_order_size);
227  }
230  const GA_AttributeOwner search_order[],
231  int search_order_size)
232  {
233  return findAttribute(GA_SCOPE_PUBLIC, name,
234  search_order,
235  search_order_size);
236  }
239  GA_AttributeScope scope,
240  const UT_StringRef &name)
241  { return findAttribute(scope, name, &owner, 1); }
244  const UT_StringRef &name)
245  {
246  return findAttribute(GA_SCOPE_PUBLIC, name,
247  &owner, 1);
248  }
251  GA_AttributeScope scope,
252  const UT_StringRef &name) const
253  { return findAttribute(scope, name, &owner, 1); }
256  const UT_StringRef &name) const
257  {
258  return findAttribute(GA_SCOPE_PUBLIC, name,
259  &owner, 1);
260  }
261  void matchAttributes(const GA_AttributeFilter &filter,
262  const GA_AttributeOwner search_order[],
263  int search_order_size,
265  void matchAttributes(const GA_AttributeFilter &filter,
266  const GA_AttributeOwner search_order[],
267  int search_order_size,
268  UT_Array<const GA_Attribute *> &list) const;
270  GA_AttributeOwner owner,
272  { return matchAttributes(filter, &owner,1, list); }
274  GA_AttributeOwner owner,
275  UT_Array<const GA_Attribute *> &list) const
276  { return matchAttributes(filter, &owner,1, list); }
277  bool destroyAttribute(GA_Attribute *attribute);
278  bool destroyAttribute(GA_AttributeOwner owner,
279  GA_AttributeScope scope,
280  const UT_StringRef &name);
283  const UT_StringRef &name)
284  {
285  return destroyAttribute(owner, GA_SCOPE_PUBLIC,
286  name);
287  }
288 
289  bool destroyAttributeIncludingP(GA_Attribute *attribute);
290 
291  int destroyAttributes(GA_AttributeOwner owner,
292  const GA_AttributeFilter &filter);
294  GA_AttributeScope scope,
295  const UT_StringRef &from_name,
296  const UT_StringHolder &to_name);
297  /// Rename an attribute to an unused name. Typically used to make fromName
298  /// available for another attribute.
299  ///
300  /// Returns new name on success, NULL on failure.
301  const char *renameAttributeUnspecified(GA_AttributeOwner owner,
302  GA_AttributeScope scope,
303  const UT_StringRef &from_name);
304 
305  // Convenience attribute methods
306  GA_Attribute *createTupleAttribute(GA_AttributeOwner owner,
307  GA_AttributeScope scope,
308  const UT_StringHolder &name,
310  int tuple_size,
311  const GA_Defaults &defaults,
312  const UT_Options *creation_args = NULL,
313  const GA_AttributeOptions *attribute_options = NULL,
314  const GA_ReuseStrategy &r = GA_ReuseStrategy());
317  const UT_StringHolder &name,
318  GA_Storage storage,
319  int tuple_size,
320  const GA_Defaults &defaults,
321  const UT_Options *creation_args = NULL,
322  const GA_AttributeOptions *attribute_options = NULL,
324  {
325  return createTupleAttribute(owner, GA_SCOPE_PUBLIC, name, storage,
326  tuple_size, defaults, creation_args,
327  attribute_options, r);
328  }
329  GA_ATINumericUPtr createDetachedTupleAttribute(
330  GA_AttributeOwner owner,
331  GA_Storage storage,
332  int tuple_size,
333  const GA_Defaults &defaults=GA_Defaults(0.0f),
334  const GA_AttributeOptions *attribute_options=NULL) const;
335  GA_Attribute *createArrayAttribute(GA_AttributeOwner owner,
336  GA_AttributeScope scope,
337  const UT_StringHolder &name,
338  GA_Storage storage,
339  int tuple_size,
340  const UT_Options *creation_args = NULL,
341  const GA_AttributeOptions *attribute_options = NULL,
342  const UT_StringRef &attribtype="arraydata",
343  const GA_ReuseStrategy &r = GA_ReuseStrategy());
344  GA_Attribute *createTempTupleAttribute(GA_AttributeOwner owner,
345  GA_Storage storage,
346  int tuple_size,
347  const GA_Defaults &defaults,
348  const UT_Options *creation_args = NULL,
349  const GA_AttributeOptions *attribute_options = NULL);
350  GA_Attribute *createStringAttribute(GA_AttributeOwner owner,
351  GA_AttributeScope scope,
352  const UT_StringHolder &name,
353  int tuple_size=1,
354  const UT_Options *creation_args = NULL,
355  const GA_AttributeOptions *attribute_options = NULL,
356  const UT_StringRef &attribtype="string",
357  const GA_ReuseStrategy &r = GA_ReuseStrategy());
360  const UT_StringHolder &name,
361  int tuple_size=1,
362  const UT_Options *creation_args = NULL,
363  const GA_AttributeOptions *attribute_options = NULL,
364  const UT_StringRef &attribtype="string",
366  {
367  return createStringAttribute(owner, GA_SCOPE_PUBLIC, name, tuple_size,
368  creation_args, attribute_options, attribtype,
369  r);
370  }
371  GA_Attribute *createTempStringAttribute(GA_AttributeOwner owner,
372  int tuple_size=1);
373  GA_Attribute *createDictAttribute(GA_AttributeOwner owner,
374  GA_AttributeScope scope,
375  const UT_StringHolder &name,
376  int tuple_size=1,
377  const UT_Options *creation_args = NULL,
378  const GA_AttributeOptions *attribute_options = NULL,
379  const UT_StringRef &attribtype="dict",
380  const GA_ReuseStrategy &r = GA_ReuseStrategy());
383  const UT_StringHolder &name,
384  int tuple_size=1,
385  const UT_Options *creation_args = NULL,
386  const GA_AttributeOptions *attribute_options = NULL,
387  const UT_StringRef &attribtype="dict",
389  {
390  return createStringAttribute(owner, GA_SCOPE_PUBLIC, name, tuple_size,
391  creation_args, attribute_options, attribtype,
392  r);
393  }
394  GA_Attribute *createTempDictAttribute(GA_AttributeOwner owner,
395  int tuple_size=1);
398  const UT_StringRef &name)
399  {
400  return findAttribute(GA_ATTRIB_POINT, scope,
401  name);
402  }
405  {
406  return findPointAttribute(GA_SCOPE_PUBLIC,
407  name);
408  }
411  const UT_StringRef &name)
412  {
413  return findAttribute(GA_ATTRIB_VERTEX, scope,
414  name);
415  }
418  {
419  return findVertexAttribute(GA_SCOPE_PUBLIC,
420  name);
421  }
424  const UT_StringRef &name)
425  {
426  return findAttribute(GA_ATTRIB_PRIMITIVE,
427  scope, name);
428  }
431  {
432  return findPrimitiveAttribute(GA_SCOPE_PUBLIC,
433  name);
434  }
437  const UT_StringRef &name)
438  {
439  return findAttribute(GA_ATTRIB_GLOBAL, scope,
440  name);
441  }
444  {
445  return findGlobalAttribute(GA_SCOPE_PUBLIC,
446  name);
447  }
448 
449  /// NOTE: These should ONLY be called by the GA_ElementGroup constructor & destructor.
450  /// @{
451  void registerGroup(GA_ElementGroup &group);
452  void unregisterGroup(GA_ElementGroup &group);
453  /// @}
454 
455  GA_ElementGroup *findGroup(GA_AttributeOwner owner,
456  const UT_StringRef &name);
457  // Convenience group methods
459  { return findGroup(GA_ATTRIB_POINT, name); }
461  { return findGroup(GA_ATTRIB_VERTEX, name); }
463  { return findGroup(GA_ATTRIB_PRIMITIVE, name); }
464 
465  /// Try to compress data pages
466  /// Will try to compress *all* pages overlapping the specified offset
467  /// range.
468  void tryCompressAllPages(GA_AttributeOwner owner,
469  GA_Offset start_offset = GA_Offset(0),
470  GA_Offset end_offset = GA_INVALID_OFFSET);
471 
472  /// Harden data pages
473  /// Will harden *all* pages overlapping the specified offset range.
474  /// Once this is done, multiple threads can write to an attribute in
475  /// parallel at a finer granularity than pages.
476  /// @{
477  SYS_DEPRECATED_REPLACE(19.5, "Use more nuanced hardening as, for example, groups are not thread-safe even if hardened.")
478  void hardenAllPages(GA_AttributeOwner owner,
479  GA_Offset start_offset = GA_Offset(0),
480  GA_Offset end_offset = GA_INVALID_OFFSET);
481  void hardenAllPagesExceptGroups(GA_AttributeOwner owner,
482  GA_Offset start_offset = GA_Offset(0),
483  GA_Offset end_offset = GA_INVALID_OFFSET);
484  /// @}
485 
486  /// Bumps all data IDs of attributes of the specified owner.
487  void bumpAllDataIds(GA_AttributeOwner owner);
488 
489  /// Save attribute sets to a JSON stream.
490  /// @section JSON-GA_AttributeSet JSON Schema: GA_AttributeSet
491  ///
492  /// Storage for a set of attributes.
493  ///
494  /// @code
495  /// {
496  /// "name" : "GA_AttributeSet",
497  /// "description" : "Attribute storage",
498  /// "type" : "orderedmap",
499  /// "properties": {
500  /// "vertexattributes": {
501  /// "type" : "array",
502  /// "items" : { "$ref" : "GA_Attribute" } ,
503  /// "description" : "Vertex attributes",
504  /// "optional" : true,
505  /// }
506  /// "pointattributes": {
507  /// "type" : "array",
508  /// "items" : { "$ref" : "GA_Attribute" } ,
509  /// "description" : "Point attributes",
510  /// "optional" : true,
511  /// }
512  /// "primitiveattributes": {
513  /// "type" : "array",
514  /// "items" : { "$ref" : "GA_Attribute" },
515  /// "description" : "Primitive attributes",
516  /// "optional" : true,
517  /// }
518  /// "globalattributes": {
519  /// "type" : "array",
520  /// "items" : { "$ref" : "GA_Attribute" } ,
521  /// "description" : "Global attributes",
522  /// "optional" : true,
523  /// }
524  /// }
525  /// }
526  /// @endcode
527  /// @see @ref JSON_FileFormat, GA_AIFJSON, GA_Attribute
528  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &s) const;
529 
530  /// Load attribute sets from a JSON stream
531  bool jsonLoad(UT_JSONParser &p, GA_LoadMap &m);
532 
533  /// Stat attribute stats from a JSON stream
534  static bool jsonStat(UT_JSONParser &p, GA_Stat &sbuf);
535 
536  // --- Query methods ----
537  int64 getMemoryUsage(bool inclusive) const;
538 
539  /// Count memory usage using a UT_MemoryCounter in order to count
540  /// shared memory correctly.
541  /// If inclusive is true, the size of this object is counted,
542  /// else only memory owned by this object is counted.
543  /// If this is pointed to by the calling object, inclusive should be true.
544  /// If this is contained in the calling object, inclusive should be false.
545  /// (Its memory was already counted in the size of the calling object.)
546  void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
547 
548 
549  bool loadDictH9(UT_IStream &is,
550  GA_AttributeOwner owner,
551  int tbl_size,
553  &definition,
555  &list,
556  const GA_AttribXlateH9 *xlate);
557  static bool saveDictH9(std::ostream &os, const char *label,
559  &list);
560 
561  /// Get information about attributes
562  bool stat(GA_Stat &stat, uint level) const;
563 
564  // Private to GA_AttributeRefMap methods --------------------
565  GA_Detail *getDetail() const { return myDetail; }
566 
567  // Private to GA_Detail methods ----------------------------------
568  void clearAllAttributes(bool for_deletion); // Called on detail deletion
569  void clearAllAttributes(GA_AttributeOwner owner, bool for_deletion); // Called in replaceWithPoints
570  // Reserve some additional space in a symbol table for batch addition.
571  void reserveNewSymbolTableSpace(GA_AttributeOwner owner,
572  GA_AttributeScope scope,
573  int size);
574  GA_ATITopology *createTopologyAttribute(GA_AttributeOwner owner,
575  const UT_StringHolder &name,
576  GA_AttributeOwner linkowner);
577 
578  /// Raw access to the GA_AttributeDict for a particular owner
581  {
582  UT_ASSERT_P(int(owner) >= 0 && int(owner) < int(GA_ATTRIB_OWNER_N));
583  return myAttributes[owner];
584  }
585 
586  /// Query whether a given string is a valid variable name.
587  static bool isValidName(const char *name,
589 
590  /// @private Function used in GA_Detail::replace to replace all attributes
591  /// If 'skip' is given, we will skip processing any attribute that
592  /// matches it. 'skip' will be called with attributes from the
593  /// destination as well as src geometries.
594  /// If 'full_copy is true, internal groups and private attribute are also
595  /// considered.'
596  void replace(const GA_AttributeSet &src, GA_AttributeOwner owner,
597  bool replaceindexmap, const GA_AttributeFilter *skip,
598  bool full_copy = false);
599 
600  /// @private Method used by merging to destroy attributes before merging
601  void mergeDestroyDestination(GA_MergeMap &map);
602  /// @private Method used by merging to add attributes during merging
603  void mergeAddDestination(GA_MergeMap &map);
604 
605  /// @private Method used by merging detail attributes
606  void mergeDestroyGlobalDestination(GA_MergeMap &map)
607  { mergeDestroyDestination(GA_ATTRIB_DETAIL, map); }
608  /// @private Method used by merging detail attributes
609  void mergeAddGlobalDestination(GA_MergeMap &map)
610  { mergeAddDestination(GA_ATTRIB_DETAIL, map); }
611 
613  {
614  return myAttributes[owner].begin();
615  }
617  GA_AttributeScope scope) const
618  {
619  return myAttributes[owner].begin(scope);
620  }
622  { return myAttributes[owner].end(); }
624  GA_AttributeScope scope) const
625  { return myAttributes[owner].end(scope); }
626 
627  /// Called by GA_Detail::defragment when defragmenting a particular
628  /// index map. Topology attributes won't be modified; they're
629  /// handled separately.
630  /// NOTE: This bumps all data IDs of attributes whose owner is that of the
631  /// index map being defragmented, including topology attributes.
632  void defragment(const GA_Defragment &defrag);
633 
634  /// By default, data IDs are not generated for new attributes to force
635  /// callers to explicitly opt-in. It is very easy for data IDs to
636  /// become stale in code that is not explicitly notifying modified
637  /// attributes.
638  SYS_DEPRECATED_REPLACE(18.0, "Data Id generation is now always enabled.")
639  void enableDataIdGeneration();
640 
641  /// Query whether generation of data IDs has been enabled.
642  bool isGeneratingDataIds() const
643  { return myGenerateDataIds; }
644 
645 private:
646  /// @private
647  /// Used only by GA_Detail
648  void setNumBuckets(GA_AttributeOwner owner, GA_AttributeScope scope, size_t nbuckets)
649  {
650  myAttributes[owner].setNumBuckets(scope, nbuckets);
651  }
652 
653  void adjustArraySize(GA_AttributeOwner owner, GA_Offset size);
654  /// When a previously deleted element is reallocated, we need to reset the
655  /// attribute data to its default values. The constructElement() assumes
656  /// that there are no current values.
657  void constructElementBlock(GA_AttributeOwner owner, GA_Offset offset, GA_Offset nelements);
658  /// When an element is destroyed, the destructElement() method is called
659  /// so that the attribute data can be cleaned up properly (i.e. string
660  /// references or group data).
661  void destructElement(GA_AttributeOwner owner, GA_Offset offset);
662  void batchDeletion(GA_AttributeOwner owner);
663 
664  /// @private Method to grow arrays prior to merging
665  void mergeGrowData(GA_AttributeOwner owner, GA_MergeMap &map);
666 
667  /// @private Method to copy data from the source to the destination for all
668  /// attribute types.
669  void mergeCopyData(const GA_MergeMap &map);
670 
671  /// @private Method to copy data from source to dest for detail attributes
672  void mergeCopyGlobalData(const GA_MergeMap &map)
673  { mergeCopyData(GA_ATTRIB_DETAIL, map); }
674 
675  /// @private Method to copy data from the source to the destination
676  void mergeCopyData(GA_AttributeOwner owner, const GA_MergeMap &map);
677 
678  void mergeDestroyDestination(GA_AttributeOwner owner,
679  GA_MergeMap &map);
680  void mergeAddDestination(GA_AttributeOwner owner,
681  GA_MergeMap &map);
682 
683  const GA_IndexMap &getIndexMap(GA_AttributeOwner type) const;
684  UT_StringRef makeUniqueName(GA_AttributeOwner owner,
685  GA_AttributeScope scope,
686  UT_WorkBuffer &name_buffer) const;
687  UT_StringRef makeUniqueName(GA_AttributeOwner owner,
688  GA_AttributeScope scope,
689  const char *prefix,
690  UT_WorkBuffer &name_buffer) const;
691 
692  /// This method, unlike createAttribute(), merely allocates the requested
693  /// attribute. The allocated attribute is not registered in our tables
694  /// nor with our detail. Consequently name collisions are ignored, and it
695  /// is up to the caller to resolve any such collisions before registering
696  /// this attribute.
697  GA_Attribute *allocAttribute(GA_AttributeOwner owner,
698  const UT_StringHolder &name,
699  const UT_Options *creation_args,
700  const GA_AttributeOptions *attribute_options,
701  const UT_StringRef &attribtype) const;
702 
704  GA_AttributeScope scope,
705  const UT_StringRef &name) const
706  {
707  UT_ASSERT_P(owner >= GA_AttributeOwner(0) && owner < GA_ATTRIB_OWNER_N);
708  return myAttributes[owner].findProxy(scope, name);
709  }
710 
712  GA_AttributeScope scope,
713  const UT_StringRef &name) const
714  {
715  GA_AttributeProxy *p = findProxy(owner, scope, name);
716  return p ? p->getAttribute() : NULL;
717  }
718  void add(GA_AttributeOwner owner, GA_Attribute *atr);
719  void invalidateProxyAndDestroyAttribute( GA_AttributeProxy *proxy);
720  bool destroy(GA_AttributeOwner owner, GA_Attribute *atr);
721  bool destroy(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
722  { return destroy(owner, find(owner, scope, name)); }
723  int destroy(GA_AttributeOwner owner, const GA_AttributeFilter &filter);
724  /// Avoids the safety check on P.
725  bool destroyIncludingP(GA_AttributeOwner owner, GA_Attribute *atr);
726  bool destroyImpl(GA_AttributeOwner owner,
727  GA_Attribute *atr);
728  void clear(GA_AttributeOwner owner, bool for_deletion);
729 
730  template<typename OP,typename FILL_OPT_OP>
731  GA_Attribute *createAttributeImpl(
732  OP &creation_op,
733  FILL_OPT_OP &fill_opt_op,
734  GA_AttributeOwner owner,
735  GA_AttributeScope scope,
736  const UT_StringHolder &name,
737  const UT_Options *create_args,
738  const GA_AttributeOptions *attribute_options,
739  const GA_AttributeType &attribtype,
740  const GA_ReuseStrategy &reuse);
741 
742  GA_Detail *myDetail;
743  GA_AttributeDict myAttributes[GA_ATTRIB_OWNER_N];
744  UT_Array<GA_Attribute *> *myDestructorCache[GA_ATTRIB_OWNER_N];
745  bool myGenerateDataIds : 1;
746  bool myPreferredPrec64 : 1;
747 };
748 
749 #endif
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(const UT_StringRef &name)
Specify when and how to reuse an existing attribute.
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, const UT_StringRef &name)
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE GA_Attribute * createDictAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=NULL, const GA_AttributeOptions *attribute_options=NULL, const UT_StringRef &attribtype="dict", const GA_ReuseStrategy &r=GA_ReuseStrategy())
SYS_FORCE_INLINE GA_Attribute * getAttribute()
SYS_FORCE_INLINE bool destroyAttribute(GA_AttributeOwner owner, const UT_StringRef &name)
GA_AttributeDict::iterator begin(GA_AttributeOwner owner, GA_AttributeScope scope) const
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:35
void
Definition: png.h:1083
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
void matchAttributes(const GA_AttributeFilter &filter, GA_AttributeOwner owner, UT_Array< const GA_Attribute * > &list) const
void skip(T &in, int n)
Definition: ImfXdr.h:613
GA_DataIdStrategy
Definition: GA_Types.h:211
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name) const
GA_AttributeDict::iterator end(GA_AttributeOwner owner, GA_AttributeScope scope) const
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
GLint level
Definition: glcorearb.h:108
GLdouble s
Definition: glad.h:3009
GA_AttributeDict::iterator begin(GA_AttributeOwner owner) const
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
SYS_FORCE_INLINE GA_Attribute * createAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype, const GA_ReuseStrategy &r=GA_ReuseStrategy())
Convenience method to add a public attribute.
Class used to map H9 geometry files to a form used by GA.
Definition: GA_AIFFileH9.h:318
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
Standard user attribute level.
Definition: GA_Types.h:149
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(const UT_StringRef &name)
GA_ElementGroup * findVertexGroup(const UT_StringRef &name)
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GA_Size GA_Offset
Definition: GA_Types.h:646
GA_AttributeScope
Definition: GA_Types.h:143
GLfloat f
Definition: glcorearb.h:1926
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(GA_AttributeScope scope, const UT_StringRef &name)
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
GA_AttributeDict::iterator end(GA_AttributeOwner owner) const
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
This class holds a reference to an attribute. Such an indirection level allows an easy way to invalid...
std::string OIIO_UTIL_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE GA_Attribute * findVertexAttribute(const UT_StringRef &name)
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeOwner owner, const UT_StringRef &name) const
GA_ElementGroup * findPointGroup(const UT_StringRef &name)
long long int64
Definition: SYS_Types.h:116
Options during loading.
Definition: GA_LoadMap.h:42
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
GLuint const GLchar * name
Definition: glcorearb.h:786
SYS_FORCE_INLINE const GA_AttributeDict & getDict(GA_AttributeOwner owner) const
Raw access to the GA_AttributeDict for a particular owner.
MX_CORE_API bool isValidName(const string &name)
Return true if the given string is a valid MaterialX name.
UT_UniquePtr< GA_Attribute > GA_AttributeUPtr
Definition: GA_Attribute.h:930
GA_ElementGroup * findPrimitiveGroup(const UT_StringRef &name)
Attribute Interface for file I/O.
Definition: GA_AIFFileH9.h:44
GLsizeiptr size
Definition: glcorearb.h:664
GA_AttributeOwner
Definition: GA_Types.h:35
A map of string to various well defined value types.
Definition: UT_Options.h:84
Class to return information about a GA_Detail.
Definition: GA_Stat.h:50
SYS_FORCE_INLINE GA_Attribute * findVertexAttribute(GA_AttributeScope scope, const UT_StringRef &name)
Class to allow custom AIF interfaces to be built.
LeafData & operator=(const LeafData &)=delete
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(GA_AttributeScope scope, const UT_StringRef &name)
SYS_FORCE_INLINE bool UTisstring(const char *s)
Class used to map the GA attribute into a form for H9 geometry files.
Definition: GA_AIFFileH9.h:262
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
SYS_FORCE_INLINE GA_Attribute * findGlobalAttribute(GA_AttributeScope scope, const UT_StringRef &name)
Container class for all geometry.
Definition: GA_Detail.h:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
SYS_FORCE_INLINE GA_Attribute * createStringAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=NULL, const GA_AttributeOptions *attribute_options=NULL, const UT_StringRef &attribtype="string", const GA_ReuseStrategy &r=GA_ReuseStrategy())
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLboolean r
Definition: glcorearb.h:1222
SYS_FORCE_INLINE GA_Attribute * createTupleAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, GA_Storage storage, int tuple_size, const GA_Defaults &defaults, const UT_Options *creation_args=NULL, const GA_AttributeOptions *attribute_options=NULL, const GA_ReuseStrategy &r=GA_ReuseStrategy())
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeScope scope, const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_order_size) const
type
Definition: core.h:1059
void matchAttributes(const GA_AttributeFilter &filter, GA_AttributeOwner owner, UT_Array< GA_Attribute * > &list)
void renameAttribute(PointDataTreeT &tree, const Name &oldName, const Name &newName)
Rename an attribute in a VDB tree.
unsigned int uint
Definition: SYS_Types.h:45
GA_Storage
Definition: GA_Types.h:51
UT_UniquePtr< GA_ATINumeric > GA_ATINumericUPtr
SYS_FORCE_INLINE GA_Attribute * findAttribute(const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_order_size)
SYS_FORCE_INLINE GA_Attribute * findGlobalAttribute(const UT_StringRef &name)
SYS_FORCE_INLINE const GA_Attribute * findAttribute(const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_order_size) const
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeScope scope, const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_order_size)
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2089
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
GLenum src
Definition: glcorearb.h:1793