All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dynamicFileFormatDependencyData.h
1 //
2 // Copyright 2019 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_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
25 #define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
30 #include "pxr/base/tf/token.h"
31 
32 #include <memory>
33 #include <vector>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
38 class VtValue;
39 
41 
51 {
52 public:
54  PCP_API
56 
58  PCP_API
61 
63  PCP_API
66 
68  PcpDynamicFileFormatDependencyData &operator=(
69  PcpDynamicFileFormatDependencyData &&rhs) {
70  Swap(rhs);
71  return *this;
72  }
73 
75  PcpDynamicFileFormatDependencyData &operator=(
76  const PcpDynamicFileFormatDependencyData &rhs) {
77  PcpDynamicFileFormatDependencyData(rhs).Swap(*this);
78  return *this;
79  }
80 
82  inline void Swap(PcpDynamicFileFormatDependencyData& rhs) {
83  _data.swap(rhs._data);
84  }
85 
87  inline void swap(PcpDynamicFileFormatDependencyData &rhs) { Swap(rhs); }
88 
90  inline bool IsEmpty() const {
91  return !_data;
92  }
93 
100  PCP_API
102  const PcpDynamicFileFormatInterface *dynamicFileFormat,
103  VtValue &&dependencyContextData,
104  TfToken::Set &&composedFieldNames);
105 
108  PCP_API
110  PcpDynamicFileFormatDependencyData &&dependencyData);
111 
114  PCP_API
115  const TfToken::Set &GetRelevantFieldNames() const;
116 
120  PCP_API
121  bool CanFieldChangeAffectFileFormatArguments(const TfToken &fieldName,
122  const VtValue& oldValue,
123  const VtValue& newValue) const;
124 
125 private:
126  // Struct containing the entire contents of the dependency.
127  struct _Data
128  {
129  using _ContextData =
130  std::pair<const PcpDynamicFileFormatInterface *, VtValue>;
131  using _ContextDataVector = std::vector<_ContextData>;
132 
133  _ContextDataVector dependencyContexts;
134  TfToken::Set relevantFieldNames;
135 
136  // Helper for adding relevant fields. We avoid copying by taking the
137  // input set if our set is empty.
138  void _AddRelevantFieldNames(TfToken::Set &&fieldNames);
139  };
140 
141  // Pointer to data. Will be null if this an empty data object.
142  std::unique_ptr<_Data> _data;
143 };
144 
145 PXR_NAMESPACE_CLOSE_SCOPE
146 
147 #endif // PXR_USD_PCP_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
PCP_API const TfToken::Set & GetRelevantFieldNames() const
Returns a list of field names that were composed for any of the dependency contexts that were added t...
PCP_API void AddDependencyContext(const PcpDynamicFileFormatInterface *dynamicFileFormat, VtValue &&dependencyContextData, TfToken::Set &&composedFieldNames)
Adds dependency info from a single context that generated dynamic file format arguments (usually a pa...
void swap(PcpDynamicFileFormatDependencyData &rhs)
Same as Swap(), but standard name.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
Standard pointer typedefs.
PCP_API bool CanFieldChangeAffectFileFormatArguments(const TfToken &fieldName, const VtValue &oldValue, const VtValue &newValue) const
Given a field name and the changed field values in oldAndNewValues this return whether this change ca...
PcpDynamicFileFormatDependencyData & operator=(PcpDynamicFileFormatDependencyData &&rhs)
Move assignment operator.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
std::set< TfToken, TfTokenFastArbitraryLessThan > Set
Predefined type for set of tokens, for when faster lookup is desired, without paying the memory or in...
Definition: token.h:183
PCP_API PcpDynamicFileFormatDependencyData()=default
Default constructor. This data will be empty.
Interface mixin that can be included by SdfFileFormat subclasses to enable dynamic file format argume...
bool IsEmpty() const
Returns whether this dependency data is empty.
void Swap(PcpDynamicFileFormatDependencyData &rhs)
Swap the contents of this dependency data with rhs.
Base class for file format implementations.
Definition: fileFormat.h:64
PcpDynamicFileFormatDependencyData & operator=(const PcpDynamicFileFormatDependencyData &rhs)
Copy assignment operator.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
PCP_API void AppendDependencyData(PcpDynamicFileFormatDependencyData &&dependencyData)
Takes all the dependency data from dependencyData and adds it to this dependency. ...
Contains the necessary information for storing a prim index&#39;s dependency on dynamic file format argum...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...