journal.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_JOURNAL_H
8 #define PXR_EXEC_ESF_JOURNAL_H
9 
11 
12 #include "pxr/pxr.h"
13 
15 
17 #include "pxr/base/tf/hash.h"
18 #include "pxr/usd/sdf/path.h"
19 
20 PXR_NAMESPACE_OPEN_SCOPE
21 
38 {
40 
41 public:
50  EsfJournal &Add(const SdfPath &path, EsfEditReason editReason) {
51  if (TF_VERIFY(path.IsAbsolutePath()) && TF_VERIFY(!path.IsEmpty())) {
52  _hashMap[path] |= editReason;
53  }
54  return *this;
55  }
56 
62  void Merge(const EsfJournal &other) {
63  for (const value_type &entry : other) {
64  _hashMap[entry.first] |= entry.second;
65  }
66  }
67 
68  bool operator==(const EsfJournal &other) const {
69  return _hashMap == other._hashMap;
70  }
71 
72  bool operator!=(const EsfJournal &other) const {
73  return _hashMap != other._hashMap;
74  }
75 
83  using value_type = _HashMap::value_type;
84  using iterator = _HashMap::iterator;
85  using const_iterator = _HashMap::const_iterator;
86 
87  iterator begin() & {
88  return _hashMap.begin();
89  }
90 
91  iterator end() & {
92  return _hashMap.end();
93  }
94 
95  const_iterator begin() const & {
96  return _hashMap.begin();
97  }
98 
99  const_iterator end() const & {
100  return _hashMap.end();
101  }
102 
103  const_iterator cbegin() const & {
104  return _hashMap.begin();
105  }
106 
107  const_iterator cend() const & {
108  return _hashMap.end();
109  }
111 
112 private:
113  _HashMap _hashMap;
114 };
115 
116 PXR_NAMESPACE_CLOSE_SCOPE
117 
118 #endif
iterator end()
Returns an iterator pointing to the end of the map.
Definition: denseHashMap.h:354
_IteratorBase< value_type, typename _Vector::iterator > iterator
An iterator type for this map.
Definition: denseHashMap.h:225
Set of scene changes that should trigger edits to the exec network.
Definition: editReason.h:30
Stores a collection of edit reasons associated with scene objects.
Definition: journal.h:37
iterator begin()
Returns an iterator pointing to the beginning of the map.
Definition: denseHashMap.h:348
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:267
EsfJournal & Add(const SdfPath &path, EsfEditReason editReason)
Adds or updates a new entry in the journal.
Definition: journal.h:50
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
SDF_API bool IsAbsolutePath() const
Returns whether the path is absolute.
void Merge(const EsfJournal &other)
Merges the entries from the other EsfJournal into this one.
Definition: journal.h:62
_IteratorBase< const value_type, typename _Vector::const_iterator > const_iterator
An iterator type for this map.
Definition: denseHashMap.h:231
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:405