HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
materialNetworkInterface.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 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_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
25 #define PXR_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/path.h"
29 #include "pxr/base/vt/value.h"
31 #include "pxr/base/tf/token.h"
32 
34 
35 /// \class HdMaterialNetworkInterface
36 ///
37 /// Abstract interface for querying and mutating a material network.
38 ///
39 /// This is useful for implementing matfilt functions which can be reused
40 /// by future scene index implementations.
41 ///
42 /// NOTE: Subclasses make no guarantee of thread-safety even for the const
43 /// accessors as they might make use of internal caching for optimization.
44 /// Should you want to read from a material from multiple threads, create
45 /// a thread-specific interface instance. The non-const methods should
46 /// never be considered thread-safe from multiple interface instances
47 /// backed from the same concrete data.
49 {
50 public:
51  virtual ~HdMaterialNetworkInterface() = default;
52 
53  virtual SdfPath GetMaterialPrimPath() const = 0;
54 
55  virtual TfTokenVector GetNodeNames() const = 0;
56  virtual TfToken GetNodeType(const TfToken &nodeName) const = 0;
57 
58  /// Node type info is a collection of data related to the node type, often
59  /// used to determine the node type.
60  ///
61  /// For now, we only have getters for this, as we aren't really intending on
62  /// mutating this in any filter.
63  virtual TfTokenVector
64  GetNodeTypeInfoKeys(const TfToken& nodeName) const = 0;
65  virtual VtValue
66  GetNodeTypeInfoValue(const TfToken& nodeName, const TfToken& key) const = 0;
67 
69  const TfToken &nodeName) const = 0;
70 
72  const TfToken &nodeName,
73  const TfToken &paramName) const = 0;
74 
76  const TfToken &nodeName) const = 0;
77 
79  {
82  };
84 
86  const TfToken &nodeName,
87  const TfToken &inputName) const = 0;
88 
89  virtual void DeleteNode(const TfToken &nodeName) = 0;
90 
91  virtual void SetNodeType(
92  const TfToken &nodeName,
93  const TfToken &nodeType) = 0;
94 
95  virtual void SetNodeParameterValue(
96  const TfToken &nodeName,
97  const TfToken &paramName,
98  const VtValue &value) = 0;
99 
100  virtual void DeleteNodeParameter(
101  const TfToken &nodeName,
102  const TfToken &paramName) = 0;
103 
104  virtual void SetNodeInputConnection(
105  const TfToken &nodeName,
106  const TfToken &inputName,
107  const InputConnectionVector &connections) = 0;
108 
109  virtual void DeleteNodeInputConnection(
110  const TfToken &nodeName,
111  const TfToken &inputName) = 0;
112 
113  /// ------------------------------------------------------------------------
114  /// Terminal query & mutation
115  virtual TfTokenVector GetTerminalNames() const = 0;
116 
117  using InputConnectionResult = std::pair<bool, InputConnection>;
119  const TfToken &terminalName) const = 0;
120 
121  virtual void DeleteTerminal(
122  const TfToken &terminalName) = 0;
123 
124  virtual void SetTerminalConnection(
125  const TfToken &terminalName,
126  const InputConnection &connection) = 0;
127 };
128 
129 
131 
132 #endif // PXR_IMAGING_HD_MATERIAL_NETWORK_INTERFACE_H
virtual InputConnectionVector GetNodeInputConnection(const TfToken &nodeName, const TfToken &inputName) const =0
virtual TfTokenVector GetTerminalNames() const =0
virtual TfTokenVector GetNodeTypeInfoKeys(const TfToken &nodeName) const =0
virtual void DeleteNodeInputConnection(const TfToken &nodeName, const TfToken &inputName)=0
virtual void SetNodeParameterValue(const TfToken &nodeName, const TfToken &paramName, const VtValue &value)=0
virtual void SetNodeType(const TfToken &nodeName, const TfToken &nodeType)=0
virtual void SetTerminalConnection(const TfToken &terminalName, const InputConnection &connection)=0
virtual VtValue GetNodeTypeInfoValue(const TfToken &nodeName, const TfToken &key) const =0
Definition: token.h:87
virtual ~HdMaterialNetworkInterface()=default
virtual SdfPath GetMaterialPrimPath() const =0
virtual TfTokenVector GetNodeNames() const =0
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
Definition: path.h:291
virtual void SetNodeInputConnection(const TfToken &nodeName, const TfToken &inputName, const InputConnectionVector &connections)=0
virtual TfToken GetNodeType(const TfToken &nodeName) const =0
virtual void DeleteNode(const TfToken &nodeName)=0
virtual void DeleteNodeParameter(const TfToken &nodeName, const TfToken &paramName)=0
virtual TfTokenVector GetAuthoredNodeParameterNames(const TfToken &nodeName) const =0
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
virtual TfTokenVector GetNodeInputConnectionNames(const TfToken &nodeName) const =0
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual VtValue GetNodeParameterValue(const TfToken &nodeName, const TfToken &paramName) const =0
virtual void DeleteTerminal(const TfToken &terminalName)=0
Definition: core.h:1131
virtual InputConnectionResult GetTerminalConnection(const TfToken &terminalName) const =0
std::pair< bool, InputConnection > InputConnectionResult
Definition: value.h:167