All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
connectableAPIBehavior.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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_USD_SHADE_CONNECTABLE_BEHAVIOR_H
25 #define PXR_USD_USD_SHADE_CONNECTABLE_BEHAVIOR_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdShade/api.h"
31 
32 #include "pxr/base/gf/vec3f.h"
33 #include "pxr/base/vt/array.h"
34 
35 #include "pxr/base/tf/type.h"
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 class UsdAttribute;
40 class UsdShadeInput;
41 class UsdShadeOutput;
42 
49 {
50 public:
51 
55  {
56  BasicNodes, // Shader, NodeGraph
57  DerivedContainerNodes, // Material, etc
58  };
59 
60  USDSHADE_API
62 
76  USDSHADE_API
77  virtual bool
79  const UsdAttribute &,
80  std::string *reason) const;
81 
94  USDSHADE_API
95  virtual bool
97  const UsdAttribute &,
98  std::string *reason) const;
99 
104  USDSHADE_API
105  virtual bool IsContainer() const;
106 
116  USDSHADE_API
117  virtual bool RequiresEncapsulation() const;
118 
119 protected:
127  USDSHADE_API
129  std::string *reason,
130  ConnectableNodeTypes nodeType =
131  ConnectableNodeTypes::BasicNodes) const;
132 
133  USDSHADE_API
134  bool _CanConnectOutputToSource(const UsdShadeOutput&, const UsdAttribute&,
135  std::string *reason,
136  ConnectableNodeTypes nodeType =
137  ConnectableNodeTypes::BasicNodes) const;
138 
139 
140 };
141 
173 template <class PrimType, class BehaviorType = UsdShadeConnectableAPIBehavior>
174 inline void
176 {
178  TfType::Find<PrimType>(),
179  std::shared_ptr<UsdShadeConnectableAPIBehavior>(new BehaviorType));
180 }
181 
184 USDSHADE_API
185 void
187  const TfType& connectablePrimType,
188  const std::shared_ptr<UsdShadeConnectableAPIBehavior>& behavior);
189 
190 PXR_NAMESPACE_CLOSE_SCOPE
191 
192 #endif // PXR_USD_USD_SHADE_CONNECTABLE_BEHAVIOR_H
void UsdShadeRegisterConnectableAPIBehavior()
Registers behavior to define connectability of attributes for PrimType.
virtual USDSHADE_API bool CanConnectInputToSource(const UsdShadeInput &, const UsdAttribute &, std::string *reason) const
The prim owning the input is guaranteed to be of the type this behavior was registered with...
USDSHADE_API bool _CanConnectInputToSource(const UsdShadeInput &, const UsdAttribute &, std::string *reason, ConnectableNodeTypes nodeType=ConnectableNodeTypes::BasicNodes) const
Helper function to separate and share special connectivity logic for specialized, NodeGraph-derived n...
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
ConnectableNodeTypes
An enum describing the types of connectable nodes which will govern what connectibility rule is invok...
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:48
virtual USDSHADE_API bool IsContainer() const
The function must be thread-safe.
virtual USDSHADE_API bool CanConnectOutputToSource(const UsdShadeOutput &, const UsdAttribute &, std::string *reason) const
The prim owning the output is guaranteed to be of the type this behavior was registered with...
TfType represents a dynamic runtime type.
Definition: type.h:64
virtual USDSHADE_API bool RequiresEncapsulation() const
The function must be thread-safe.
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:47
UsdShadeConnectableAPIBehavior defines the compatibilty and behavior UsdShadeConnectableAPIof when ap...