Ocean
Ocean::ConstAccessor< T, TKey > Class Template Referenceabstract

This class implements a base class for accessors allowing a constant reference access. More...

Inheritance diagram for Ocean::ConstAccessor< T, TKey >:

Public Types

typedef T Type
 Definition of the element type of this accessor. More...
 
typedef TKey KeyType
 Definition of the key (or e.g., index) type of this accessor. More...
 

Public Member Functions

virtual const T * data () const
 Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps. More...
 
virtual bool canAccess (const TKey &key) const =0
 Returns whether this accessor has a specific element. More...
 
virtual bool firstElement (T &element, TKey &key) const =0
 Returns the first element of this accessor. More...
 
virtual bool nextElement (const TKey &previousKey, T &nextElement, TKey &nextKey) const =0
 Returns the next element which follows a given key of the previous element. More...
 
virtual const T & operator[] (const TKey &key) const =0
 Returns one element of this accessor object by a given key. More...
 
- Public Member Functions inherited from Ocean::Accessor
virtual ~Accessor ()=default
 Default destructor. More...
 
virtual size_t size () const =0
 Returns the number of accessible elements of this accessor object. More...
 
bool isEmpty () const
 Returns whether this accessor provides no elements. More...
 

Protected Member Functions

 ConstAccessor ()=default
 Protected default constructor. More...
 
- Protected Member Functions inherited from Ocean::Accessor
 Accessor ()=default
 Protected default constructor. More...
 
 Accessor (const Accessor &accessor)=default
 Protected copy constructor. More...
 
Accessoroperator= (const Accessor &accessor)=delete
 Deleted assign operator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::Accessor
template<typename TAccessor >
static std::vector< typename TAccessor::Type > accessor2elements (const TAccessor &accessor)
 Returns all elements of a given accessor (as a block). More...
 
template<typename TAccessor >
static std::unordered_map< typename TAccessor::KeyType, typename TAccessor::Type > accessor2map (const TAccessor &accessor)
 Returns all elements of a given accessor as a map with key and elements. More...
 
template<typename TAccessor , typename TIndex >
static std::vector< typename TAccessor::Type > accessor2subsetElements (const TAccessor &accessor, const std::vector< TIndex > &subset)
 Returns a subset of all elements of a given accessor (as a block). More...
 

Detailed Description

template<typename T, typename TKey>
class Ocean::ConstAccessor< T, TKey >

This class implements a base class for accessors allowing a constant reference access.

Template Parameters
TThe data type of the elements of the accessor
TKeyThe data type of the keys of the accessor

Member Typedef Documentation

◆ KeyType

template<typename T , typename TKey >
typedef TKey Ocean::ConstAccessor< T, TKey >::KeyType

Definition of the key (or e.g., index) type of this accessor.

◆ Type

template<typename T , typename TKey >
typedef T Ocean::ConstAccessor< T, TKey >::Type

Definition of the element type of this accessor.

Constructor & Destructor Documentation

◆ ConstAccessor()

template<typename T , typename TKey >
Ocean::ConstAccessor< T, TKey >::ConstAccessor ( )
protecteddefault

Protected default constructor.

Member Function Documentation

◆ canAccess()

template<typename T , typename TKey >
virtual bool Ocean::ConstAccessor< T, TKey >::canAccess ( const TKey &  key) const
pure virtual

Returns whether this accessor has a specific element.

Parameters
keyThe key of the element to be checked
Returns
True, if the element exists

Implemented in Ocean::NonconstMapAccessor< T, TKey >, Ocean::ConstMapAccessor< T, TKey >, Ocean::NonconstIndexedAccessor< T >, and Ocean::ConstIndexedAccessor< T >.

◆ data()

template<typename T , typename TKey >
const T * Ocean::ConstAccessor< T, TKey >::data
virtual

Returns a pointer to the elements of this accessor if the data exists within one memory block without gaps.

Beware: There is not guarantee that the data of an accessor is stored as one memory block, thus be prepared that the resulting pointer is nullptr.

Returns
The pointer to the memory block of this accessor, if available

Reimplemented in Ocean::ConstArrayAccessor< T >.

◆ firstElement()

template<typename T , typename TKey >
virtual bool Ocean::ConstAccessor< T, TKey >::firstElement ( T &  element,
TKey &  key 
) const
pure virtual

Returns the first element of this accessor.

Parameters
elementThe resulting first element by copying the element (by using the assign operator)
keyThe resulting key of the first element
Returns
True, if at least one element exists

Implemented in Ocean::NonconstMapAccessor< T, TKey >, Ocean::ConstMapAccessor< T, TKey >, Ocean::NonconstIndexedAccessor< T >, and Ocean::ConstIndexedAccessor< T >.

◆ nextElement()

template<typename T , typename TKey >
virtual bool Ocean::ConstAccessor< T, TKey >::nextElement ( const TKey &  previousKey,
T &  nextElement,
TKey &  nextKey 
) const
pure virtual

Returns the next element which follows a given key of the previous element.

Parameters
previousKeyThe previous key for which the next following element is requested
nextElementThe resulting next element by copying the element (by using the assign operator)
nextKeyThe resulting key of the next element
Returns
True, if a next element exists

Implemented in Ocean::NonconstMapAccessor< T, TKey >, Ocean::ConstMapAccessor< T, TKey >, Ocean::NonconstIndexedAccessor< T >, and Ocean::ConstIndexedAccessor< T >.

◆ operator[]()

template<typename T , typename TKey >
virtual const T& Ocean::ConstAccessor< T, TKey >::operator[] ( const TKey &  key) const
pure virtual

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