Loading...
Searching...
No Matches
expressionVariables.h
1//
2// Copyright 2023 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_USD_PCP_EXPRESSION_VARIABLES_H
25#define PXR_USD_PCP_EXPRESSION_VARIABLES_H
26
27#include "pxr/pxr.h"
28#include "pxr/usd/pcp/api.h"
30#include "pxr/usd/pcp/expressionVariablesSource.h"
31
33
34#include <utility>
35#include <unordered_map>
36
37PXR_NAMESPACE_OPEN_SCOPE
38
44{
45public:
51 PCP_API
54 const PcpLayerStackIdentifier& sourceLayerStackId,
55 const PcpLayerStackIdentifier& rootLayerStackId,
56 const PcpExpressionVariables* overrideExpressionVars = nullptr);
57
61
65 const PcpExpressionVariablesSource& source,
66 const VtDictionary& expressionVariables)
69 VtDictionary(expressionVariables))
70 { }
71
76 VtDictionary&& expressionVariables)
77 : _source(std::move(source))
78 , _expressionVariables(std::move(expressionVariables))
79 { }
80
83 bool operator==(const PcpExpressionVariables& rhs) const
84 {
85 return (this == &rhs) ||
86 (std::tie(_source, _expressionVariables) ==
87 std::tie(rhs._source, rhs._expressionVariables));
88 }
89
90 bool operator!=(const PcpExpressionVariables& rhs) const
91 {
92 return !(*this == rhs);
93 }
95
98 { return _source; }
99
102 { return _expressionVariables; }
103
105 void SetVariables(const VtDictionary& variables)
106 { _expressionVariables = variables; }
107
108private:
110 VtDictionary _expressionVariables;
111};
112
113// ------------------------------------------------------------
114
122{
123public:
124 PCP_API
126 const PcpLayerStackIdentifier& rootLayerStackIdentifier);
127
131 PCP_API
134
135private:
136 PcpLayerStackIdentifier _rootLayerStackId;
137
138 using _IdentifierToExpressionVarsMap = std::unordered_map<
140 _IdentifierToExpressionVarsMap _identifierToExpressionVars;
141};
142
143PXR_NAMESPACE_CLOSE_SCOPE
144
145#endif
Helper object for computing PcpExpressionVariable objects.
PCP_API const PcpExpressionVariables & ComputeExpressionVariables(const PcpLayerStackIdentifier &id)
Compute the composed expression variables for the layer stack with the given id.
Object containing composed expression variables associated with a given layer stack,...
PcpExpressionVariables()=default
Create a new object with no expression variables and the source set to the root layer stack.
const VtDictionary & GetVariables() const
Returns the composed expression variables dictionary.
PcpExpressionVariables(PcpExpressionVariablesSource &&source, VtDictionary &&expressionVariables)
Creates a new object for source with the given expressionVariables.
PcpExpressionVariables(const PcpExpressionVariablesSource &source, const VtDictionary &expressionVariables)
Creates a new object for source with the given expressionVariables.
static PCP_API PcpExpressionVariables Compute(const PcpLayerStackIdentifier &sourceLayerStackId, const PcpLayerStackIdentifier &rootLayerStackId, const PcpExpressionVariables *overrideExpressionVars=nullptr)
Compute the composed expression variables for sourceLayerStackId, recursively computing and composing...
void SetVariables(const VtDictionary &variables)
Set the composed expression variables to variables.
const PcpExpressionVariablesSource & GetSource() const
Return the source of the composed expression variables.
Represents the layer stack associated with a set of expression variables.
Arguments used to identify a layer stack.
A user-extensible hashing mechanism for use with runtime hash tables.
Definition: hash.h:477
A map with string keys and VtValue values.
Definition: dictionary.h:60
STL namespace.