Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1//
2// Copyright 2025 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_EXEC_VDF_INPUT_H
8#define PXR_EXEC_VDF_INPUT_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
16#include "pxr/exec/vdf/mask.h"
17#include "pxr/exec/vdf/types.h"
18
19#include "pxr/base/tf/span.h"
20
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
25class VdfConnection;
26class VdfNode;
27class VdfOutput;
28
36{
37public:
38
41 VDF_API
43
48 VdfInput(VdfNode &owner, int specIndex, const VdfOutput *output = NULL) :
49 _owner(owner), _associatedOutput(output), _specIndex(specIndex) {
50 }
51
54 const VdfConnectionVector &GetConnections() const { return _connections; }
55
58 size_t GetNumConnections() const {
59 return _connections.size();
60 }
61
64 const VdfConnection &operator[](size_t index) const {
65 return *_connections[index];
66 }
67
70 VdfConnection &GetNonConstConnection(size_t index) const {
71 return *_connections[index];
72 }
73
76 VDF_API
77 const VdfInputSpec &GetSpec() const;
78
82 const VdfOutput *GetAssociatedOutput() const { return _associatedOutput; }
83
86 const VdfNode &GetNode() const { return _owner; }
87
90 VdfNode &GetNode() { return _owner; }
91
94 const TfToken &GetName() const {
95 return GetSpec().GetName();
96 }
97
100 VDF_API
101 std::string GetDebugName() const;
102
103private:
104
105 // Only the VdfNetwork and VdfIsolatedSubnetwork should have access to the
106 // connect API.
107 friend class VdfNetwork;
108 friend class VdfIsolatedSubnetwork;
109
110 // VdfOutput needs to be able to call _AddConnection().
111 friend class VdfOutput;
112
116 int _GetSpecIndex() const {
117 return _specIndex;
118 }
119
126 VdfConnection *_AddConnection(
127 VdfOutput &output,
128 const VdfMask &mask,
129 int atIndex);
130
132 void _RemoveConnection(VdfConnection *connection);
133
142 void _ReorderInputConnections(
143 const TfSpan<const VdfConnectionVector::size_type> &newToOldIndices);
144
145private:
146
147 // The owner of this input connector.
148 VdfNode &_owner;
149
150 // A pointer to a corresponding output. This is only non-null for in/out
151 // connectors.
152 const VdfOutput *_associatedOutput;
153
154 // The list of connections on this connector.
155 VdfConnectionVector _connections;
156
157 // The index of the connector spec for this input on the owning node.
158 int _specIndex;
159};
160
162
163PXR_NAMESPACE_CLOSE_SCOPE
164
165#endif
size_type size() const
Returns the current size of the vector.
Definition: smallVector.h:596
Represents a range of contiguous elements.
Definition: span.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A class that fully represents a connection between two VdfNodes.
Definition: connection.h:30
A VdfInput is used to connect a VdfNode to one or more VdfNodes' outputs.
Definition: input.h:36
VdfConnection & GetNonConstConnection(size_t index) const
Returns the connection at index, writable.
Definition: input.h:70
size_t GetNumConnections() const
Returns the number of connections for this input.
Definition: input.h:58
VDF_API const VdfInputSpec & GetSpec() const
Returns the spec for this input connector.
const VdfConnection & operator[](size_t index) const
Returns the connection at index.
Definition: input.h:64
const VdfNode & GetNode() const
Returns the owning node for this input connector.
Definition: input.h:86
VdfNode & GetNode()
Returns the non-const owning node for this input connector.
Definition: input.h:90
VDF_API std::string GetDebugName() const
Returns a descriptive name for this input connector.
VDF_API ~VdfInput()
Destructor.
VdfInput(VdfNode &owner, int specIndex, const VdfOutput *output=NULL)
Constructor.
Definition: input.h:48
const TfToken & GetName() const
Returns the name of this input.
Definition: input.h:94
const VdfConnectionVector & GetConnections() const
Returns a list of connections connected to this input.
Definition: input.h:54
const VdfOutput * GetAssociatedOutput() const
Returns the output corresponding to this input.
Definition: input.h:82
A VdfInputSpec describes an input connector.
Definition: inputSpec.h:30
const TfToken & GetName() const
Returns the name of this connector.
Definition: inputSpec.h:68
A VdfIsolatedSubnetwork builds a collection of VdfNodes and VdfConnections that are disconnected from...
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:37
A VdfNetwork is a collection of VdfNodes and their connections.
Definition: network.h:60
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:53
A VdfOutput represents an output on a node.
Definition: output.h:32