HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDG_AttributeGeometry.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  * COMMENTS:
7  */
8 
9 #ifndef __PDG_ATTRIBUTE_Geometry_H__
10 #define __PDG_ATTRIBUTE_Geometry_H__
11 
12 #include "PDG_API.h"
13 
14 #include "PDG_ApplicationShim.h"
15 #include "PDG_AttributeData.h"
16 
17 class UT_JSONValue;
18 class UT_JSONWriter;
19 class UT_StringHolder;
20 
21 /**
22  * Attribute that contains a single PDG_AttributeShim::Geometry* for storing
23  * geometry on a work item.
24  */
26 {
27 public:
28  static constexpr PDG_AttributeType TypeEnum = PDG_AttributeType::eGeometry;
29 
33 
34 public:
36  explicit PDG_AttributeGeometry(Data geometry);
37  ~PDG_AttributeGeometry() override;
38 
39  int64 getMemoryUsage(bool inclusive) const override;
41  UT_WorkBuffer& errors) const override;
42  PDG_AttributeData* clone() const override;
43  bool saveData(UT_JSONWriter& writer) const override;
44  bool loadData(const UT_JSONValue& value) override;
45  bool compare(
46  const PDG_AttributeData* other
47  ) const override;
49  PDG_AttributeMergeOp merge_op,
50  int stride) override;
51 
52  Data geometry() const;
53  void setGeometry(Data geometry);
54  bool desc(UT_StringHolder& str) const;
55 
56  inline bool hasData() const
57  {
58  return (myGeometry != nullptr);
59  }
60 
61  inline int size() const
62  {
63  return 1;
64  }
65 
66  inline bool valid(int component) const
67  {
68  return (component == 0);
69  }
70 
71  inline bool value(Data& geometry, int component) const
72  {
73  if (component != 0)
74  return false;
75 
76  geometry = myGeometry;
77  return true;
78  }
79 
80  inline void setValue(Data geometry, int index)
81  {
82  setGeometry(geometry);
83  }
84 
85  inline void swap(PDG_AttributeGeometry* other)
86  {
87  std::swap(myGeometry, other->myGeometry);
88  }
89 
90  void copy(const PDG_AttributeGeometry* other);
91 
92 private:
93  Data myGeometry;
94 };
95 
96 #endif
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
Definition: UT_ArraySet.h:1631
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
virtual bool compare(const PDG_AttributeData *) const =0
Compares this data object with another data object.
#define PDG_API
Definition: PDG_API.h:23
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
bool valid(int component) const
virtual bool loadData(const UT_JSONValue &)=0
Loads data from a JSON value.
virtual PDG_AttributeMergeError merge(PDG_AttributeMergeOp merge_op, int stride)=0
Applies a merge op to the data in this attribute.
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
virtual bool saveData(UT_JSONWriter &) const =0
Serializes the data to a JSON writer.
long long int64
Definition: SYS_Types.h:116
void swap(PDG_AttributeGeometry *other)
PDG_AttributeMergeOp
Enumeration of different ways that attributes can be combined.
A single PDG_ApplicationShim::Geometry instance.
bool value(Data &geometry, int component) const
virtual bool hash(SYS_HashType &hash_value, UT_WorkBuffer &errors) const =0
Return a hash value derived from the attribute data.
PDG_AttributeType
Enumeration of possible attribute types.
virtual int64 getMemoryUsage(bool inclusive) const =0
Returns the memory usage of the attribute and its data.
GLuint index
Definition: glcorearb.h:786
void setValue(Data geometry, int index)
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
PDG_AttributeMergeError
Enumerations of errors that can occur when merging attributes.
Definition: core.h:1131
size_t hash_value(const CH_ChannelRef &ref)
virtual PDG_AttributeData * clone() const =0
Deep copies this attribute.