HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
filteringSceneIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_FILTERING_SCENE_INDEX_H
25 #define PXR_IMAGING_HD_FILTERING_SCENE_INDEX_H
26 
27 #include "pxr/pxr.h"
28 
29 #include <set>
30 #include <unordered_map>
31 
33 #include "pxr/base/tf/singleton.h"
34 
35 #include "pxr/usd/sdf/path.h"
36 
40 
42 
44 
45 ///
46 /// \class HdFilteringSceneIndexBase
47 ///
48 /// An abstract base class for scene indexes that have one or more input scene
49 /// indexes which serve as a basis for their own scene.
50 ///
52 {
53 public:
54  virtual std::vector<HdSceneIndexBaseRefPtr> GetInputScenes() const = 0;
55 };
56 
58 
59 ///
60 /// \class HdSingleInputFilteringSceneIndexBase
61 ///
62 /// An abstract base class for a filtering scene index that observes a single
63 /// input scene index.
64 ///
66 {
67 public:
68  HD_API
69  std::vector<HdSceneIndexBaseRefPtr> GetInputScenes() const final;
70 
71 protected:
72  HD_API
74  const HdSceneIndexBaseRefPtr &inputSceneIndex);
75 
76  virtual void _PrimsAdded(
77  const HdSceneIndexBase &sender,
78  const HdSceneIndexObserver::AddedPrimEntries &entries) = 0;
79 
80  virtual void _PrimsRemoved(
81  const HdSceneIndexBase &sender,
82  const HdSceneIndexObserver::RemovedPrimEntries &entries) = 0;
83 
84  virtual void _PrimsDirtied(
85  const HdSceneIndexBase &sender,
86  const HdSceneIndexObserver::DirtiedPrimEntries &entries) = 0;
87 
88  // Base implementation converts prim removed messages.
89  HD_API
90  virtual void _PrimsRenamed(
91  const HdSceneIndexBase &sender,
93 
94  /// Returns the input scene.
95  ///
96  /// It is always safe to call and dereference this return value. If this
97  /// was constructed with a null scene index, a fallback one will be used.
98  const HdSceneIndexBaseRefPtr &_GetInputSceneIndex() const {
99  return _inputSceneIndex;
100  }
101 
102 private:
103 
104  HdSceneIndexBaseRefPtr _inputSceneIndex;
105 
106  friend class _Observer;
107 
108  class _Observer : public HdSceneIndexObserver
109  {
110  public:
111  _Observer(HdSingleInputFilteringSceneIndexBase *owner)
112  : _owner(owner) {}
113 
114  void PrimsAdded(
115  const HdSceneIndexBase &sender,
116  const AddedPrimEntries &entries) override;
117 
118  void PrimsRemoved(
119  const HdSceneIndexBase &sender,
120  const RemovedPrimEntries &entries) override;
121 
122  void PrimsDirtied(
123  const HdSceneIndexBase &sender,
124  const DirtiedPrimEntries &entries) override;
125 
126  void PrimsRenamed(
127  const HdSceneIndexBase &sender,
128  const RenamedPrimEntries &entries) override;
129  private:
130  HdSingleInputFilteringSceneIndexBase *_owner;
131  };
132 
133  _Observer _observer;
134 
135 };
136 
138 
139 #endif // PXR_IMAGING_HD_FILTERING_SCENE_INDEX_H
virtual std::vector< HdSceneIndexBaseRefPtr > GetInputScenes() const =0
HD_API std::vector< HdSceneIndexBaseRefPtr > GetInputScenes() const final
#define HD_API
Definition: api.h:40
virtual void _PrimsRemoved(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RemovedPrimEntries &entries)=0
HD_API HdSingleInputFilteringSceneIndexBase(const HdSceneIndexBaseRefPtr &inputSceneIndex)
virtual void _PrimsDirtied(const HdSceneIndexBase &sender, const HdSceneIndexObserver::DirtiedPrimEntries &entries)=0
virtual HD_API void _PrimsRenamed(const HdSceneIndexBase &sender, const HdSceneIndexObserver::RenamedPrimEntries &entries)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_AND_REF_PTRS(HdFilteringSceneIndexBase)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual void _PrimsAdded(const HdSceneIndexBase &sender, const HdSceneIndexObserver::AddedPrimEntries &entries)=0
const HdSceneIndexBaseRefPtr & _GetInputSceneIndex() const