Loading...
Searching...
No Matches
expressionVariables.h
1//
2// Copyright 2023 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_USD_PCP_EXPRESSION_VARIABLES_H
8#define PXR_USD_PCP_EXPRESSION_VARIABLES_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/pcp/api.h"
13#include "pxr/usd/pcp/expressionVariablesSource.h"
14
16
17#include <utility>
18#include <unordered_map>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
27{
28public:
34 PCP_API
37 const PcpLayerStackIdentifier& sourceLayerStackId,
38 const PcpLayerStackIdentifier& rootLayerStackId,
39 const PcpExpressionVariables* overrideExpressionVars = nullptr);
40
44
48 const PcpExpressionVariablesSource& source,
49 const VtDictionary& expressionVariables)
52 VtDictionary(expressionVariables))
53 { }
54
59 VtDictionary&& expressionVariables)
60 : _source(std::move(source))
61 , _expressionVariables(std::move(expressionVariables))
62 { }
63
66 bool operator==(const PcpExpressionVariables& rhs) const
67 {
68 return (this == &rhs) ||
69 (std::tie(_source, _expressionVariables) ==
70 std::tie(rhs._source, rhs._expressionVariables));
71 }
72
73 bool operator!=(const PcpExpressionVariables& rhs) const
74 {
75 return !(*this == rhs);
76 }
78
81 { return _source; }
82
85 { return _expressionVariables; }
86
88 void SetVariables(const VtDictionary& variables)
89 { _expressionVariables = variables; }
90
91private:
93 VtDictionary _expressionVariables;
94};
95
96// ------------------------------------------------------------
97
105{
106public:
107 PCP_API
109 const PcpLayerStackIdentifier& rootLayerStackIdentifier);
110
114 PCP_API
117
118private:
119 PcpLayerStackIdentifier _rootLayerStackId;
120
121 using _IdentifierToExpressionVarsMap = std::unordered_map<
123 _IdentifierToExpressionVarsMap _identifierToExpressionVars;
124};
125
126PXR_NAMESPACE_CLOSE_SCOPE
127
128#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:472
A map with string keys and VtValue values.
Definition: dictionary.h:52
STL namespace.