Blender  V3.3
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
blender::VArrayCommon< T > Class Template Reference

#include <BLI_virtual_array.hh>

Inheritance diagram for blender::VArrayCommon< T >:
blender::VArray< float > blender::VArray< int > blender::VArray< blender::vec_base > blender::VArray< T > blender::VMutableArray< T >

Public Member Functions

 operator bool () const
 
T operator[] (const int64_t index) const
 
T get (const int64_t index) const
 
int64_t size () const
 
bool is_empty () const
 
IndexRange index_range () const
 
CommonVArrayInfo common_info () const
 
bool is_span () const
 
Span< Tget_internal_span () const
 
bool is_single () const
 
T get_internal_single () const
 
bool is_same (const VArrayCommon< T > &other) const
 
void materialize (MutableSpan< T > r_span) const
 
void materialize (IndexMask mask, MutableSpan< T > r_span) const
 
void materialize_to_uninitialized (MutableSpan< T > r_span) const
 
void materialize_to_uninitialized (IndexMask mask, MutableSpan< T > r_span) const
 
void materialize_compressed (IndexMask mask, MutableSpan< T > r_span) const
 
void materialize_compressed_to_uninitialized (IndexMask mask, MutableSpan< T > r_span) const
 
bool try_assign_GVArray (GVArray &varray) const
 

Protected Types

using Storage = Any< detail::VArrayAnyExtraInfo< T >, 24, 8 >
 

Protected Member Functions

 VArrayCommon ()=default
 
 VArrayCommon (const VArrayCommon &other)
 
 VArrayCommon (VArrayCommon &&other) noexcept
 
 VArrayCommon (const VArrayImpl< T > *impl)
 
 VArrayCommon (std::shared_ptr< const VArrayImpl< T >> impl)
 
template<typename ImplT , typename... Args>
void emplace (Args &&...args)
 
void copy_from (const VArrayCommon &other)
 
void move_from (VArrayCommon &&other) noexcept
 
const VArrayImpl< T > * impl_from_storage () const
 

Protected Attributes

const VArrayImpl< T > * impl_ = nullptr
 
Storage storage_
 

Detailed Description

template<typename T>
class blender::VArrayCommon< T >

Utility class to reduce code duplication for methods available on #VArray and #VMutableArray. Deriving #VMutableArray from #VArray would have some issues:

Definition at line 589 of file BLI_virtual_array.hh.

Member Typedef Documentation

◆ Storage

template<typename T >
using blender::VArrayCommon< T >::Storage = Any<detail::VArrayAnyExtraInfo<T>, 24, 8>
protected

Store the virtual array implementation in an #Any. This makes it easy to avoid a memory allocation if the implementation is small enough and is copyable. This is the case for the most common virtual arrays. Other virtual array implementations are typically stored as #std::shared_ptr. That works even when the implementation itself is not copyable and makes copying VArrayCommon cheaper.

Definition at line 598 of file BLI_virtual_array.hh.

Constructor & Destructor Documentation

◆ VArrayCommon() [1/5]

template<typename T >
blender::VArrayCommon< T >::VArrayCommon ( )
protecteddefault

◆ VArrayCommon() [2/5]

template<typename T >
blender::VArrayCommon< T >::VArrayCommon ( const VArrayCommon< T > &  other)
inlineprotected

Copy constructor.

Definition at line 617 of file BLI_virtual_array.hh.

◆ VArrayCommon() [3/5]

template<typename T >
blender::VArrayCommon< T >::VArrayCommon ( VArrayCommon< T > &&  other)
inlineprotectednoexcept

Move constructor.

Definition at line 623 of file BLI_virtual_array.hh.

◆ VArrayCommon() [4/5]

template<typename T >
blender::VArrayCommon< T >::VArrayCommon ( const VArrayImpl< T > *  impl)
inlineprotected

Wrap an existing #VArrayImpl and don't take ownership of it. This should rarely be used in practice.

Definition at line 634 of file BLI_virtual_array.hh.

◆ VArrayCommon() [5/5]

template<typename T >
blender::VArrayCommon< T >::VArrayCommon ( std::shared_ptr< const VArrayImpl< T >>  impl)
inlineprotected

Wrap an existing #VArrayImpl that is contained in a #std::shared_ptr. This takes ownership.

Definition at line 642 of file BLI_virtual_array.hh.

References impl.

Member Function Documentation

◆ common_info()

template<typename T >
CommonVArrayInfo blender::VArrayCommon< T >::common_info ( ) const
inline

◆ copy_from()

template<typename T >
void blender::VArrayCommon< T >::copy_from ( const VArrayCommon< T > &  other)
inlineprotected

Utility to implement a copy assignment operator in a subclass.

Definition at line 672 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::storage_.

Referenced by blender::VMutableArray< T >::operator VArray< T >(), blender::VArray< T >::operator=(), and blender::VMutableArray< T >::operator=().

◆ emplace()

template<typename T >
template<typename ImplT , typename... Args>
void blender::VArrayCommon< T >::emplace ( Args &&...  args)
inlineprotected

Replace the contained #VArrayImpl.

Definition at line 652 of file BLI_virtual_array.hh.

References ptr.

◆ get()

template<typename T >
T blender::VArrayCommon< T >::get ( const int64_t  index) const
inline

Same as the operator[] but is sometimes easier to use when one has a pointer to a virtual array.

Definition at line 727 of file BLI_virtual_array.hh.

Referenced by blender::fn::tests::TEST(), and blender::tests::TEST().

◆ get_internal_single()

template<typename T >
T blender::VArrayCommon< T >::get_internal_single ( ) const
inline

◆ get_internal_span()

template<typename T >
Span<T> blender::VArrayCommon< T >::get_internal_span ( ) const
inline

◆ impl_from_storage()

template<typename T >
const VArrayImpl<T>* blender::VArrayCommon< T >::impl_from_storage ( ) const
inlineprotected

◆ index_range()

template<typename T >
IndexRange blender::VArrayCommon< T >::index_range ( ) const
inline

◆ is_empty()

template<typename T >
bool blender::VArrayCommon< T >::is_empty ( ) const
inline

◆ is_same()

template<typename T >
bool blender::VArrayCommon< T >::is_same ( const VArrayCommon< T > &  other) const
inline

Return true when the other virtual references the same underlying memory.

Definition at line 802 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::impl_, and blender::VArrayImpl< T >::is_same().

Referenced by blender::nodes::node_geo_set_position_cc::set_computed_position_and_offset().

◆ is_single()

template<typename T >
bool blender::VArrayCommon< T >::is_single ( ) const
inline

◆ is_span()

template<typename T >
bool blender::VArrayCommon< T >::is_span ( ) const
inline

◆ materialize() [1/2]

template<typename T >
void blender::VArrayCommon< T >::materialize ( IndexMask  mask,
MutableSpan< T r_span 
) const
inline

Copy some indices of the virtual array into a span.

Definition at line 825 of file BLI_virtual_array.hh.

References BLI_assert, mask(), and blender::VArrayImpl< T >::materialize().

◆ materialize() [2/2]

template<typename T >
void blender::VArrayCommon< T >::materialize ( MutableSpan< T r_span) const
inline

◆ materialize_compressed()

template<typename T >
void blender::VArrayCommon< T >::materialize_compressed ( IndexMask  mask,
MutableSpan< T r_span 
) const
inline

◆ materialize_compressed_to_uninitialized()

template<typename T >
void blender::VArrayCommon< T >::materialize_compressed_to_uninitialized ( IndexMask  mask,
MutableSpan< T r_span 
) const
inline

◆ materialize_to_uninitialized() [1/2]

template<typename T >
void blender::VArrayCommon< T >::materialize_to_uninitialized ( IndexMask  mask,
MutableSpan< T r_span 
) const
inline

◆ materialize_to_uninitialized() [2/2]

template<typename T >
void blender::VArrayCommon< T >::materialize_to_uninitialized ( MutableSpan< T r_span) const
inline

◆ move_from()

template<typename T >
void blender::VArrayCommon< T >::move_from ( VArrayCommon< T > &&  other)
inlineprotectednoexcept

Utility to implement a move assignment operator in a subclass.

Definition at line 682 of file BLI_virtual_array.hh.

Referenced by blender::VMutableArray< T >::operator VArray< T >(), blender::VArray< T >::operator=(), and blender::VMutableArray< T >::operator=().

◆ operator bool()

template<typename T >
blender::VArrayCommon< T >::operator bool ( ) const
inline

Return false when there is no virtual array implementation currently.

Definition at line 705 of file BLI_virtual_array.hh.

◆ operator[]()

template<typename T >
T blender::VArrayCommon< T >::operator[] ( const int64_t  index) const
inline

Get the element at a specific index.

Note
This can't return a reference because the value may be computed on the fly. This also implies that one can not use this method for assignments.

Definition at line 715 of file BLI_virtual_array.hh.

References BLI_assert, blender::VArrayImpl< T >::get(), and size().

◆ size()

template<typename T >
int64_t blender::VArrayCommon< T >::size ( ) const
inline

◆ try_assign_GVArray()

template<typename T >
bool blender::VArrayCommon< T >::try_assign_GVArray ( GVArray varray) const
inline

See #GVArrayImpl::try_assign_GVArray.

Definition at line 854 of file BLI_virtual_array.hh.

References blender::VArrayImpl< T >::try_assign_GVArray().

Referenced by blender::GVArray::GVArray().

Member Data Documentation

◆ impl_

template<typename T >
const VArrayImpl<T>* blender::VArrayCommon< T >::impl_ = nullptr
protected

Pointer to the currently contained virtual array implementation. This is allowed to be null.

Definition at line 603 of file BLI_virtual_array.hh.

Referenced by blender::VArrayCommon< T >::is_same().

◆ storage_

template<typename T >
Storage blender::VArrayCommon< T >::storage_
protected

Does the memory management for the virtual array implementation. It contains one of the following:

  • Inlined subclass of #VArrayImpl.
  • Non-owning pointer to a #VArrayImpl.
  • Shared pointer to a #VArrayImpl.

Definition at line 611 of file BLI_virtual_array.hh.

Referenced by blender::VArrayCommon< T >::copy_from().


The documentation for this class was generated from the following file: