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_OptionsHolder;
20 class UT_StringHolder;
21 
22 /**
23  * Attribute that contains a single PDG_AttributeShim::Geometry* for storing
24  * geometry on a work item.
25  */
27 {
28 public:
29  static constexpr PDG_AttributeType TypeEnum = PDG_AttributeType::eGeometry;
30 
34 
35 public:
37  explicit PDG_AttributeGeometry(Data geometry);
38  ~PDG_AttributeGeometry() override;
39 
40  int64 getMemoryUsage(bool inclusive) const override;
42  UT_WorkBuffer& errors) const override;
43  PDG_AttributeData* clone() const override;
44 
45  bool saveData(UT_JSONWriter& writer) const override;
46  void saveData(
47  const UT_StringHolder& key,
48  UT_OptionsHolder& dict) const override;
49 
50  bool loadData(const UT_JSONValue& value) override;
51  bool loadData(
52  const UT_StringHolder& key,
53  const UT_OptionsHolder& dict) override;
54 
55  bool compare(
56  const PDG_AttributeData* other
57  ) const override;
59  PDG_AttributeMergeOp merge_op,
60  int stride) override;
61 
62  Data geometry() const;
63  void setGeometry(Data geometry);
64  bool desc(UT_StringHolder& str) const;
65 
66  inline bool hasData() const
67  {
68  return (myGeometry != nullptr);
69  }
70 
71  inline int size() const
72  {
73  return 1;
74  }
75 
76  inline bool valid(int component) const
77  {
78  return (component == 0);
79  }
80 
81  inline bool value(Data& geometry, int component) const
82  {
83  if (component != 0)
84  return false;
85 
86  geometry = myGeometry;
87  return true;
88  }
89 
90  inline void setValue(Data geometry, int index)
91  {
92  setGeometry(geometry);
93  }
94 
95  inline void swap(PDG_AttributeGeometry* other)
96  {
97  std::swap(myGeometry, other->myGeometry);
98  }
99 
100  void copy(const PDG_AttributeGeometry* other);
101 
102 private:
103  Data myGeometry;
104 };
105 
106 #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
A single PDG_ApplicationShim::Geometry instance.
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
PDG_AttributeType
Enumeration of possible attribute types.
void swap(PDG_AttributeGeometry *other)
PDG_AttributeMergeOp
Enumeration of different ways that attributes can be combined.
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.
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.