This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
connectableAPIBehavior.h
Go to the documentation of this file.
1//
2// Copyright 2020 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_USD_SHADE_CONNECTABLE_BEHAVIOR_H
8#define PXR_USD_USD_SHADE_CONNECTABLE_BEHAVIOR_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdShade/api.h"
14
15#include "pxr/base/gf/vec3f.h"
16#include "pxr/base/vt/array.h"
17
18#include "pxr/base/tf/type.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class UsdAttribute;
23class UsdShadeInput;
24class UsdShadeOutput;
25
32{
33public:
34
38 {
39 BasicNodes, // Shader, NodeGraph
40 DerivedContainerNodes, // Material, etc
41 };
42
43 // By default we want a connectableBehavior to not exhibit a container like
44 // behavior. And we want encapsulation behavior enabled by default.
45 USDSHADE_API
47 : _isContainer(false), _requiresEncapsulation(true) {}
48
49 USDSHADE_API
50 UsdShadeConnectableAPIBehavior(const bool isContainer,
51 const bool requiresEncapsulation)
52 : _isContainer(isContainer),
53 _requiresEncapsulation(requiresEncapsulation) {}
54
55 USDSHADE_API
57
71 USDSHADE_API
72 virtual bool
74 const UsdAttribute &,
75 std::string *reason) const;
76
89 USDSHADE_API
90 virtual bool
92 const UsdAttribute &,
93 std::string *reason) const;
94
100 USDSHADE_API
101 virtual bool
102 IsContainer() const final;
103
110 //
115 USDSHADE_API
116 virtual bool
118
119protected:
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;
138private:
139 bool _isContainer;
140 bool _requiresEncapsulation;
141};
142
189template <class PrimType, class BehaviorType = UsdShadeConnectableAPIBehavior>
190inline void
192{
194 TfType::Find<PrimType>(),
195 std::shared_ptr<UsdShadeConnectableAPIBehavior>(new BehaviorType));
196}
197
200USDSHADE_API
201void
203 const TfType& connectablePrimType,
204 const std::shared_ptr<UsdShadeConnectableAPIBehavior>& behavior);
205
206PXR_NAMESPACE_CLOSE_SCOPE
207
208#endif // PXR_USD_USD_SHADE_CONNECTABLE_BEHAVIOR_H
TfType represents a dynamic runtime type.
Definition: type.h:48
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
UsdShadeConnectableAPIBehavior defines the compatibilty and behavior UsdShadeConnectableAPIof when ap...
ConnectableNodeTypes
An enum describing the types of connectable nodes which will govern what connectibility rule is invok...
virtual USDSHADE_API bool IsContainer() const final
The function must be thread-safe.
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...
virtual USDSHADE_API bool RequiresEncapsulation() const final
The function must be thread-safe.
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.
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.
This class encapsulates a shader or node-graph input, which is a connectable attribute representing a...
Definition: input.h:32
This class encapsulates a shader or node-graph output, which is a connectable attribute representing ...
Definition: output.h:31
void UsdShadeRegisterConnectableAPIBehavior()
Registers behavior to define connectability of attributes for PrimType.
STL namespace.