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  const GA_Attribute *findAttribute(GA_AttributeScope scope,
189  const UT_StringRef &name,
190  const GA_AttributeOwner search_order[],
191  int search_order_size) const;
194  const UT_StringRef &name,
195  const GA_AttributeOwner search_order[],
196  int search_order_size)
197  {
198  return const_cast<GA_Attribute *>(
199  static_cast<const GA_AttributeSet *>
200  (this)->findAttribute(scope, name,
201  search_order,
202  search_order_size));
203  }
206  const GA_AttributeOwner search_order[],
207  int search_order_size) const
208  {
209  return findAttribute(GA_SCOPE_PUBLIC, name,
210  search_order,
211  search_order_size);
212  }
215  const GA_AttributeOwner search_order[],
216  int search_order_size)
217  {
218  return findAttribute(GA_SCOPE_PUBLIC, name,
219  search_order,
220  search_order_size);
221  }
224  GA_AttributeScope scope,
225  const UT_StringRef &name)
226  { return findAttribute(scope, name, &owner, 1); }
229  const UT_StringRef &name)
230  {
231  return findAttribute(GA_SCOPE_PUBLIC, name,
232  &owner, 1);
233  }
236  GA_AttributeScope scope,
237  const UT_StringRef &name) const
238  { return findAttribute(scope, name, &owner, 1); }
241  const UT_StringRef &name) const
242  {
243  return findAttribute(GA_SCOPE_PUBLIC, name,
244  &owner, 1);
245  }
246  void matchAttributes(const GA_AttributeFilter &filter,
247  const GA_AttributeOwner search_order[],
248  int search_order_size,
250  void matchAttributes(const GA_AttributeFilter &filter,
251  const GA_AttributeOwner search_order[],
252  int search_order_size,
253  UT_Array<const GA_Attribute *> &list) const;
255  GA_AttributeOwner owner,
257  { return matchAttributes(filter, &owner,1, list); }
259  GA_AttributeOwner owner,
260  UT_Array<const GA_Attribute *> &list) const
261  { return matchAttributes(filter, &owner,1, list); }
262  bool destroyAttribute(GA_Attribute *attribute);
263  bool destroyAttribute(GA_AttributeOwner owner,
264  GA_AttributeScope scope,
265  const UT_StringRef &name);
268  const UT_StringRef &name)
269  {
270  return destroyAttribute(owner, GA_SCOPE_PUBLIC,
271  name);
272  }
273 
274  bool destroyAttributeIncludingP(GA_Attribute *attribute);
275 
276  int destroyAttributes(GA_AttributeOwner owner,
277  const GA_AttributeFilter &filter);
279  GA_AttributeScope scope,
280  const UT_StringRef &fromName,
281  const UT_StringHolder &toName);
282  /// Rename an attribute to an unused name. Typically used to make fromName
283  /// available for another attribute.
284  ///
285  /// Returns new name on success, NULL on failure.
286  const char *renameAttributeUnspecified(GA_AttributeOwner owner,
287  GA_AttributeScope scope,
288  const UT_StringRef &fromName);
289 
290  // Convenience attribute methods
291  GA_Attribute *createTupleAttribute(GA_AttributeOwner owner,
292  GA_AttributeScope scope,
293  const UT_StringHolder &name,
295  int tuple_size,
296  const GA_Defaults &defaults,
297  const UT_Options *creation_args = NULL,
298  const GA_AttributeOptions *attribute_options = NULL,
299  const GA_ReuseStrategy &r = GA_ReuseStrategy());
302  const UT_StringHolder &name,
303  GA_Storage storage,
304  int tuple_size,
305  const GA_Defaults &defaults,
306  const UT_Options *creation_args = NULL,
307  const GA_AttributeOptions *attribute_options = NULL,
309  {
310  return createTupleAttribute(owner, GA_SCOPE_PUBLIC, name, storage,
311  tuple_size, defaults, creation_args,
312  attribute_options, r);
313  }
314  GA_ATINumericUPtr createDetachedTupleAttribute(
315  GA_AttributeOwner owner,
316  GA_Storage storage,
317  int tuple_size,
318  const GA_Defaults &defaults=GA_Defaults(0.0f),
319  const GA_AttributeOptions *attribute_options=NULL) const;
320  GA_Attribute *createArrayAttribute(GA_AttributeOwner owner,
321  GA_AttributeScope scope,
322  const UT_StringHolder &name,
323  GA_Storage storage,
324  int tuple_size,
325  const UT_Options *creation_args = NULL,
326  const GA_AttributeOptions *attribute_options = NULL,
327  const UT_StringRef &attribtype="arraydata",
328  const GA_ReuseStrategy &r = GA_ReuseStrategy());
329  GA_Attribute *createTempTupleAttribute(GA_AttributeOwner owner,
330  GA_Storage storage,
331  int tuple_size,
332  const GA_Defaults &defaults,
333  const UT_Options *creation_args = NULL,
334  const GA_AttributeOptions *attribute_options = NULL);
335  GA_Attribute *createStringAttribute(GA_AttributeOwner owner,
336  GA_AttributeScope scope,
337  const UT_StringHolder &name,
338  int tuple_size=1,
339  const UT_Options *creation_args = NULL,
340  const GA_AttributeOptions *attribute_options = NULL,
341  const UT_StringRef &attribtype="string",
342  const GA_ReuseStrategy &r = GA_ReuseStrategy());
345  const UT_StringHolder &name,
346  int tuple_size=1,
347  const UT_Options *creation_args = NULL,
348  const GA_AttributeOptions *attribute_options = NULL,
349  const UT_StringRef &attribtype="string",
351  {
352  return createStringAttribute(owner, GA_SCOPE_PUBLIC, name, tuple_size,
353  creation_args, attribute_options, attribtype,
354  r);
355  }
356  GA_Attribute *createTempStringAttribute(GA_AttributeOwner owner,
357  int tuple_size=1);
358  GA_Attribute *createDictAttribute(GA_AttributeOwner owner,
359  GA_AttributeScope scope,
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="dict",
365  const GA_ReuseStrategy &r = GA_ReuseStrategy());
368  const UT_StringHolder &name,
369  int tuple_size=1,
370  const UT_Options *creation_args = NULL,
371  const GA_AttributeOptions *attribute_options = NULL,
372  const UT_StringRef &attribtype="dict",
374  {
375  return createStringAttribute(owner, GA_SCOPE_PUBLIC, name, tuple_size,
376  creation_args, attribute_options, attribtype,
377  r);
378  }
379  GA_Attribute *createTempDictAttribute(GA_AttributeOwner owner,
380  int tuple_size=1);
383  const UT_StringRef &name)
384  {
385  return findAttribute(GA_ATTRIB_POINT, scope,
386  name);
387  }
390  {
391  return findPointAttribute(GA_SCOPE_PUBLIC,
392  name);
393  }
396  const UT_StringRef &name)
397  {
398  return findAttribute(GA_ATTRIB_VERTEX, scope,
399  name);
400  }
403  {
404  return findVertexAttribute(GA_SCOPE_PUBLIC,
405  name);
406  }
409  const UT_StringRef &name)
410  {
411  return findAttribute(GA_ATTRIB_PRIMITIVE,
412  scope, name);
413  }
416  {
417  return findPrimitiveAttribute(GA_SCOPE_PUBLIC,
418  name);
419  }
422  const UT_StringRef &name)
423  {
424  return findAttribute(GA_ATTRIB_GLOBAL, scope,
425  name);
426  }
429  {
430  return findGlobalAttribute(GA_SCOPE_PUBLIC,
431  name);
432  }
433 
434  /// NOTE: These should ONLY be called by the GA_ElementGroup constructor & destructor.
435  /// @{
436  void registerGroup(GA_ElementGroup &group);
437  void unregisterGroup(GA_ElementGroup &group);
438  /// @}
439 
440  GA_ElementGroup *findGroup(GA_AttributeOwner owner,
441  const UT_StringRef &name);
442  // Convenience group methods
444  { return findGroup(GA_ATTRIB_POINT, name); }
446  { return findGroup(GA_ATTRIB_VERTEX, name); }
448  { return findGroup(GA_ATTRIB_PRIMITIVE, name); }
449 
450  /// Try to compress data pages
451  /// Will try to compress *all* pages overlapping the specified offset
452  /// range.
453  void tryCompressAllPages(GA_AttributeOwner owner,
454  GA_Offset start_offset = GA_Offset(0),
455  GA_Offset end_offset = GA_INVALID_OFFSET);
456 
457  /// Harden data pages
458  /// Will harden *all* pages overlapping the specified offset range.
459  /// Once this is done, multiple threads can write to an attribute in
460  /// parallel at a finer granularity than pages.
461  void hardenAllPages(GA_AttributeOwner owner,
462  GA_Offset start_offset = GA_Offset(0),
463  GA_Offset end_offset = GA_INVALID_OFFSET);
464 
465  /// Bumps all data IDs of attributes of the specified owner.
466  void bumpAllDataIds(GA_AttributeOwner owner);
467 
468  /// Save attribute sets to a JSON stream.
469  /// @section JSON-GA_AttributeSet JSON Schema: GA_AttributeSet
470  ///
471  /// Storage for a set of attributes.
472  ///
473  /// @code
474  /// {
475  /// "name" : "GA_AttributeSet",
476  /// "description" : "Attribute storage",
477  /// "type" : "orderedmap",
478  /// "properties": {
479  /// "vertexattributes": {
480  /// "type" : "array",
481  /// "items" : { "$ref" : "GA_Attribute" } ,
482  /// "description" : "Vertex attributes",
483  /// "optional" : true,
484  /// }
485  /// "pointattributes": {
486  /// "type" : "array",
487  /// "items" : { "$ref" : "GA_Attribute" } ,
488  /// "description" : "Point attributes",
489  /// "optional" : true,
490  /// }
491  /// "primitiveattributes": {
492  /// "type" : "array",
493  /// "items" : { "$ref" : "GA_Attribute" },
494  /// "description" : "Primitive attributes",
495  /// "optional" : true,
496  /// }
497  /// "globalattributes": {
498  /// "type" : "array",
499  /// "items" : { "$ref" : "GA_Attribute" } ,
500  /// "description" : "Global attributes",
501  /// "optional" : true,
502  /// }
503  /// }
504  /// }
505  /// @endcode
506  /// @see @ref JSON_FileFormat, GA_AIFJSON, GA_Attribute
507  bool jsonSave(UT_JSONWriter &w, const GA_SaveMap &s) const;
508 
509  /// Load attribute sets from a JSON stream
510  bool jsonLoad(UT_JSONParser &p, GA_LoadMap &m);
511 
512  /// Stat attribute stats from a JSON stream
513  static bool jsonStat(UT_JSONParser &p, GA_Stat &sbuf);
514 
515  // --- Query methods ----
516  int64 getMemoryUsage(bool inclusive) const;
517 
518  /// Count memory usage using a UT_MemoryCounter in order to count
519  /// shared memory correctly.
520  /// If inclusive is true, the size of this object is counted,
521  /// else only memory owned by this object is counted.
522  /// If this is pointed to by the calling object, inclusive should be true.
523  /// If this is contained in the calling object, inclusive should be false.
524  /// (Its memory was already counted in the size of the calling object.)
525  void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
526 
527 
528  bool loadDictH9(UT_IStream &is,
529  GA_AttributeOwner owner,
530  int tbl_size,
532  &definition,
534  &list,
535  const GA_AttribXlateH9 *xlate);
536  static bool saveDictH9(std::ostream &os, const char *label,
538  &list);
539 
540  /// Get information about attributes
541  bool stat(GA_Stat &stat, uint level) const;
542 
543  // Private to GA_AttributeRefMap methods --------------------
544  GA_Detail *getDetail() const { return myDetail; }
545 
546  // Private to GA_Detail methods ----------------------------------
547  void clearAllAttributes(bool for_deletion); // Called on detail deletion
548  void clearAllAttributes(GA_AttributeOwner owner, bool for_deletion); // Called in replaceWithPoints
549  // Reserve some additional space in a symbol table for batch addition.
550  void reserveNewSymbolTableSpace(GA_AttributeOwner owner,
551  GA_AttributeScope scope,
552  int size);
553  GA_ATITopology *createTopologyAttribute(GA_AttributeOwner owner,
554  const UT_StringHolder &name,
555  GA_AttributeOwner linkowner);
556 
557  /// Raw access to the GA_AttributeDict for a particular owner
560  {
561  UT_ASSERT_P(int(owner) >= 0 && int(owner) < int(GA_ATTRIB_OWNER_N));
562  return myAttributes[owner];
563  }
564 
565  /// Query whether a given string is a valid variable name.
566  static bool isValidName(const char *name,
568 
569  /// @private Function used in GA_Detail::replace to replace all attributes
570  /// If 'skip' is given, we will skip processing any attribute that
571  /// matches it. 'skip' will be called with attributes from the
572  /// destination as well as src geometries.
573  void replace(const GA_AttributeSet &src, GA_AttributeOwner owner,
574  bool replaceindexmap, const GA_AttributeFilter *skip);
575 
576  /// @private Method used by merging to destroy attributes before merging
577  void mergeDestroyDestination(GA_MergeMap &map);
578  /// @private Method used by merging to add attributes during merging
579  void mergeAddDestination(GA_MergeMap &map);
580 
581  /// @private Method used by merging detail attributes
582  void mergeDestroyGlobalDestination(GA_MergeMap &map)
583  { mergeDestroyDestination(GA_ATTRIB_DETAIL, map); }
584  /// @private Method used by merging detail attributes
585  void mergeAddGlobalDestination(GA_MergeMap &map)
586  { mergeAddDestination(GA_ATTRIB_DETAIL, map); }
587 
589  {
590  return myAttributes[owner].begin();
591  }
593  GA_AttributeScope scope) const
594  {
595  return myAttributes[owner].begin(scope);
596  }
598  { return myAttributes[owner].end(); }
600  GA_AttributeScope scope) const
601  { return myAttributes[owner].end(scope); }
602 
603  /// Called by GA_Detail::defragment when defragmenting a particular
604  /// index map. Topology attributes won't be modified; they're
605  /// handled separately.
606  /// NOTE: This bumps all data IDs of attributes whose owner is that of the
607  /// index map being defragmented, including topology attributes.
608  void defragment(const GA_Defragment &defrag);
609 
610  /// By default, data IDs are not generated for new attributes to force
611  /// callers to explicitly opt-in. It is very easy for data IDs to
612  /// become stale in code that is not explicitly notifying modified
613  /// attributes.
614  SYS_DEPRECATED_REPLACE(18.0, "Data Id generation is now always enabled.")
615  void enableDataIdGeneration();
616 
617  /// Query whether generation of data IDs has been enabled.
618  bool isGeneratingDataIds() const
619  { return myGenerateDataIds; }
620 
621 private:
622  /// @private
623  /// Used only by GA_Detail
624  void setNumBuckets(GA_AttributeOwner owner, GA_AttributeScope scope, size_t nbuckets)
625  {
626  myAttributes[owner].setNumBuckets(scope, nbuckets);
627  }
628 
629  void adjustArraySize(GA_AttributeOwner owner, GA_Offset size);
630  /// When a previously deleted element is reallocated, we need to reset the
631  /// attribute data to its default values. The constructElement() assumes
632  /// that there are no current values.
633  void constructElementBlock(GA_AttributeOwner owner, GA_Offset offset, GA_Offset nelements);
634  /// When an element is destroyed, the destructElement() method is called
635  /// so that the attribute data can be cleaned up properly (i.e. string
636  /// references or group data).
637  void destructElement(GA_AttributeOwner owner, GA_Offset offset);
638  void batchDeletion(GA_AttributeOwner owner);
639 
640  /// @private Method to grow arrays prior to merging
641  void mergeGrowData(GA_AttributeOwner owner, GA_MergeMap &map);
642 
643  /// @private Method to copy data from the source to the destination for all
644  /// attribute types.
645  void mergeCopyData(const GA_MergeMap &map);
646 
647  /// @private Method to copy data from source to dest for detail attributes
648  void mergeCopyGlobalData(const GA_MergeMap &map)
649  { mergeCopyData(GA_ATTRIB_DETAIL, map); }
650 
651  /// @private Method to copy data from the source to the destination
652  void mergeCopyData(GA_AttributeOwner owner, const GA_MergeMap &map);
653 
654  void mergeDestroyDestination(GA_AttributeOwner owner,
655  GA_MergeMap &map);
656  void mergeAddDestination(GA_AttributeOwner owner,
657  GA_MergeMap &map);
658 
659  const GA_IndexMap &getIndexMap(GA_AttributeOwner type) const;
660  UT_StringRef makeUniqueName(GA_AttributeOwner owner,
661  GA_AttributeScope scope,
662  UT_WorkBuffer &name_buffer) const;
663  UT_StringRef makeUniqueName(GA_AttributeOwner owner,
664  GA_AttributeScope scope,
665  const char *prefix,
666  UT_WorkBuffer &name_buffer) const;
667 
668  /// This method, unlike createAttribute(), merely allocates the requested
669  /// attribute. The allocated attribute is not registered in our tables
670  /// nor with our detail. Consequently name collisions are ignored, and it
671  /// is up to the caller to resolve any such collisions before registering
672  /// this attribute.
673  GA_Attribute *allocAttribute(GA_AttributeOwner owner,
674  const UT_StringHolder &name,
675  const UT_Options *creation_args,
676  const GA_AttributeOptions *attribute_options,
677  const UT_StringRef &attribtype) const;
678 
679  inline GA_AttributeProxy *findProxy(GA_AttributeOwner owner,
680  GA_AttributeScope scope,
681  const UT_StringRef &name) const
682  {
683  UT_ASSERT_P(owner >= GA_AttributeOwner(0) && owner < GA_ATTRIB_OWNER_N);
684  return myAttributes[owner].findProxy(scope, name);
685  }
686  inline GA_Attribute *find(GA_AttributeOwner owner,
687  GA_AttributeScope scope,
688  const UT_StringRef &name) const
689  {
690  GA_AttributeProxy *p = findProxy(owner, scope, name);
691  return p ? p->getAttribute() : NULL;
692  }
693  void add(GA_AttributeOwner owner, GA_Attribute *atr);
694  void invalidateProxyAndDestroyAttribute( GA_AttributeProxy *proxy);
695  bool destroy(GA_AttributeOwner owner, GA_Attribute *atr);
696  bool destroy(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
697  { return destroy(owner, find(owner, scope, name)); }
698  int destroy(GA_AttributeOwner owner, const GA_AttributeFilter &filter);
699  /// Avoids the safety check on P.
700  bool destroyIncludingP(GA_AttributeOwner owner, GA_Attribute *atr);
701  bool destroyImpl(GA_AttributeOwner owner,
702  GA_Attribute *atr);
703  void clear(GA_AttributeOwner owner, bool for_deletion);
704 
705  template<typename OP,typename FILL_OPT_OP>
706  GA_Attribute *createAttributeImpl(
707  OP &creation_op,
708  FILL_OPT_OP &fill_opt_op,
709  GA_AttributeOwner owner,
710  GA_AttributeScope scope,
711  const UT_StringHolder &name,
712  const UT_Options *create_args,
713  const GA_AttributeOptions *attribute_options,
714  const GA_AttributeType &attribtype,
715  const GA_ReuseStrategy &reuse);
716 
717  GA_Detail *myDetail;
718  GA_AttributeDict myAttributes[GA_ATTRIB_OWNER_N];
719  UT_Array<GA_Attribute *> *myDestructorCache[GA_ATTRIB_OWNER_N];
720  bool myGenerateDataIds : 1;
721  bool myPreferredPrec64 : 1;
722 };
723 
724 #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:196
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(const UT_StringRef &name)
GLuint counter
Definition: glew.h:2745
Specify when and how to reuse an existing attribute.
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, const UT_StringRef &name)
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 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
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:885
GA_DataIdStrategy
Definition: GA_Types.h:209
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:107
GA_AttributeDict::iterator begin(GA_AttributeOwner owner) const
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
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:317
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
GLuint const GLchar * name
Definition: glcorearb.h:785
Standard user attribute level.
Definition: GA_Types.h:147
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(const UT_StringRef &name)
GLenum src
Definition: glcorearb.h:1792
GA_ElementGroup * findVertexGroup(const UT_StringRef &name)
#define GA_INVALID_OFFSET
Definition: GA_Types.h:677
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
GLsizeiptr size
Definition: glcorearb.h:663
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GA_Size GA_Offset
Definition: GA_Types.h:640
GA_AttributeScope
Definition: GA_Types.h:141
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(GA_AttributeScope scope, const UT_StringRef &name)
GA_Detail * getDetail() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
GA_AttributeDict::iterator end(GA_AttributeOwner owner) const
std::string OIIO_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
Definition: format.h:2929
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:170
This class holds a reference to an attribute. Such an indirection level allows an easy way to invalid...
#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
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
GA_Attribute * getAttribute()
GA_ElementGroup * findPointGroup(const UT_StringRef &name)
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
Options during loading.
Definition: GA_LoadMap.h:42
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
MX_CORE_API bool isValidName(const string &name)
Return true if the given string is a valid MaterialX name.
SYS_FORCE_INLINE const GA_AttributeDict & getDict(GA_AttributeOwner owner) const
Raw access to the GA_AttributeDict for a particular owner.
UT_UniquePtr< GA_Attribute > GA_AttributeUPtr
Definition: GA_Attribute.h:918
GA_ElementGroup * findPrimitiveGroup(const UT_StringRef &name)
Attribute Interface for file I/O.
Definition: GA_AIFFileH9.h:43
GA_AttributeOwner
Definition: GA_Types.h:33
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.
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(GA_AttributeScope scope, const UT_StringRef &name)
Class used to map the GA attribute into a form for H9 geometry files.
Definition: GA_AIFFileH9.h:261
GLboolean GLuint group
Definition: glew.h:2750
const GLdouble * m
Definition: glew.h:9166
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
GLfloat f
Definition: glcorearb.h:1925
SYS_FORCE_INLINE GA_Attribute * findGlobalAttribute(GA_AttributeScope scope, const UT_StringRef &name)
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
Container class for all geometry.
Definition: GA_Detail.h:95
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())
GLintptr offset
Definition: glcorearb.h:664
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
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())
GLboolean r
Definition: glcorearb.h:1221
GLdouble s
Definition: glew.h:1395
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:49
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)