Loading...
Searching...
No Matches
vectorSubrangeAccessor.h
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_VECTOR_SUBRANGE_ACCESSOR_H
8#define PXR_EXEC_VDF_VECTOR_SUBRANGE_ACCESSOR_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/exec/vdf/api.h"
13#include "pxr/exec/vdf/boxedContainer.h"
14#include "pxr/exec/vdf/vectorData.h"
15
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20template <typename T> class VdfIteratorRange;
21template <typename T> class VdfReadIterator;
22template <typename T> class VdfSubrangeView;
23
24// Post a TF_FATAL_ERROR on behalf of Vdf_VectorSubrangeAccessor when a
25// type-mismatch is detected.
26[[noreturn]]
27VDF_API
28void
29Vdf_VectorSubrangeAccessorPostFatalError(
30 const std::type_info &haveType,
31 const std::type_info &wantType);
32
41template <typename T>
43{
44public:
48 Vdf_VectorData *data,
49 const Vdf_VectorData::Info &info)
50 : _boxedRanges(nullptr)
51 {
52 const std::type_info &haveType = data->GetTypeInfo();
53 const std::type_info &wantType = typeid(T);
54 if (ARCH_UNLIKELY(!TfSafeTypeCompare(haveType, wantType))) {
55 Vdf_VectorSubrangeAccessorPostFatalError(haveType, wantType);
56 }
57
58 if (info.layout == Vdf_VectorData::Info::Layout::Boxed) {
59 const Vdf_BoxedContainer<T> *boxedContainer =
60 static_cast<const Vdf_BoxedContainer<T>*>(info.data);
61 _boxedRanges = &boxedContainer->GetRanges();
62 }
63 }
64
65private:
67
70 bool IsBoxed() const {
71 return _boxedRanges;
72 }
73
79 const Vdf_BoxedRanges &GetBoxedRanges() const {
80 return *_boxedRanges;
81 }
82
83private:
84 const Vdf_BoxedRanges *_boxedRanges;
85};
86
87PXR_NAMESPACE_CLOSE_SCOPE
88
89#endif
This simple container stores multiple values that flow through the network as a single data flow elem...
const Vdf_BoxedRanges & GetRanges() const
Returns the subranges of boxed data.
Each range represents a logical group of elements stored in a Vdf_BoxedContainer.
Abstract base class for storing data in a VdfVector.
Definition: vectorData.h:27
Specialized vector accessor for read access to boxed containers.
Vdf_VectorSubrangeAccessor(Vdf_VectorData *data, const Vdf_VectorData::Info &info)
Constructor.
This class allows for construction of iterable ranges.
Definition: iteratorRange.h:27
An iterator that provides read access to input values using a context.
Definition: readIterator.h:39
This class enables iteration over subranges of input values, where each subrange contains values orig...
Definition: subrangeView.h:28
Safely compare C++ RTTI type structures.
bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)
Safely compare std::type_info structures.