All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
layerStackRegistry.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 PCP_LAYER_STACK_REGISTRY_H
25 #define PCP_LAYER_STACK_REGISTRY_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/pcp/errors.h"
31 #include "pxr/base/tf/declarePtrs.h"
32 #include "pxr/base/tf/refBase.h"
33 
34 #include <memory>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
39 TF_DECLARE_REF_PTRS(Pcp_LayerStackRegistry);
40 
42 class Pcp_LayerStackRegistryData;
43 class Pcp_MutedLayers;
44 
49 class Pcp_LayerStackRegistry : public TfRefBase, public TfWeakBase {
50 public:
52  static Pcp_LayerStackRegistryRefPtr New(
53  const std::string& fileFormatTarget = std::string(),
54  bool isUsd=false);
55 
62  void MuteAndUnmuteLayers(const SdfLayerHandle& anchorLayer,
63  std::vector<std::string>* layersToMute,
64  std::vector<std::string>* layersToUnmute);
65 
68  const std::vector<std::string>& GetMutedLayers() const;
69 
75  bool IsLayerMuted(const SdfLayerHandle& anchorLayer,
76  const std::string& layerIdentifier,
77  std::string* canonicalLayerIdentifier = nullptr) const;
78 
82  PcpLayerStackRefPtr FindOrCreate(const PcpLayerStackIdentifier& identifier,
83  PcpErrorVector *allErrors);
84 
87  PcpLayerStackPtr Find(const PcpLayerStackIdentifier&) const;
88 
90  const PcpLayerStackPtrVector&
91  FindAllUsingLayer(const SdfLayerHandle& layer) const;
92 
96  const PcpLayerStackPtrVector&
97  FindAllUsingMutedLayer(const std::string& layerId) const;
98 
100  std::vector<PcpLayerStackPtr> GetAllLayerStacks() const;
101 
102 private:
104  Pcp_LayerStackRegistry(const std::string& fileFormatTarget,
105  bool isUsd);
106  ~Pcp_LayerStackRegistry();
107 
108  // Find that doesn't lock.
109  PcpLayerStackPtr _Find(const PcpLayerStackIdentifier&) const;
110 
111  // Remove the layer stack with the given identifier from the registry.
112  void _Remove(const PcpLayerStackIdentifier&,
113  const PcpLayerStack *);
114 
115  // Update the layer-stack-by-layer maps by setting the layers for the
116  // given layer stack.
117  void _SetLayers(const PcpLayerStack*);
118 
119  // Returns the file format target for layer stacks managed by this
120  // registry.
121  const std::string& _GetFileFormatTarget() const;
122 
123  // Returns whether or not we are in USD mode for avoiding
124  // extra calls such as Pcp_ComputeRelocationForLayerStack()
125  bool _IsUsd() const;
126 
127  // Returns the muted layer collection so that layer stack
128  // computation can easily query whether a layer is muted.
129  const Pcp_MutedLayers& _GetMutedLayers() const;
130 
131  // PcpLayerStack can access private _GetFileFormatTarget(),
132  // _Remove(), and _SetLayers().
133  friend class PcpLayerStack;
134 
135 private:
136  std::unique_ptr<Pcp_LayerStackRegistryData> _data;
137 };
138 
143 class Pcp_MutedLayers
144 {
145 public:
146  const std::vector<std::string>& GetMutedLayers() const;
147  void MuteAndUnmuteLayers(const SdfLayerHandle& anchorLayer,
148  std::vector<std::string>* layersToMute,
149  std::vector<std::string>* layersToUnmute);
150  bool IsLayerMuted(const SdfLayerHandle& anchorLayer,
151  const std::string& layerIdentifier,
152  std::string* canonicalLayerIdentifier = nullptr) const;
153 
154 private:
155  std::vector<std::string> _layers;
156 };
157 
158 PXR_NAMESPACE_CLOSE_SCOPE
159 
160 #endif // PCP_LAYER_STACK_REGISTRY_H
Represents a stack of layers that contribute opinions to composition.
Definition: layerStack.h:65
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:72
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:142
Arguments used to identify a layer stack.