Loading...
Searching...
No Matches
output.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_OUTPUT_H
8#define PXR_EXEC_VDF_OUTPUT_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
15#include "pxr/exec/vdf/types.h"
16
17#include <tbb/spin_mutex.h>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class TfToken;
22class VdfInput;
23class VdfMask;
24class VdfOutputSpec;
25
32{
33public:
34
37 VDF_API
38 VdfOutput(VdfNode &owner, int specIndex);
39
42 VDF_API
44
47 const VdfConnectionVector &GetConnections() const { return _connections; }
48
51 size_t GetNumConnections() const {
52 return _connections.size();
53 }
54
57 const VdfNode &GetNode() const { return _owner; }
58
61 VdfNode &GetNode() { return _owner; }
62
65 VDF_API
66 const TfToken &GetName() const;
67
71 VDF_API
72 void SetAssociatedInput(const VdfInput *input);
73
76 const VdfInput *GetAssociatedInput() const {
77 return _associatedInput;
78 }
79
85 const VdfMask *GetAffectsMask() const {
86 return _affectsMask.IsEmpty() ? nullptr : &_affectsMask;
87 }
88
94 VDF_API
95 void SetAffectsMask(const VdfMask &mask);
96
100 VdfId GetId() const {
101 return _id;
102 }
103
109 static VdfIndex GetIndexFromId(const VdfId id) {
110 return static_cast<VdfIndex>(id);
111 }
112
119 return static_cast<VdfVersion>(id >> 32);
120 }
121
124 VDF_API
125 const VdfOutputSpec &GetSpec() const;
126
132 VDF_API
133 std::string GetDebugName() const;
134
141 VDF_API
142 int GetNumDataEntries() const;
143
144private:
145
146 // Only the VdfNetwork and VdfIsolatedSubnetwork should have access to the
147 // connect API.
148 friend class VdfNetwork;
149 friend class VdfIsolatedSubnetwork;
150
151 // Connects \p node's input named \p inputName to this output with a
152 // given \p mask. If \p atIndex is >= 0 the connection will be placed at
153 // index \p atIndex on the target input. Otherwise the connection will
154 // be appended at the end.
155 //
156 VdfConnection *_Connect(VdfNode *node,
157 const TfToken &inputName,
158 const VdfMask &mask,
159 int atIndex);
160
162 void _RemoveConnection(VdfConnection *connection);
163
164private:
165
166 // The node that owns this output.
167 VdfNode &_owner;
168
169 // The output id.
170 const VdfId _id;
171
172 // The input (if any) associated with this output.
173 const VdfInput *_associatedInput;
174
175 // The list of connections connected to this output.
176 VdfConnectionVector _connections;
177
178 // The mask indicating the elements that this output is expected to modify
179 // from its corresponding input. For outputs with no corresponding input,
180 // the mask will be of size 0.
181 VdfMask _affectsMask;
182
183 // The index of the connector spec for this output on the owning node.
184 int _specIndex;
185
186 // Sychronize concurrently connecting to this output.
187 tbb::spin_mutex _connectionsMutex;
188};
189
191
192PXR_NAMESPACE_CLOSE_SCOPE
193
194#endif
size_type size() const
Returns the current size of the vector.
Definition: smallVector.h:596
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
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
bool IsEmpty() const
Returns true if this mask is empty, i.e.
Definition: mask.h:168
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
size_t GetNumConnections() const
Returns the number of connections for this output.
Definition: output.h:51
const VdfNode & GetNode() const
Returns the owning node for this output.
Definition: output.h:57
VDF_API VdfOutput(VdfNode &owner, int specIndex)
Constructor.
VDF_API void SetAssociatedInput(const VdfInput *input)
Sets the input associated with this output.
static VdfIndex GetIndexFromId(const VdfId id)
Get the output index from the output id.
Definition: output.h:109
VdfNode & GetNode()
Returns the non-const owning node for this output.
Definition: output.h:61
VDF_API int GetNumDataEntries() const
Returns the expected number of entries in the data computed at this output.
VDF_API std::string GetDebugName() const
Returns the debug name for this output.
VdfId GetId() const
The unique id of this output.
Definition: output.h:100
VDF_API void SetAffectsMask(const VdfMask &mask)
Sets the affects mask for this output.
VDF_API const VdfOutputSpec & GetSpec() const
Returns the connector specification object for this output.
VDF_API const TfToken & GetName() const
Returns the name of this output.
const VdfInput * GetAssociatedInput() const
Returns the in/out connector associated with this output.
Definition: output.h:76
VDF_API ~VdfOutput()
Destructor.
const VdfMask * GetAffectsMask() const
Returns the mask of elements that this output is expected to modify from its corresponding input.
Definition: output.h:85
static VdfVersion GetVersionFromId(const VdfId id)
Get the output version from the output id.
Definition: output.h:118
const VdfConnectionVector & GetConnections() const
Returns a list of connections connected to this output.
Definition: output.h:47
A VdfOuptutSpec describes an output connector.
Definition: outputSpec.h:40
uint64_t VdfId
The unique identifier type for Vdf objects.
Definition: types.h:107
uint32_t VdfIndex
The index type for Vdf objects.
Definition: types.h:110
uint32_t VdfVersion
The version type for Vdf objects.
Definition: types.h:113