Changeset View
Changeset View
Standalone View
Standalone View
source/blender/functions/FN_generic_virtual_array.hh
| Show All 21 Lines | |||||
| * A generic virtual array is the same as a virtual array from blenlib, except for the fact that | * A generic virtual array is the same as a virtual array from blenlib, except for the fact that | ||||
| * the data type is only known at runtime. | * the data type is only known at runtime. | ||||
| */ | */ | ||||
| #include <optional> | #include <optional> | ||||
| #include "BLI_virtual_array.hh" | #include "BLI_virtual_array.hh" | ||||
| #include "FN_generic_array.hh" | |||||
| #include "FN_generic_span.hh" | #include "FN_generic_span.hh" | ||||
| namespace blender::fn { | namespace blender::fn { | ||||
| template<typename T> class GVArray_Typed; | template<typename T> class GVArray_Typed; | ||||
| template<typename T> class GVMutableArray_Typed; | template<typename T> class GVMutableArray_Typed; | ||||
| class GVArray; | class GVArray; | ||||
| ▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | protected: | ||||
| } | } | ||||
| const void *try_get_internal_varray_impl() const override | const void *try_get_internal_varray_impl() const override | ||||
| { | { | ||||
| return varray_; | return varray_; | ||||
| } | } | ||||
| }; | }; | ||||
| class GVArray_For_GArray : public GVArray_For_GSpan { | |||||
| protected: | |||||
| GArray<> array_; | |||||
| public: | |||||
| GVArray_For_GArray(GArray<> array) : GVArray_For_GSpan(array.as_span()), array_(std::move(array)) | |||||
| { | |||||
| } | |||||
JacquesLucke: This constructor still has to set `data_`. | |||||
Done Inline ActionsEek, thanks! The GSpan constructor seems to work better here anyway. HooglyBoogly: Eek, thanks! The `GSpan` constructor seems to work better here anyway. | |||||
Done Inline ActionsRight. Note, if GArray would support small-object-optimization, then the GSpan constructor could not be used. JacquesLucke: Right. Note, if `GArray` would support small-object-optimization, then the `GSpan` constructor… | |||||
| }; | |||||
| /* Used to convert any generic virtual array into a typed one. */ | /* Used to convert any generic virtual array into a typed one. */ | ||||
| template<typename T> class VArray_For_GVArray : public VArray<T> { | template<typename T> class VArray_For_GVArray : public VArray<T> { | ||||
| protected: | protected: | ||||
| const GVArray *varray_ = nullptr; | const GVArray *varray_ = nullptr; | ||||
| public: | public: | ||||
| VArray_For_GVArray(const GVArray &varray) : VArray<T>(varray.size()), varray_(&varray) | VArray_For_GVArray(const GVArray &varray) : VArray<T>(varray.size()), varray_(&varray) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 552 Lines • Show Last 20 Lines | |||||
This constructor still has to set data_.