Ocean
Ocean::ScopedNonconstMemoryAccessor< 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

 ScopedNonconstMemoryAccessor (NonconstIndexedAccessor< T > &accessor)
 Creates a new scoped accessor object by a given indexed accessor object. More...
 
 ScopedNonconstMemoryAccessor (NonconstIndexedAccessor< T > *accessor, const size_t temporarySize=0)
 Creates a new scoped accessor object by an optional indexed accessor object or creates an internal temporary memory with specified size. More...
 
 ~ScopedNonconstMemoryAccessor ()
 Destructs the scoped accessor object. More...
 
T * data ()
 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...
 
T & operator[] (const size_t index)
 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

NonconstIndexedAccessor< T > * accessor_ = nullptr
 The given accessor object providing the data for this object, nullptr if no accessor object was provided during creation. More...
 
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::ScopedNonconstMemoryAccessor< 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. The connected indexed accessor object will hold the data of this accessor object after this object is disposed.

Constructor & Destructor Documentation

◆ ScopedNonconstMemoryAccessor() [1/2]

template<typename T >
Ocean::ScopedNonconstMemoryAccessor< T >::ScopedNonconstMemoryAccessor ( NonconstIndexedAccessor< T > &  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, the provided accessor needs to exist at least until the scope ends

◆ ScopedNonconstMemoryAccessor() [2/2]

template<typename T >
Ocean::ScopedNonconstMemoryAccessor< T >::ScopedNonconstMemoryAccessor ( NonconstIndexedAccessor< T > *  accessor,
const size_t  temporarySize = 0 
)
inlineexplicit

Creates a new scoped accessor object by an optional indexed accessor object or creates an internal temporary memory with specified size.

Parameters
accessorThe accessor object providing the data for this scoped object, the provided accessor needs to exist at least until the scope ends, nullptr to create an internal temporary memory without connected accessor
temporarySizeThe explicit size of the internal memory if no accessor is provided, does not have any meaning if an accessor is provided

◆ ~ScopedNonconstMemoryAccessor()

Destructs the scoped accessor object.

Further, the intermediate values of this object may be copied back to the accessor object, if necessary.

Member Function Documentation

◆ data()

template<typename T >
T * Ocean::ScopedNonconstMemoryAccessor< 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::ScopedNonconstMemoryAccessor< 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 >
T & Ocean::ScopedNonconstMemoryAccessor< T >::operator[] ( const size_t  index)
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::ScopedNonconstMemoryAccessor< T >::size
inline

Returns the number of elements the accessor provides.

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

Field Documentation

◆ accessor_

template<typename T >
NonconstIndexedAccessor<T>* Ocean::ScopedNonconstMemoryAccessor< T >::accessor_ = nullptr
protected

The given accessor object providing the data for this object, nullptr if no accessor object was provided during creation.

◆ data_

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

The pointer to the memory block of the accessor.

◆ intermediateValues_

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

The individual elements of the accessor, if necessary.

◆ size_

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

The number of elements the accessor provides.


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