HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dynamicFileFormatInterface.h
Go to the documentation of this file.
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_INTERFACE_H
25 #define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
29 #include "pxr/usd/sdf/fileFormat.h"
30 
32 
34 class VtValue;
35 
36 /// \class PcpDynamicFileFormatInterface
37 ///
38 /// Interface mixin that can be included by SdfFileFormat subclasses to enable
39 /// dynamic file format argument generation for a file format plugin.
40 /// When prim index composition encounters a payload to an asset of a file
41 /// format that implements this interface, it will call
42 /// ComposeFieldsForFileFormatArguments to generate arguments from the current
43 /// composition context at which the payload is being added. The derived file
44 /// format is on the hook for using the provided context to compute any prim
45 /// field values it needs and generate the relevant file format arguments for
46 /// its content.
48 {
49 public:
50  /// Empty virtual destructor to prevent build errors with some compilers.
51  PCP_API
53 
54  /// Derived classes must implement this function to compose prim metadata
55  /// fields and/or attribute default values using the given \p context and
56  /// use them to generate file format arguments for the layer at
57  /// \p assetPath.
58  ///
59  /// The context provides the methods for composing prim metadata field
60  /// values and attribute default values at the current point in prim index
61  /// composition which can be used to generate the relevant file format
62  /// arguments. In the implementation, these arguments need to be added to
63  /// the set of file format arguments provided by \p args.
64  ///
65  /// Additionally, implementations can output \p dependencyContextData of
66  /// any value type that will then be passed back in to calls to
67  /// CanFieldChangeAffectFileFormatArguments and
68  /// CanAttributeDefaultValueChangeAffectFileFormatArguments during change
69  /// processing. This can be used to provide more that context that is
70  /// specific to the file format when determining whether a field change
71  /// really does affect the arguments generated by a particular call to this
72  /// function.
73  PCP_API
75  const std::string &assetPath,
76  const PcpDynamicFileFormatContext &context,
78  VtValue *dependencyContextData) const = 0;
79 
80  /// Return true if the change to scene description of the field named
81  /// \p field can affect the dynamic file format arguments generated by
82  /// ComposeFieldsForFileFormatArguments.
83  ///
84  /// This function will be called during change processing to determine
85  /// whether a change to a field affects the dynamic file format arguments of
86  /// a payload that a prim index depends on.
87  ///
88  /// The default implementation always returns true, indicating that any
89  /// value change for a passed in field will require file format arguments to
90  /// be recomputed. Derived classes can override this function to be more
91  /// discerning about which changes would truly cause a file format argument
92  /// update, reducing the number of unnecessary recompositions of dynamic
93  /// payloads using its file format.
94  ///
95  /// \p oldValue and \p newValue contain the old and new values of the field.
96  /// \p dependencyContextData is the arbitrary typed data that was generated
97  /// by the call to ComposeFieldsForFileFormatArguments when the payload arc
98  /// was computed.
99  PCP_API
101  const TfToken &field,
102  const VtValue &oldValue,
103  const VtValue &newValue,
104  const VtValue &dependencyContextData) const;
105 
106  /// Return true if the change to scene description of the default field
107  /// for the attribute named \p attributeName can affect the dynamic file
108  /// format arguments generated by ComposeFieldsForFileFormatArguments.
109  ///
110  /// This function will be called during change processing to determine
111  /// whether a change to a attribute's default value affects the dynamic file
112  /// format arguments of a payload that a prim index depends on.
113  ///
114  /// The default implementation always returns true, indicating that any
115  /// default value change for a passed in attribute will require file format
116  /// arguments to be recomputed. Derived classes can override this function
117  /// to be more discerning about which changes would truly cause a file
118  /// format argument update, reducing the number of unnecessary
119  /// recompositions of dynamic payloads using its file format.
120  ///
121  /// \p oldValue and \p newValue contain the old and new values of the
122  /// default value field. \p dependencyContextData is the arbitrary typed
123  /// data that was generated by the call to
124  /// ComposeFieldsForFileFormatArguments when the payload arc was computed.
125  PCP_API
127  const TfToken &attributeName,
128  const VtValue &oldValue,
129  const VtValue &newValue,
130  const VtValue &dependencyContextData) const;
131 };
132 
134 
135 #endif // PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
virtual PCP_API void ComposeFieldsForFileFormatArguments(const std::string &assetPath, const PcpDynamicFileFormatContext &context, SdfFileFormat::FileFormatArguments *args, VtValue *dependencyContextData) const =0
virtual PCP_API bool CanFieldChangeAffectFileFormatArguments(const TfToken &field, const VtValue &oldValue, const VtValue &newValue, const VtValue &dependencyContextData) const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
Definition: token.h:87
virtual PCP_API bool CanAttributeDefaultValueChangeAffectFileFormatArguments(const TfToken &attributeName, const VtValue &oldValue, const VtValue &newValue, const VtValue &dependencyContextData) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
**If you just want to fire and args
Definition: thread.h:609
virtual PCP_API ~PcpDynamicFileFormatInterface()
Empty virtual destructor to prevent build errors with some compilers.
std::map< std::string, std::string > FileFormatArguments
Definition: fileFormat.h:119
Definition: value.h:164
#define PCP_API
Definition: api.h:40