Loading...
Searching...
No Matches
maskedOutput.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_MASKED_OUTPUT_H
8#define PXR_EXEC_VDF_MASKED_OUTPUT_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
15#include "pxr/exec/vdf/mask.h"
16
17#include <string>
18#include <utility>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class VdfOutput;
23
32{
33public :
34
36 _output(nullptr) {}
37
38 VdfMaskedOutput(VdfOutput *output, const VdfMask &mask) :
39 _output(output), _mask(mask) {}
40
41 VdfMaskedOutput(VdfOutput *output, VdfMask &&mask) :
42 _output(output), _mask(std::move(mask)) {}
43
46 explicit operator bool() const {
47 return static_cast<bool>(_output);
48 }
49
53 return _output;
54 }
55
58 void SetOutput(VdfOutput *output) {
59 _output = output;
60 }
61
64 const VdfMask &GetMask() const {
65 return _mask;
66 }
67
70 void SetMask(const VdfMask &mask) {
71 _mask = mask;
72 }
73
76 void SetMask(VdfMask &&mask) {
77 _mask = std::move(mask);
78 }
79
82 bool operator==(const VdfMaskedOutput &rhs) const {
83 return _output == rhs._output &&
84 _mask == rhs._mask;
85 }
86
87 bool operator!=(const VdfMaskedOutput &rhs) const {
88 return !(*this == rhs);
89 }
90
91 struct Hash
92 {
93 size_t operator()(const VdfMaskedOutput &maskedOutput) const
94 {
95 // Note: maskedOutput.GetMask() is a flyweight.
96 return (size_t)maskedOutput.GetOutput() +
97 maskedOutput.GetMask().GetHash();
98 }
99 };
100
101 bool operator<(const VdfMaskedOutput &rhs) const {
102 std::less<const VdfOutput *> outputLT;
103 if (outputLT(_output, rhs._output))
104 return true;
105
106 if (outputLT(rhs._output, _output))
107 return false;
108
109 return VdfMask::ArbitraryLessThan()(_mask, rhs._mask);
110 }
111
112 bool operator<=(const VdfMaskedOutput &rhs) const {
113 return !(rhs < *this);
114 }
115
116 bool operator>(const VdfMaskedOutput &rhs) const {
117 return rhs < *this;
118 }
119
120 bool operator>=(const VdfMaskedOutput &rhs) const {
121 return !(*this < rhs);
122 }
123
124 friend inline void swap(VdfMaskedOutput &lhs, VdfMaskedOutput &rhs) {
125 using std::swap;
126 swap(lhs._output, rhs._output);
127 swap(lhs._mask, rhs._mask);
128 }
129
132 VDF_API
133 std::string GetDebugName() const;
134
135// -----------------------------------------------------------------------------
136
137private :
138
139 VdfOutput *_output;
140 VdfMask _mask;
141};
142
143PXR_NAMESPACE_CLOSE_SCOPE
144
145#endif
A VdfMask is placed on connections to specify the data flowing through them.
Definition: mask.h:37
size_t GetHash() const
Returns a hash for the mask.
Definition: mask.h:565
Class to hold on to an externally owned output and a mask.
Definition: maskedOutput.h:32
void SetOutput(VdfOutput *output)
Sets the output to output.
Definition: maskedOutput.h:58
VDF_API std::string GetDebugName() const
Returns a string describing this masked output.
VdfOutput * GetOutput() const
Returns the VdfOutput.
Definition: maskedOutput.h:52
const VdfMask & GetMask() const
Returns the VdfMask.
Definition: maskedOutput.h:64
bool operator==(const VdfMaskedOutput &rhs) const
Equality comparison.
Definition: maskedOutput.h:82
void SetMask(const VdfMask &mask)
Sets the mask to mask.
Definition: maskedOutput.h:70
void SetMask(VdfMask &&mask)
Sets the mask to mask.
Definition: maskedOutput.h:76
A VdfOutput represents an output on a node.
Definition: output.h:32
Arbitrary total ordering of masks.
Definition: mask.h:283