Ocean
Ocean::ScopedConstMemoryAccessor< T > Class Template Reference

This class implements an accessor that guarantees memory access to the elements of an indexed accessor object until the scope ends. More...

Public Member Functions

template<typename TAccessor >
 ScopedConstMemoryAccessor (const TAccessor &accessor)
 Creates a new scoped accessor object by a given indexed accessor object. More...
 
const T * data () const
 Returns the pointer to the memory block providing the data of the accessor. More...
 
size_t size () const
 Returns the number of elements the accessor provides. More...
 
const T & operator[] (const size_t index) const
 Returns one element of this accessor. More...
 
 operator bool () const
 Returns whether this object provides access to at least one element of the accessor. More...
 

Protected Attributes

const T * data_ = nullptr
 The pointer to the memory block of the accessor. More...
 
size_t size_ = 0
 The number of elements the accessor provides. More...
 
std::vector< T > intermediateValues_
 The individual elements of the accessor, if necessary. More...
 

Detailed Description

template<typename T>
class Ocean::ScopedConstMemoryAccessor< T >

This class implements an accessor that guarantees memory access to the elements of an indexed accessor object until the scope ends.

The memory access ensures that the entire data of the indexed accessor objects is provided as one memory block without any gaps.
Beware: The data of the given indexed accessor may be copied (if necessary) to ensure the functionality.
Thus, the accessible elements of this object may be clones/copies of the actual provided accessor object.

Constructor & Destructor Documentation

◆ ScopedConstMemoryAccessor()

template<typename T >
template<typename TAccessor >
Ocean::ScopedConstMemoryAccessor< T >::ScopedConstMemoryAccessor ( const TAccessor &  accessor)
inlineexplicit

Creates a new scoped accessor object by a given indexed accessor object.

Parameters
accessorThe accessor object providing the data for this scoped object, ensure that the provided accessor exists at least until the scope ends
Template Parameters
TAccessorThe data type of the accessor providing the data, must be of type ConstIndexedAccessor<T>, or ConstTemplateArrayAccessor<T, size_t> or ConstTemplateArraySubsetAccessor<T, size_t>

Member Function Documentation

◆ data()

template<typename T >
const T * Ocean::ScopedConstMemoryAccessor< T >::data
inline

Returns the pointer to the memory block providing the data of the accessor.

Returns
The memory block's pointer, nullptr if the accessor does not provide any data

◆ operator bool()

template<typename T >
Ocean::ScopedConstMemoryAccessor< T >::operator bool
inlineexplicit

Returns whether this object provides access to at least one element of the accessor.

Returns
True, if so

◆ operator[]()

template<typename T >
const T & Ocean::ScopedConstMemoryAccessor< T >::operator[] ( const size_t  index) const
inline

Returns one element of this accessor.

Parameters
indexThe index of the element, with range [0, size())
Returns
The requested element

◆ size()

template<typename T >
size_t Ocean::ScopedConstMemoryAccessor< T >::size
inline

Returns the number of elements the accessor provides.

Returns
The accessor's number of elements, with range [0, infinity)

Field Documentation

◆ data_

template<typename T >
const T* Ocean::ScopedConstMemoryAccessor< T >::data_ = nullptr
protected

The pointer to the memory block of the accessor.

◆ intermediateValues_

template<typename T >
std::vector<T> Ocean::ScopedConstMemoryAccessor< T >::intermediateValues_
protected

The individual elements of the accessor, if necessary.

◆ size_

template<typename T >
size_t Ocean::ScopedConstMemoryAccessor< T >::size_ = 0
protected

The number of elements the accessor provides.


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