HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
15 
17 #include "pxr/base/tf/hash.h"
18 #include "pxr/usd/sdf/path.h"
19 
21 
22 /// Stores a collection of edit reasons associated with scene objects.
23 ///
24 /// Exec compilation uses an EsfJournal to log all scene queries performed
25 /// while compiling a node or forming connections in the exec network.
26 /// An instance of EsfJournal is passed to public methods of scene adapter
27 /// interfaces (e.g. EsfPrimInterface::GetParent), and those methods add entries
28 /// to the journal.
29 ///
30 /// Given the scene adapter method calls made to produce a node in the network,
31 /// the resulting journal contains all scene changes that would trigger
32 /// uncompilation of that node. Likewise, when the exec compiler uses the scene
33 /// adapter to identify the connections flowing into a node in the exec network,
34 /// the resulting journal contains all scene changes that would trigger
35 /// uncompilation of those connections.
36 ///
38 {
40 
41 public:
42  /// Adds or updates a new entry in the journal.
43  ///
44  /// If a journal entry already exists for \p path, then its edit reasons
45  /// are extended by \p editReason.
46  ///
47  /// Returns a reference to the current journal, so multiple Add calls can be
48  /// chained together.
49  ///
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 
57  /// Merges the entries from the \p other EsfJournal into this one.
58  ///
59  /// If this journal and \p other have entries for the same path, then
60  /// the merged entry contains the union of both reasons.
61  ///
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 
76  /// \name Iteration API
77  ///
78  /// These types and methods allow EsfJournal to be used in range-based
79  /// for-loops.
80  ///
81  /// @{
82  ///
86 
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  }
110  /// @}
111 
112 private:
113  _HashMap _hashMap;
114 };
115 
117 
118 #endif
_IteratorBase< const value_type, typename _Vector::const_iterator > const_iterator
Definition: denseHashMap.h:227
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
bool operator==(const EsfJournal &other) const
Definition: journal.h:68
const_iterator begin() const &
Definition: journal.h:95
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
Definition: path.h:405
EsfJournal & Add(const SdfPath &path, EsfEditReason editReason)
Definition: journal.h:50
std::pair< const SdfPath, EsfEditReason > value_type
Definition: denseHashMap.h:44
iterator end()&
Definition: journal.h:91
_HashMap::value_type value_type
Definition: journal.h:83
const_iterator cbegin() const &
Definition: journal.h:103
SDF_API bool IsAbsolutePath() const
Returns whether the path is absolute.
iterator end()
Definition: denseHashMap.h:350
Definition: path.h:280
void Merge(const EsfJournal &other)
Definition: journal.h:62
_HashMap::iterator iterator
Definition: journal.h:84
bool operator!=(const EsfJournal &other) const
Definition: journal.h:72
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
iterator begin()&
Definition: journal.h:87
const_iterator end() const &
Definition: journal.h:99
iterator begin()
Definition: denseHashMap.h:344
const_iterator cend() const &
Definition: journal.h:107
_HashMap::const_iterator const_iterator
Definition: journal.h:85
_IteratorBase< value_type, typename _Vector::iterator > iterator
Definition: denseHashMap.h:221