HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
prefixingSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 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_IMAGING_HD_PREFIXING_SCENE_INDEX_H
8 #define PXR_IMAGING_HD_PREFIXING_SCENE_INDEX_H
9 
10 #include "pxr/imaging/hd/api.h"
12 
14 
17 
18 ///
19 /// \class HdPrefixingSceneIndex
20 ///
21 /// A prefixing scene index is one in which the input scene contains
22 /// data sources whose paths are all prefixed with a given prefix.
23 ///
25 {
26 public:
27 
28  /// Creates a new prefixing scene index.
29  ///
30  static HdPrefixingSceneIndexRefPtr New(
31  const HdSceneIndexBaseRefPtr &inputScene, const SdfPath &prefix)
32  {
33  return TfCreateRefPtr(new HdPrefixingSceneIndex(inputScene, prefix));
34  }
35 
36  // satisfying HdSceneIndexBase
37  HD_API
38  HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override;
39 
40  HD_API
41  SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override;
42 
43  HD_API
44  SdfPath AddPrefix(const SdfPath &primPath) const;
45  HD_API
46  SdfPath RemovePrefix(const SdfPath &primPath) const;
47 
48 protected:
49 
50  HD_API
51  HdPrefixingSceneIndex(const HdSceneIndexBaseRefPtr &inputScene,
52  const SdfPath &prefix);
53 
54  // satisfying HdSingleInputFilteringSceneIndexBase
55  void _PrimsAdded(
56  const HdSceneIndexBase &sender,
57  const HdSceneIndexObserver::AddedPrimEntries &entries) override;
58 
59  void _PrimsRemoved(
60  const HdSceneIndexBase &sender,
61  const HdSceneIndexObserver::RemovedPrimEntries &entries) override;
62 
63  void _PrimsDirtied(
64  const HdSceneIndexBase &sender,
65  const HdSceneIndexObserver::DirtiedPrimEntries &entries) override;
66 
67 private:
68 
69  const SdfPath _prefix;
70  typedef std::unordered_map<SdfPath, SdfPath, SdfPath::Hash> SdfPathMap;
71  SdfPathMap _addPrefixMap;
72  SdfPathMap _removePrefixMap;
73 };
74 
76 
77 #endif
78 
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition: refPtr.h:1190
void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries) override
HD_API SdfPath AddPrefix(const SdfPath &primPath) const
HD_API SdfPath RemovePrefix(const SdfPath &primPath) const
HD_API HdPrefixingSceneIndex(const HdSceneIndexBaseRefPtr &inputScene, const SdfPath &prefix)
HD_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath) const override
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define HD_API
Definition: api.h:23
void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries) override
std::vector< class SdfPath > SdfPathVector
static HdPrefixingSceneIndexRefPtr New(const HdSceneIndexBaseRefPtr &inputScene, const SdfPath &prefix)
Definition: path.h:280
void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries) override
TF_DECLARE_REF_PTRS(HdPrefixingSceneIndex)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API HdSceneIndexPrim GetPrim(const SdfPath &primPath) const override