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 
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/esf/api.h"
15 
16 #include <cstdint>
17 #include <string>
18 
19 PXR_NAMESPACE_OPEN_SCOPE
20 
31 {
32 public:
33 
36 
37  static const EsfEditReason None;
38 
44 
50 
54 
58 
62 
64 
67 
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 
81  constexpr EsfEditReason& operator&=(EsfEditReason other) {
82  _bits &= other._bits;
83  return *this;
84  }
85 
86  constexpr EsfEditReason& operator|=(EsfEditReason other) {
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 
102  constexpr bool Contains(EsfEditReason other) const {
103  return (_bits & other._bits) == other._bits;
104  }
105 
107 
109  bool operator<(const EsfEditReason &other) const {
110  return _bits < other._bits;
111  }
112 
114  constexpr EsfEditReason() = default;
115 
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 {
132  ResyncedObject,
133  ChangedPropertyList,
134  ChangedConnectionPaths,
135  ChangedIncomingConnections,
136  ChangedTargetPaths,
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 
154  EsfEditReason::_BitIndex::ResyncedObject);
155 
157  EsfEditReason::_BitIndex::ChangedPropertyList);
158 
160  EsfEditReason::_BitIndex::ChangedConnectionPaths);
161 
163  EsfEditReason::_BitIndex::ChangedIncomingConnections);
164 
166  EsfEditReason::_BitIndex::ChangedTargetPaths);
167 
168 PXR_NAMESPACE_CLOSE_SCOPE
169 
170 #endif
static const EsfEditReason ChangedConnectionPaths
The list of connection paths on an attribute has changed.
Definition: editReason.h:53
ESF_API std::string GetDescription() const
Get a string describing the contents of this edit reason.
Set of scene changes that should trigger edits to the exec network.
Definition: editReason.h:30
static const EsfEditReason ResyncedObject
Something about an object has changed.
Definition: editReason.h:43
static const EsfEditReason ChangedTargetPaths
The list of target paths on a relationship has changed.
Definition: editReason.h:61
static const EsfEditReason ChangedPropertyList
The list of properties on a prim has changed.
Definition: editReason.h:49
static const EsfEditReason ChangedIncomingConnections
The set of connections that target an object has changed.
Definition: editReason.h:57
bool operator<(const EsfEditReason &other) const
Enables consistent sorting of EsfEditReasons.
Definition: editReason.h:109
constexpr EsfEditReason()=default
Equivalent to EsfEditReason::None.
constexpr bool Contains(EsfEditReason other) const
Return true if other's reasons are entirely contained by this set of reasons.
Definition: editReason.h:102