8#ifndef META_OCEAN_BASE_ACCESSOR_H
9#define META_OCEAN_BASE_ACCESSOR_H
35 virtual size_t size()
const = 0;
48 template <
typename TAccessor>
49 static std::vector<typename TAccessor::Type>
accessor2elements(
const TAccessor& accessor);
56 template <
typename TAccessor>
57 static std::unordered_map<typename TAccessor::KeyType, typename TAccessor::Type>
accessor2map(
const TAccessor& accessor);
65 template <
typename TAccessor,
typename TIndex>
66 static std::vector<typename TAccessor::Type>
accessor2subsetElements(
const TAccessor& accessor,
const std::vector<TIndex>& subset);
95template <
typename T,
typename TKey>
164template <
typename T,
typename TKey>
200template <
typename T,
typename TKey>
291 virtual bool canAccess(
const size_t& index)
const;
297 virtual bool firstElement(T& element,
size_t& index)
const;
356 virtual bool canAccess(
const size_t& index)
const;
433 virtual const T*
data()
const;
439 virtual size_t size()
const;
445 virtual const T&
operator[](
const size_t& index)
const;
542 virtual size_t size()
const;
548 virtual const T*
const &
operator[](
const size_t& index)
const;
645 inline const T*
data()
const;
651 inline size_t size()
const;
663 inline bool canAccess(
const size_t& index)
const;
669 inline bool firstElement(T& element,
size_t& index)
const;
681 inline const T&
operator[](
const size_t& index)
const;
764 virtual size_t size()
const;
770 virtual const T&
operator[](
const size_t& index)
const;
868 inline const T*
data()
const;
880 inline size_t size()
const;
892 inline bool canAccess(
const size_t& index)
const;
898 inline bool firstElement(T& element,
size_t& index)
const;
910 inline const T&
operator[](
const size_t& index)
const;
968 virtual size_t size()
const;
974 virtual const T&
operator[](
const size_t& index)
const;
999template <
typename T,
typename TKey>
1020 explicit inline ConstMapAccessor(
const std::unordered_map<TKey, T>& elements);
1026 virtual size_t size()
const;
1032 virtual bool canAccess(
const TKey& key)
const;
1038 virtual bool firstElement(T& element, TKey& key)
const;
1050 virtual const T&
operator[](
const TKey& key)
const;
1072template <
typename T,
typename TKey>
1093 virtual size_t size()
const;
1099 virtual bool canAccess(
const TKey& key)
const;
1105 virtual bool firstElement(T& element, TKey& key)
const;
1117 virtual const T&
operator[](
const TKey& key)
const;
1139template <
typename T,
typename TIndex>
1191 virtual size_t size()
const;
1197 virtual const T&
operator[](
const size_t& index)
const;
1229template <
typename T,
typename TIndex>
1291 inline const T*
data()
const;
1297 inline size_t size()
const;
1309 inline bool canAccess(
const size_t& index)
const;
1315 inline bool firstElement(T& element,
size_t& index)
const;
1327 inline const T&
operator[](
const size_t& index)
const;
1354template <
typename T,
typename TIndex>
1378 virtual size_t size()
const;
1385 virtual const T&
operator[](
const size_t& index)
const;
1404template <
typename T>
1434 virtual const T&
operator[](
const size_t& index)
const;
1440 virtual size_t size()
const;
1457template <
typename T>
1467 template <
typename TAccessor>
1474 inline const T*
data()
const;
1480 inline size_t size()
const;
1487 inline const T&
operator[](
const size_t index)
const;
1493 explicit inline operator bool()
const;
1514template <
typename T>
1548 inline size_t size()
const;
1561 explicit inline operator bool()
const;
1583template <
typename TAccessor>
1586 std::vector<typename TAccessor::Type> result;
1587 result.reserve(accessor.size());
1589 for (
size_t n = 0; n < accessor.size(); ++n)
1591 result.emplace_back(accessor[n]);
1597template <
typename TAccessor>
1600 std::unordered_map<typename TAccessor::KeyType, typename TAccessor::Type> result;
1602 typename TAccessor::Type element;
1603 typename TAccessor::KeyType key;
1605 if (accessor.firstElement(element, key))
1607 result[key] = element;
1609 typename TAccessor::KeyType nextKey;
1611 while (accessor.nextElement(key, element, nextKey))
1614 result[key] = element;
1621template <
typename TAccessor,
typename TIndex>
1624 std::vector<typename TAccessor::Type> result;
1625 result.reserve(subset.size());
1627 for (
size_t n = 0; n < subset.size(); ++n)
1629 result.emplace_back(accessor[subset[n]]);
1635template <
typename T,
typename TKey>
1641template <
typename T,
typename TKey>
1647template <
typename T>
1650 return index < this->
size();
1653template <
typename T>
1656 if (this->
size() == 0)
1661 element = (*this)[0];
1667template <
typename T>
1670 if (previousIndex + 1 < this->
size())
1672 nextIndex = previousIndex + 1;
1673 element = (*this)[nextIndex];
1681template <
typename T>
1684 return index < this->
size();
1687template <
typename T>
1690 if (this->
size() == 0)
1695 element = (*this)[0];
1700template <
typename T>
1703 if (previousIndex + 1 < this->
size())
1705 nextIndex = previousIndex + 1;
1713template <
typename T>
1726template <
typename T>
1729 return index < this->
size();
1732template <
typename T,
typename TIndex>
1741template <
typename T,
typename TIndex>
1750template <
typename T,
typename TIndex>
1756template <
typename T,
typename TIndex>
1764template <
typename T>
1767 *
this = std::move(accessor);
1770template <
typename T>
1778template <
typename T>
1786template <
typename T>
1792template <
typename T>
1798template <
typename T>
1801 ocean_assert(index <
size_);
1807template <
typename T>
1810 if (
this != &accessor)
1813 size_ = accessor.size_;
1815 accessor.elements_ =
nullptr;
1822template <
typename T>
1826 for (
size_t n = 0; n <
size; ++n)
1832template <
typename T>
1836 for (
size_t n = 0; n < elements.size(); ++n)
1842template <
typename T>
1848template <
typename T>
1856template <
typename T>
1859 *
this = std::move(accessor);
1862template <
typename T>
1870template <
typename T>
1878template <
typename T>
1884template <
typename T>
1890template <
typename T>
1896template <
typename T>
1899 return index <
size_;
1902template <
typename T>
1915template <
typename T>
1918 if (previousIndex + 1 >=
size_)
1923 nextIndex = previousIndex + 1;
1928template <
typename T>
1931 ocean_assert(index <
size_);
1935template <
typename T>
1938 if (
this != &accessor)
1941 size_ = accessor.size_;
1943 accessor.elements_ =
nullptr;
1950template <
typename T>
1953 *
this = std::move(accessor);
1956template <
typename T>
1964template <
typename T>
1972template <
typename T>
1977 if (resizeSize != 0)
1979 elements.resize(resizeSize);
1983 size_ = elements.size();
1986template <
typename T>
1993 if (resizeSize != 0)
1995 elements->resize(resizeSize);
1999 size_ = elements->size();
2003template <
typename T>
2006 ocean_assert(index <
size_);
2012template <
typename T>
2015 ocean_assert(index <
size_);
2021template <
typename T>
2027template <
typename T>
2033template <
typename T>
2036 if (
this != &accessor)
2039 size_ = accessor.size_;
2041 accessor.elements_ =
nullptr;
2048template <
typename T>
2051 *
this = std::move(accessor);
2054template <
typename T>
2062template <
typename T>
2070template <
typename T>
2075 if (resizeSize != 0)
2077 elements.resize(resizeSize);
2081 size_ = elements.size();
2084template <
typename T>
2091 if (resizeSize != 0)
2093 elements->resize(resizeSize);
2097 size_ = elements->size();
2101template <
typename T>
2107template <
typename T>
2113template <
typename T>
2119template <
typename T>
2125template <
typename T>
2128 return index <
size_;
2131template <
typename T>
2144template <
typename T>
2147 if (previousIndex + 1 >=
size_)
2152 nextIndex = previousIndex + 1;
2157template <
typename T>
2160 ocean_assert(index <
size_);
2164template <
typename T>
2167 ocean_assert(index <
size_);
2171template <
typename T>
2174 if (
this != &accessor)
2177 size_ = accessor.size_;
2179 accessor.elements_ =
nullptr;
2186template <
typename T>
2189 *
this = std::move(accessor);
2192template <
typename T>
2197 ocean_assert(
size_ != 0);
2201template <
typename T>
2207template <
typename T>
2210 ocean_assert_and_suppress_unused(index <
size_, index);
2216template <
typename T>
2219 if (
this != &accessor)
2222 size_ = accessor.size_;
2224 accessor.element_ =
nullptr;
2231template <
typename T,
typename TKey>
2234 *
this = std::move(accessor);
2237template <
typename T,
typename TKey>
2244template <
typename T,
typename TKey>
2250template <
typename T,
typename TKey>
2261template <
typename T,
typename TKey>
2275template <
typename T,
typename TKey>
2283 typename std::unordered_map<TKey, T>::const_iterator i =
elementMap_->find(previousKey);
2290 element = i->second;
2295template <
typename T,
typename TKey>
2304template <
typename T,
typename TKey>
2307 if (
this != &accessor)
2310 accessor.elementMap_ =
nullptr;
2316template <
typename T,
typename TKey>
2323template <
typename T,
typename TKey>
2334template <
typename T,
typename TKey>
2348template <
typename T,
typename TKey>
2356 typename std::unordered_map<TKey, T>::const_iterator i =
elementMap_->find(previousKey);
2363 element = i->second;
2368template <
typename T,
typename TKey>
2374template <
typename T,
typename TKey>
2383template <
typename T,
typename TKey>
2392template <
typename T,
typename TIndex>
2395 *
this = std::move(accessor);
2398template <
typename T,
typename TIndex>
2407template <
typename T,
typename TIndex>
2416template <
typename T,
typename TIndex>
2423 ocean_assert(subsetIndices.size() <= elements.size());
2424 for (
size_t n = 0; n < subsetIndices.size(); ++n)
2426 ocean_assert(subsetIndices[n] < elements.size());
2431template <
typename T,
typename TIndex>
2437template <
typename T,
typename TIndex>
2446template <
typename T,
typename TIndex>
2449 if (
this != &accessor)
2455 accessor.elements_ =
nullptr;
2456 accessor.subsetIndices_ =
nullptr;
2457 accessor.subsetSize_ = 0;
2463template <
typename T,
typename TIndex>
2466 *
this = std::move(accessor);
2469template <
typename T,
typename TIndex>
2478template <
typename T,
typename TIndex>
2487template <
typename T,
typename TIndex>
2494 ocean_assert(subsetIndices.size() <= elements.size());
2495 for (
size_t n = 0; n < subsetIndices.size(); ++n)
2497 ocean_assert(subsetIndices[n] < elements.size());
2502template <
typename T,
typename TIndex>
2508template <
typename T,
typename TIndex>
2514template <
typename T,
typename TIndex>
2520template <
typename T,
typename TIndex>
2526template <
typename T,
typename TIndex>
2534 element = (*this)[0];
2540template <
typename T,
typename TIndex>
2548 nextIndex = previousIndex + 1;
2554template <
typename T,
typename TIndex>
2562template <
typename T,
typename TIndex>
2565 if (
this != &accessor)
2571 accessor.elements_ =
nullptr;
2572 accessor.subsetIndices_ =
nullptr;
2573 accessor.subsetSize_ = 0;
2579template <
typename T>
2587template <
typename T>
2590 ocean_assert(index <
size_);
2596template <
typename T>
2602template <
typename T>
2603template <
typename TAccessor>
2608 data_ = accessor.data();
2609 size_ = accessor.size();
2615 for (
size_t n = 0; n <
size_; ++n)
2624template <
typename T>
2632template <
typename T>
2640template <
typename T>
2645 return data_[index];
2648template <
typename T>
2653 return data_ !=
nullptr;
2656template <
typename T>
2671 for (
size_t n = 0; n <
size_; ++n)
2680template <
typename T>
2697 for (
size_t n = 0; n <
size_; ++n)
2716template <
typename T>
2721 ocean_assert(
accessor_->data() ==
nullptr);
2724 for (
size_t n = 0; n <
size_; ++n)
2731template <
typename T>
2739template <
typename T>
2747template <
typename T>
2752 return data_[index];
2755template <
typename T>
2760 return data_ !=
nullptr;
Accessor(const Accessor &accessor)=default
Protected copy constructor.
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.
Definition Accessor.h:1598
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
virtual ~Accessor()=default
Default destructor.
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).
Definition Accessor.h:1622
Accessor()=default
Protected default constructor.
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition Accessor.h:1578
Accessor & operator=(const Accessor &accessor)=delete
Deleted assign operator.
static std::vector< typename TAccessor::Type > accessor2elements(const TAccessor &accessor)
Returns all elements of a given accessor (as a block).
Definition Accessor.h:1584
This class implements a container for callback functions.
Definition Callback.h:3454
virtual const T & operator[](const TKey &key) const =0
Returns one element of this accessor object by a given key.
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.
TKey KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition Accessor.h:108
T Type
Definition of the element type of this accessor.
Definition Accessor.h:103
virtual const T * data() const
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:1636
ConstAccessor()=default
Protected default constructor.
virtual bool canAccess(const TKey &key) const =0
Returns whether this accessor has a specific element.
virtual bool firstElement(T &element, TKey &key) const =0
Returns the first element of this accessor.
ConstArrayAccessor()=default
Creates a new empty accessor.
ConstArrayAccessor< T > & operator=(ConstArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition Accessor.h:1808
const T * elements_
The elements of this accessor.
Definition Accessor.h:457
virtual const T * data() const
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:1787
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:460
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:1793
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:1799
size_t subsetSize_
The number of elements that can be accessed.
Definition Accessor.h:1215
ConstArraySubsetAccessor< T, TIndex > & operator=(ConstArraySubsetAccessor< T, TIndex > &&accessor) noexcept
Move operator.
Definition Accessor.h:2447
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2432
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2438
TIndex IndexType
Definition of the data type of the indices.
Definition Accessor.h:1147
ConstArraySubsetAccessor()=default
Creates a new empty accessor.
const TIndex * subsetIndices_
The subset indices of this accessor.
Definition Accessor.h:1212
const T * elements_
The elements of this accessor.
Definition Accessor.h:1209
Callback< const T &, const size_t > CallbackFunction
Definition of a callback function providing access to individual elements.
Definition Accessor.h:1414
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2588
CallbackFunction callback_
The callback function of this accessor.
Definition Accessor.h:1445
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:1448
ConstCallbackIndexedAccessor()=default
Creates a new empty accessor.
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2597
const T * element_
The element of this accessor.
Definition Accessor.h:986
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2208
ConstElementAccessor()=default
Creates a new empty accessor.
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:989
ConstElementAccessor< T > & operator=(ConstElementAccessor< T > &&accessor) noexcept
Move operator.
Definition Accessor.h:2217
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2202
virtual const T & operator[](const size_t &index) const =0
Returns one element of this accessor object by a given index.
virtual bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:1648
virtual bool nextElement(const size_t &previousIndex, T &nextElement, size_t &nextIndex) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:1668
ConstIndexedAccessor()=default
Creates a new indexed-based accessor object.
virtual bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition Accessor.h:1654
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:1751
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:1757
const ConstIndexedAccessor< T > & child_
Definition Accessor.h:1390
const TIndex * subsetIndices_
The subset indices of this accessor.
Definition Accessor.h:1393
size_t subsetSize_
The number of elements that can be accessed.
Definition Accessor.h:1396
ConstIndexedAccessorSubsetAccessor(const ConstIndexedAccessor< T > &child, const TIndex *subsetIndices, const size_t subsetSize)
Creates a new accessor which uses an accessor as base.
Definition Accessor.h:1733
ConstMapAccessor()=default
Creates a new empty accessor.
virtual bool firstElement(T &element, TKey &key) const
Returns the first element of this accessor.
Definition Accessor.h:2262
virtual bool nextElement(const TKey &previousKey, T &nextElement, TKey &nextKey) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:2276
const std::unordered_map< TKey, T > * elementMap_
The elements of this accessor.
Definition Accessor.h:1062
ConstMapAccessor< T, TKey > & operator=(ConstMapAccessor< T, TKey > &&accessor) noexcept
Move operator.
Definition Accessor.h:2305
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2245
virtual const T & operator[](const TKey &key) const
Returns one element of this accessor object.
Definition Accessor.h:2296
virtual bool canAccess(const TKey &key) const
Returns whether this accessor has a specific element.
Definition Accessor.h:2251
ConstTemplateArrayAccessor()=default
Creates a new empty accessor.
T Type
Definition of the element type of this accessor.
Definition Accessor.h:606
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:1929
bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition Accessor.h:1903
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition Accessor.h:1891
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:696
const T * data() const
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:1879
size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:1885
bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:1897
ConstTemplateArrayAccessor< T > & operator=(ConstTemplateArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition Accessor.h:1936
size_t KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition Accessor.h:611
const T * elements_
The elements of this accessor.
Definition Accessor.h:693
bool nextElement(const size_t &previousIndex, T &nextElement, size_t &nextIndex) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:1916
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2555
T Type
Definition of the element type of this accessor.
Definition Accessor.h:1237
const T * data() const
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:2503
size_t KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition Accessor.h:1242
size_t subsetSize_
The number of elements that can be accessed.
Definition Accessor.h:1345
ConstTemplateArraySubsetAccessor< T, TIndex > & operator=(ConstTemplateArraySubsetAccessor< T, TIndex > &&accessor) noexcept
Move operator.
Definition Accessor.h:2563
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition Accessor.h:2515
ConstTemplateArraySubsetAccessor()=default
Creates a new empty accessor.
bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:2521
const TIndex * subsetIndices_
The subset indices of this accessor.
Definition Accessor.h:1342
bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition Accessor.h:2527
bool nextElement(const size_t &previousIndex, T &nextElement, size_t &nextIndex) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:2541
TIndex IndexType
Definition of the data type of the indices.
Definition Accessor.h:1247
const T * elements_
The elements of this accessor.
Definition Accessor.h:1339
size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2509
virtual T & operator[](const TKey &key)=0
Returns one element of this accessor object by a given key.
NonconstAccessor()=default
Creates a new indexed-based accessor object.
virtual T * data()
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:1642
T * elements_
The elements of this accessor.
Definition Accessor.h:788
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2004
virtual T * data()
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:2022
NonconstArrayAccessor< T > & operator=(NonconstArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition Accessor.h:2034
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:791
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2028
NonconstArrayAccessor()=default
Creates a new empty accessor.
This class implements a base class for all indexed-based accessors allowing a non-constant reference ...
Definition Accessor.h:284
virtual T & operator[](const size_t &index)=0
Returns one element of this accessor object by a given index.
virtual bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:1682
virtual bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition Accessor.h:1688
NonconstIndexedAccessor< T > * pointer()
Returns the pointer to this object if this accessor holds at least one element (if this accessor is n...
Definition Accessor.h:1714
virtual bool nextElement(const size_t &previousIndex, T &nextElement, size_t &nextIndex) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:1701
virtual const T & operator[](const size_t &index) const =0
Returns one element of this accessor object by a given key.
NonconstIndexedAccessor()=default
Creates a new accessor object.
NonconstMapAccessor()=default
Creates a new empty accessor.
std::unordered_map< TKey, T > * elementMap_
The elements of this accessor.
Definition Accessor.h:1128
virtual bool canAccess(const TKey &key) const
Returns whether this accessor has a specific element.
Definition Accessor.h:2324
virtual bool firstElement(T &element, TKey &key) const
Returns the first element of this accessor.
Definition Accessor.h:2335
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2369
virtual const T & operator[](const TKey &key) const
Returns one element of this accessor object.
Definition Accessor.h:2375
virtual bool nextElement(const TKey &previousKey, T &nextElement, TKey &nextKey) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:2349
bool nextElement(const size_t &previousIndex, T &nextElement, size_t &nextIndex) const
Returns the next element which follows a given key of the previous element.
Definition Accessor.h:2145
NonconstTemplateArrayAccessor()=default
Creates a new empty accessor.
T Type
Definition of the element type of this accessor.
Definition Accessor.h:811
size_t KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition Accessor.h:816
size_t size_
The number of elements that can be accessed.
Definition Accessor.h:931
bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition Accessor.h:2132
const T * data() const
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition Accessor.h:2102
bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:2126
NonconstTemplateArrayAccessor< T > & operator=(NonconstTemplateArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition Accessor.h:2172
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition Accessor.h:2120
T * elements_
The elements of this accessor.
Definition Accessor.h:928
size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:2114
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:2158
const T & operator[](const size_t index) const
Returns one element of this accessor.
Definition Accessor.h:2641
size_t size_
The number of elements the accessor provides.
Definition Accessor.h:1501
const T * data_
The pointer to the memory block of the accessor.
Definition Accessor.h:1498
const T * data() const
Returns the pointer to the memory block providing the data of the accessor.
Definition Accessor.h:2625
std::vector< T > intermediateValues_
The individual elements of the accessor, if necessary.
Definition Accessor.h:1504
size_t size() const
Returns the number of elements the accessor provides.
Definition Accessor.h:2633
ScopedConstMemoryAccessor(const TAccessor &accessor)
Creates a new scoped accessor object by a given indexed accessor object.
Definition Accessor.h:2604
T * data_
The pointer to the memory block of the accessor.
Definition Accessor.h:1569
size_t size_
The number of elements the accessor provides.
Definition Accessor.h:1572
ScopedNonconstMemoryAccessor(NonconstIndexedAccessor< T > &accessor)
Creates a new scoped accessor object by a given indexed accessor object.
Definition Accessor.h:2657
NonconstIndexedAccessor< T > * accessor_
The given accessor object providing the data for this object, nullptr if no accessor object was provi...
Definition Accessor.h:1566
T * data()
Returns the pointer to the memory block providing the data of the accessor.
Definition Accessor.h:2732
T & operator[](const size_t index)
Returns one element of this accessor.
Definition Accessor.h:2748
~ScopedNonconstMemoryAccessor()
Destructs the scoped accessor object.
Definition Accessor.h:2717
std::vector< T > intermediateValues_
The individual elements of the accessor, if necessary.
Definition Accessor.h:1575
size_t size() const
Returns the number of elements the accessor provides.
Definition Accessor.h:2740
SharedPointerConstArrayAccessor(SharedPointerConstArrayAccessor< T > &&accessor)=default
Move constructor.
std::vector< SharedPointer > SharedPointers
Definition of a vector holding the shared pointer objects.
Definition Accessor.h:508
std::shared_ptr< T > SharedPointer
Definition of the shared pointer object.
Definition Accessor.h:503
SharedPointerConstArrayAccessor()=default
Creates a new empty accessor.
std::vector< const T * > elements_
The pointers to the actual elements wrapped in the shared pointers.
Definition Accessor.h:560
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition Accessor.h:1843
SharedPointerConstArrayAccessor< T > & operator=(SharedPointerConstArrayAccessor< T > &&accessor)=default
Move operator.
virtual const T *const & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition Accessor.h:1849
T Type
Definition of the element type of this accessor.
Definition Accessor.h:208
virtual T operator[](const TKey &key) const =0
Returns one element of this accessor object by a given index.
TemporaryAccessor()=default
Creates a new indexed-based accessor object.
virtual bool canAccess(const TKey &key) const =0
Returns whether this accessor has a specific element.
virtual T operator[](const size_t &index) const =0
Returns one element of this accessor object by a given index.
virtual bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition Accessor.h:1727
TemporaryIndexedAccessor()=default
Creates a new indexed-based accessor object.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15