HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
editReason.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_EXEC_ESF_EDIT_REASON_H
8 #define PXR_EXEC_ESF_EDIT_REASON_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/esf/api.h"
15 
16 #include <cstdint>
17 #include <string>
18 
20 
21 /// Set of scene changes that should trigger edits to the exec network.
22 ///
23 /// The set of change types contained in an EsfEdtReason is stored as a
24 /// bitmask, where each bit represents a different type of scene change.
25 /// EsfEditReason%s can be manipulated with standard bitwise operators.
26 ///
27 /// Users can only construct bitmasks from the provided set of supported edit
28 /// reasons.
29 ///
31 {
32 public:
33 
34  /// \name Supported edit reasons
35  /// @{
36 
37  static const EsfEditReason None;
38 
39  /// Something about an object has changed.
40  ///
41  /// This includes recursive resyncs on namespace ancestors.
42  ///
44 
45  /// The list of properties on a prim has changed.
46  ///
47  /// This includes renames to the prim's properties.
48  ///
50 
51  /// The list of connection paths on an attribute has changed.
52  ///
54 
55  /// The set of connections that target an object has changed.
56  ///
58 
59  /// The list of target paths on a relationship has changed.
60  ///
62 
63  /// @}
64 
65  /// \name Bitwise operations
66  /// @{
67 
68  /// Return true if this object contains any edit reasons.
69  constexpr explicit operator bool() const {
70  return _bits;
71  }
72 
73  constexpr bool operator==(EsfEditReason other) const {
74  return _bits == other._bits;
75  }
76 
77  constexpr bool operator!=(EsfEditReason other) const {
78  return _bits != other._bits;
79  }
80 
82  _bits &= other._bits;
83  return *this;
84  }
85 
87  _bits |= other._bits;
88  return *this;
89  }
90 
91  constexpr EsfEditReason operator&(EsfEditReason other) const {
92  return {_bits & other._bits};
93  }
94 
95  constexpr EsfEditReason operator|(EsfEditReason other) const {
96  return {_bits | other._bits};
97  }
98 
99  /// Return true if \p other's reasons are entirely contained by this set
100  /// of reasons.
101  ///
102  constexpr bool Contains(EsfEditReason other) const {
103  return (_bits & other._bits) == other._bits;
104  }
105 
106  /// @}
107 
108  /// Enables consistent sorting of EsfEditReasons.
109  bool operator<(const EsfEditReason &other) const {
110  return _bits < other._bits;
111  }
112 
113  /// Equivalent to EsfEditReason::None.
114  constexpr EsfEditReason() = default;
115 
116  /// Get a string describing the contents of this edit reason.
117  ///
118  /// The string is a comma-separated list of pre-defined edit reasons that
119  /// make up this value.
120  ///
121  ESF_API std::string GetDescription() const;
122 
123 private:
124  using _BitsType = uint32_t;
125 
126  // Private methods use this constructor to initialize from a raw bitmask.
127  constexpr EsfEditReason(_BitsType bits) : _bits(bits) {}
128 
129  // By using an enum class value for each bit position, we make it less
130  // error-prone to define new edit reasons.
131  enum class _BitIndex : uint8_t {
137  Max
138  };
139 
140  // Predefined edit reasons use this constructor.
141  constexpr EsfEditReason(_BitIndex bit)
142  : _bits(1 << static_cast<int>(bit))
143  {}
144 
145  // Returns a string describing this _BitIndex enum value.
146  static const char *_GetBitDescription(_BitIndex bit);
147 
148  _BitsType _bits = 0;
149 };
150 
151 inline constexpr EsfEditReason EsfEditReason::None(0);
152 
155 
158 
161 
164 
167 
169 
170 #endif
constexpr bool operator!=(EsfEditReason other) const
Return true if this object contains any edit reasons.
Definition: editReason.h:77
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
static const EsfEditReason ChangedConnectionPaths
Definition: editReason.h:53
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
constexpr EsfEditReason operator|(EsfEditReason other) const
Return true if this object contains any edit reasons.
Definition: editReason.h:95
constexpr bool operator==(EsfEditReason other) const
Return true if this object contains any edit reasons.
Definition: editReason.h:73
OutGridT const XformOp bool bool
constexpr bool Contains(EsfEditReason other) const
Definition: editReason.h:102
constexpr EsfEditReason & operator|=(EsfEditReason other)
Return true if this object contains any edit reasons.
Definition: editReason.h:86
static const EsfEditReason None
Definition: editReason.h:37
bool operator<(const EsfEditReason &other) const
Enables consistent sorting of EsfEditReasons.
Definition: editReason.h:109
static const EsfEditReason ChangedTargetPaths
Definition: editReason.h:61
constexpr EsfEditReason operator&(EsfEditReason other) const
Return true if this object contains any edit reasons.
Definition: editReason.h:91
static const EsfEditReason ChangedIncomingConnections
Definition: editReason.h:57
constexpr EsfEditReason()=default
Equivalent to EsfEditReason::None.
constexpr EsfEditReason & operator&=(EsfEditReason other)
Return true if this object contains any edit reasons.
Definition: editReason.h:81
ESF_API std::string GetDescription() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define ESF_API
Definition: api.h:25
static const EsfEditReason ResyncedObject
Definition: editReason.h:43
static const EsfEditReason ChangedPropertyList
Definition: editReason.h:49