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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
8 #define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/pcp/api.h"
12 #include "pxr/usd/sdf/fileFormat.h"
13 
15 
17 class VtValue;
18 
19 /// \class PcpDynamicFileFormatInterface
20 ///
21 /// Interface mixin that can be included by SdfFileFormat subclasses to enable
22 /// dynamic file format argument generation for a file format plugin.
23 /// When prim index composition encounters a payload to an asset of a file
24 /// format that implements this interface, it will call
25 /// ComposeFieldsForFileFormatArguments to generate arguments from the current
26 /// composition context at which the payload is being added. The derived file
27 /// format is on the hook for using the provided context to compute any prim
28 /// field values it needs and generate the relevant file format arguments for
29 /// its content.
31 {
32 public:
33  /// Empty virtual destructor to prevent build errors with some compilers.
34  PCP_API
36 
37  /// Derived classes must implement this function to compose prim metadata
38  /// fields and/or attribute default values using the given \p context and
39  /// use them to generate file format arguments for the layer at
40  /// \p assetPath.
41  ///
42  /// The context provides the methods for composing prim metadata field
43  /// values and attribute default values at the current point in prim index
44  /// composition which can be used to generate the relevant file format
45  /// arguments. In the implementation, these arguments need to be added to
46  /// the set of file format arguments provided by \p args.
47  ///
48  /// Additionally, implementations can output \p dependencyContextData of
49  /// any value type that will then be passed back in to calls to
50  /// CanFieldChangeAffectFileFormatArguments and
51  /// CanAttributeDefaultValueChangeAffectFileFormatArguments during change
52  /// processing. This can be used to provide more that context that is
53  /// specific to the file format when determining whether a field change
54  /// really does affect the arguments generated by a particular call to this
55  /// function.
56  PCP_API
58  const std::string &assetPath,
59  const PcpDynamicFileFormatContext &context,
61  VtValue *dependencyContextData) const = 0;
62 
63  /// Return true if the change to scene description of the field named
64  /// \p field can affect the dynamic file format arguments generated by
65  /// ComposeFieldsForFileFormatArguments.
66  ///
67  /// This function will be called during change processing to determine
68  /// whether a change to a field affects the dynamic file format arguments of
69  /// a payload that a prim index depends on.
70  ///
71  /// The default implementation always returns true, indicating that any
72  /// value change for a passed in field will require file format arguments to
73  /// be recomputed. Derived classes can override this function to be more
74  /// discerning about which changes would truly cause a file format argument
75  /// update, reducing the number of unnecessary recompositions of dynamic
76  /// payloads using its file format.
77  ///
78  /// \p oldValue and \p newValue contain the old and new values of the field.
79  /// \p dependencyContextData is the arbitrary typed data that was generated
80  /// by the call to ComposeFieldsForFileFormatArguments when the payload arc
81  /// was computed.
82  PCP_API
84  const TfToken &field,
85  const VtValue &oldValue,
86  const VtValue &newValue,
87  const VtValue &dependencyContextData) const;
88 
89  /// Return true if the change to scene description of the default field
90  /// for the attribute named \p attributeName can affect the dynamic file
91  /// format arguments generated by ComposeFieldsForFileFormatArguments.
92  ///
93  /// This function will be called during change processing to determine
94  /// whether a change to a attribute's default value affects the dynamic file
95  /// format arguments of a payload that a prim index depends on.
96  ///
97  /// The default implementation always returns true, indicating that any
98  /// default value change for a passed in attribute will require file format
99  /// arguments to be recomputed. Derived classes can override this function
100  /// to be more discerning about which changes would truly cause a file
101  /// format argument update, reducing the number of unnecessary
102  /// recompositions of dynamic payloads using its file format.
103  ///
104  /// \p oldValue and \p newValue contain the old and new values of the
105  /// default value field. \p dependencyContextData is the arbitrary typed
106  /// data that was generated by the call to
107  /// ComposeFieldsForFileFormatArguments when the payload arc was computed.
108  PCP_API
110  const TfToken &attributeName,
111  const VtValue &oldValue,
112  const VtValue &newValue,
113  const VtValue &dependencyContextData) const;
114 };
115 
117 
118 #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
Definition: token.h:70
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:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
**If you just want to fire and args
Definition: thread.h:618
virtual PCP_API ~PcpDynamicFileFormatInterface()
Empty virtual destructor to prevent build errors with some compilers.
std::map< std::string, std::string > FileFormatArguments
Definition: fileFormat.h:102
Definition: value.h:146
#define PCP_API
Definition: api.h:23