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);
95 template <
typename T,
typename TKey>
164 template <
typename T,
typename TKey>
200 template <
typename T,
typename TKey>
239 template <
typename T>
282 template <
typename T>
291 virtual bool canAccess(
const size_t& index)
const;
297 virtual bool firstElement(T& element,
size_t& index)
const;
339 template <
typename T>
356 virtual bool canAccess(
const size_t& index)
const;
398 template <
typename T>
433 virtual const T*
data()
const;
439 virtual size_t size()
const;
445 virtual const T&
operator[](
const size_t& index)
const;
495 template <
typename T>
542 virtual size_t size()
const;
548 virtual const T*
const &
operator[](
const size_t& index)
const;
598 template <
typename T>
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;
705 template <
typename T>
764 virtual size_t size()
const;
770 virtual const T&
operator[](
const size_t& index)
const;
803 template <
typename T>
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;
940 template <
typename T>
968 virtual size_t size()
const;
974 virtual const T&
operator[](
const size_t& index)
const;
999 template <
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;
1072 template <
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;
1139 template <
typename T,
typename TIndex>
1191 virtual size_t size()
const;
1197 virtual const T&
operator[](
const size_t& index)
const;
1229 template <
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;
1354 template <
typename T,
typename TIndex>
1378 virtual size_t size()
const;
1385 virtual const T&
operator[](
const size_t& index)
const;
1404 template <
typename T>
1434 virtual const T&
operator[](
const size_t& index)
const;
1440 virtual size_t size()
const;
1457 template <
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;
1514 template <
typename T>
1548 inline size_t size()
const;
1561 explicit inline operator bool()
const;
1583 template <
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]);
1597 template <
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))
1609 result[key] = element;
1611 while (accessor.nexteElement(key, element, key));
1617 template <
typename TAccessor,
typename TIndex>
1620 std::vector<typename TAccessor::Type> result;
1621 result.reserve(subset.size());
1623 for (
size_t n = 0; n < subset.size(); ++n)
1625 result.emplace_back(accessor[subset[n]]);
1631 template <
typename T,
typename TKey>
1637 template <
typename T,
typename TKey>
1643 template <
typename T>
1646 return index < this->size();
1649 template <
typename T>
1652 if (this->size() == 0)
1657 element = (*this)[0];
1663 template <
typename T>
1666 if (previousIndex + 1 < this->size())
1668 nextIndex = previousIndex + 1;
1669 element = (*this)[nextIndex];
1677 template <
typename T>
1680 return index < this->size();
1683 template <
typename T>
1686 if (this->size() == 0)
1691 element = (*this)[0];
1696 template <
typename T>
1699 if (previousIndex + 1 < this->size())
1701 nextIndex = previousIndex + 1;
1702 nextElement = (*this)[nextIndex];
1709 template <
typename T>
1712 if (this->isEmpty())
1722 template <
typename T>
1725 return index < this->size();
1728 template <
typename T,
typename TIndex>
1731 subsetIndices_(subsetIndices),
1732 subsetSize_(subsetSize)
1737 template <
typename T,
typename TIndex>
1740 subsetIndices_(subsetIndices.data()),
1741 subsetSize_(subsetIndices.size())
1746 template <
typename T,
typename TIndex>
1752 template <
typename T,
typename TIndex>
1755 ocean_assert(index < subsetSize_);
1757 return child_[subsetIndices_[index]];
1760 template <
typename T>
1763 *
this = std::move(accessor);
1766 template <
typename T>
1768 elements_(elements),
1774 template <
typename T>
1776 elements_(elements.data()),
1777 size_(elements.size())
1782 template <
typename T>
1788 template <
typename T>
1794 template <
typename T>
1797 ocean_assert(index < size_);
1798 ocean_assert(elements_ !=
nullptr);
1800 return elements_[index];
1803 template <
typename T>
1806 if (
this != &accessor)
1808 elements_ = accessor.elements_;
1809 size_ = accessor.size_;
1811 accessor.elements_ =
nullptr;
1818 template <
typename T>
1822 for (
size_t n = 0; n <
size; ++n)
1828 template <
typename T>
1830 elements_(elements.size())
1832 for (
size_t n = 0; n < elements.size(); ++n)
1838 template <
typename T>
1841 return elements_.size();
1844 template <
typename T>
1847 ocean_assert(index < elements_.size());
1849 return elements_[index];
1852 template <
typename T>
1855 *
this = std::move(accessor);
1858 template <
typename T>
1860 elements_(elements),
1866 template <
typename T>
1868 elements_(elements.data()),
1869 size_(elements.size())
1874 template <
typename T>
1880 template <
typename T>
1886 template <
typename T>
1892 template <
typename T>
1895 return index < size_;
1898 template <
typename T>
1906 element = elements_[0];
1911 template <
typename T>
1914 if (previousIndex + 1 >= size_)
1919 nextIndex = previousIndex + 1;
1920 nextElement = elements_[nextIndex];
1924 template <
typename T>
1927 ocean_assert(index < size_);
1928 return elements_[index];
1931 template <
typename T>
1934 if (
this != &accessor)
1936 elements_ = accessor.elements_;
1937 size_ = accessor.size_;
1939 accessor.elements_ =
nullptr;
1946 template <
typename T>
1949 *
this = std::move(accessor);
1952 template <
typename T>
1954 elements_(elements),
1960 template <
typename T>
1962 elements_(elements.data()),
1963 size_(elements.size())
1968 template <
typename T>
1973 if (resizeSize != 0)
1975 elements.resize(resizeSize);
1979 size_ = elements.size();
1982 template <
typename T>
1989 if (resizeSize != 0)
1991 elements->resize(resizeSize);
1995 size_ = elements->size();
1999 template <
typename T>
2002 ocean_assert(index < size_);
2003 ocean_assert(elements_);
2005 return elements_[index];
2008 template <
typename T>
2011 ocean_assert(index < size_);
2012 ocean_assert(elements_);
2014 return elements_[index];
2017 template <
typename T>
2023 template <
typename T>
2029 template <
typename T>
2032 if (
this != &accessor)
2034 elements_ = accessor.elements_;
2035 size_ = accessor.size_;
2037 accessor.elements_ =
nullptr;
2044 template <
typename T>
2047 *
this = std::move(accessor);
2050 template <
typename T>
2052 elements_(elements),
2058 template <
typename T>
2060 elements_(elements.data()),
2061 size_(elements.size())
2066 template <
typename T>
2071 if (resizeSize != 0)
2073 elements.resize(resizeSize);
2077 size_ = elements.size();
2080 template <
typename T>
2087 if (resizeSize != 0)
2089 elements->resize(resizeSize);
2093 size_ = elements->size();
2097 template <
typename T>
2103 template <
typename T>
2109 template <
typename T>
2115 template <
typename T>
2121 template <
typename T>
2124 return index < size_;
2127 template <
typename T>
2135 element = elements_[0];
2140 template <
typename T>
2143 if (previousIndex + 1 >= size_)
2148 nextIndex = previousIndex + 1;
2149 nextElement = elements_[nextIndex];
2153 template <
typename T>
2156 ocean_assert(index < size_);
2157 return elements_[index];
2160 template <
typename T>
2163 ocean_assert(index < size_);
2164 return elements_[index];
2167 template <
typename T>
2170 if (
this != &accessor)
2172 elements_ = accessor.elements_;
2173 size_ = accessor.size_;
2175 accessor.elements_ =
nullptr;
2182 template <
typename T>
2185 *
this = std::move(accessor);
2188 template <
typename T>
2193 ocean_assert(
size_ != 0);
2197 template <
typename T>
2203 template <
typename T>
2206 ocean_assert_and_suppress_unused(index < size_, index);
2207 ocean_assert(element_ !=
nullptr);
2212 template <
typename T>
2215 if (
this != &accessor)
2217 element_ = accessor.element_;
2218 size_ = accessor.size_;
2220 accessor.element_ =
nullptr;
2227 template <
typename T,
typename TKey>
2230 *
this = std::move(accessor);
2233 template <
typename T,
typename TKey>
2235 elementMap_(&elements)
2240 template <
typename T,
typename TKey>
2243 return elementMap_ ? elementMap_->size() : 0;
2246 template <
typename T,
typename TKey>
2249 if (elementMap_ ==
nullptr)
2254 return elementMap_->find(key) != elementMap_->end();
2257 template <
typename T,
typename TKey>
2260 if (elementMap_ ==
nullptr || elementMap_->empty())
2265 key = elementMap_->begin()->first;
2266 element = elementMap_->begin()->second;
2271 template <
typename T,
typename TKey>
2274 if (elementMap_ ==
nullptr)
2279 const typename std::unordered_map<TKey, T>::const_iterator i = elementMap_->find(previousKey);
2280 if (i == elementMap_->cend() || (++i) == elementMap_->cend())
2286 element = i->second;
2291 template <
typename T,
typename TKey>
2294 ocean_assert(elementMap_);
2295 ocean_assert(elementMap_->find(key) != elementMap_->end());
2297 return elementMap_->find(key)->second;
2300 template <
typename T,
typename TKey>
2303 if (
this != &accessor)
2305 elementMap_ = accessor.elementMap_;
2306 accessor.elementMap_ =
nullptr;
2312 template <
typename T,
typename TKey>
2314 elementMap_(&elements)
2319 template <
typename T,
typename TKey>
2322 if (elementMap_ ==
nullptr)
2327 return elementMap_->find(key) != elementMap_->end();
2330 template <
typename T,
typename TKey>
2333 if (elementMap_ ==
nullptr || elementMap_->empty())
2338 key = elementMap_->begin()->first;
2339 element = elementMap_->begin()->second;
2344 template <
typename T,
typename TKey>
2347 if (elementMap_ ==
nullptr)
2352 const typename std::unordered_map<TKey, T>::const_iterator i = elementMap_->find(previousKey);
2353 if (i == elementMap_->cend() || (++i) == elementMap_->cend())
2359 element = i->second;
2364 template <
typename T,
typename TKey>
2367 return elementMap_ ? elementMap_->size() : 0;
2370 template <
typename T,
typename TKey>
2373 ocean_assert(elementMap_);
2374 ocean_assert(elementMap_->find(key) != elementMap_->end());
2376 return elementMap_->find(key)->second;
2379 template <
typename T,
typename TKey>
2382 ocean_assert(elementMap_);
2383 ocean_assert(elementMap_->find(key) != elementMap_->end());
2385 return elementMap_->find(key)->second;
2388 template <
typename T,
typename TIndex>
2391 *
this = std::move(accessor);
2394 template <
typename T,
typename TIndex>
2396 elements_(elements),
2397 subsetIndices_(subsetIndices),
2398 subsetSize_(subsetSize)
2403 template <
typename T,
typename TIndex>
2405 elements_(elements),
2406 subsetIndices_(subsetIndices.data()),
2407 subsetSize_(subsetIndices.size())
2412 template <
typename T,
typename TIndex>
2414 elements_(elements.data()),
2415 subsetIndices_(subsetIndices.data()),
2416 subsetSize_(subsetIndices.size())
2419 ocean_assert(subsetIndices.size() <= elements.size());
2420 for (
size_t n = 0; n < subsetIndices.size(); ++n)
2422 ocean_assert(subsetIndices[n] < elements.size());
2427 template <
typename T,
typename TIndex>
2433 template <
typename T,
typename TIndex>
2436 ocean_assert(index < subsetSize_);
2437 ocean_assert(elements_ && subsetIndices_);
2439 return elements_[subsetIndices_[index]];
2442 template <
typename T,
typename TIndex>
2445 if (
this != &accessor)
2447 elements_ = accessor.elements_;
2448 subsetIndices_ = accessor.subsetIndices_;
2449 subsetSize_ = accessor.subsetSize_;
2451 accessor.elements_ =
nullptr;
2452 accessor.subsetIndices_ =
nullptr;
2453 accessor.subsetSize_ = 0;
2459 template <
typename T,
typename TIndex>
2462 *
this = std::move(accessor);
2465 template <
typename T,
typename TIndex>
2467 elements_(elements),
2468 subsetIndices_(subsetIndices),
2469 subsetSize_(subsetSize)
2474 template <
typename T,
typename TIndex>
2476 elements_(elements),
2477 subsetIndices_(subsetIndices.data()),
2478 subsetSize_(subsetIndices.size())
2483 template <
typename T,
typename TIndex>
2485 elements_(elements.data()),
2486 subsetIndices_(subsetIndices.data()),
2487 subsetSize_(subsetIndices.size())
2490 ocean_assert(subsetIndices.size() <= elements.size());
2491 for (
size_t n = 0; n < subsetIndices.size(); ++n)
2493 ocean_assert(subsetIndices[n] < elements.size());
2498 template <
typename T,
typename TIndex>
2504 template <
typename T,
typename TIndex>
2510 template <
typename T,
typename TIndex>
2513 return subsetSize_ == 0;
2516 template <
typename T,
typename TIndex>
2519 return index < subsetSize_;
2522 template <
typename T,
typename TIndex>
2525 if (subsetSize_ == 0)
2530 element = (*this)[0];
2536 template <
typename T,
typename TIndex>
2539 if (previousIndex + 1 >= subsetSize_)
2544 nextIndex = previousIndex + 1;
2545 nextElement = (*this)[nextIndex];
2550 template <
typename T,
typename TIndex>
2553 ocean_assert(index < subsetSize_);
2555 return elements_[subsetIndices_[index]];
2558 template <
typename T,
typename TIndex>
2561 if (
this != &accessor)
2563 elements_ = accessor.elements_;
2564 subsetIndices_ = accessor.subsetIndices_;
2565 subsetSize_ = accessor.subsetSize_;
2567 accessor.elements_ =
nullptr;
2568 accessor.subsetIndices_ =
nullptr;
2569 accessor.subsetSize_ = 0;
2575 template <
typename T>
2577 callback_(callback),
2583 template <
typename T>
2586 ocean_assert(index < size_);
2587 ocean_assert(callback_);
2589 return callback_(index);
2592 template <
typename T>
2598 template <
typename T>
2599 template <
typename TAccessor>
2604 data_ = accessor.data();
2605 size_ = accessor.size();
2611 for (
size_t n = 0; n <
size_; ++n)
2620 template <
typename T>
2623 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2628 template <
typename T>
2631 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2636 template <
typename T>
2639 ocean_assert(data_ && index < size());
2641 return data_[index];
2644 template <
typename T>
2647 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2649 return data_ !=
nullptr;
2652 template <
typename T>
2654 accessor_(&accessor),
2667 for (
size_t n = 0; n <
size_; ++n)
2676 template <
typename T>
2678 accessor_(accessor),
2693 for (
size_t n = 0; n <
size_; ++n)
2712 template <
typename T>
2715 if (accessor_ && !intermediateValues_.empty())
2717 ocean_assert(accessor_->data() ==
nullptr);
2718 ocean_assert(size_ == accessor_->size());
2720 for (
size_t n = 0; n < size_; ++n)
2722 (*accessor_)[n] = std::move(intermediateValues_[n]);
2727 template <
typename T>
2730 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2735 template <
typename T>
2738 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2743 template <
typename T>
2746 ocean_assert(data_ && index < size());
2748 return data_[index];
2751 template <
typename T>
2754 ocean_assert((data_ !=
nullptr && size_ != 0) || (data_ ==
nullptr && size_ == 0));
2756 return data_ !=
nullptr;
This class implements a base class for all accessors.
Definition: Accessor.h:23
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.
Accessor & operator=(const Accessor &accessor)=delete
Deleted assign operator.
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:1618
Accessor()=default
Protected default constructor.
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition: Accessor.h:1578
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 base class for accessors allowing a constant reference access.
Definition: Accessor.h:97
TKey KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition: Accessor.h:108
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.
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:1632
virtual const T & operator[](const TKey &key) const =0
Returns one element of this accessor object by a given key.
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.
T Type
Definition of the element type of this accessor.
Definition: Accessor.h:103
This class implements an accessor providing direct access to a constant array of elements.
Definition: Accessor.h:400
ConstArrayAccessor()=default
Creates a new empty accessor.
ConstArrayAccessor< T > & operator=(ConstArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition: Accessor.h:1804
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:1783
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:1789
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:1795
This class implements an indexed-based constant accessor providing access to a subset of elements sto...
Definition: Accessor.h:1141
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:2443
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:2428
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:2434
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
TIndex IndexType
Definition of the data type of the indices.
Definition: Accessor.h:1147
This class implements an accessor providing access to a elements by using a callback function.
Definition: Accessor.h:1406
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:2584
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.
Callback< const T &, const size_t > CallbackFunction
Definition of a callback function providing access to individual elements.
Definition: Accessor.h:1414
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:2593
This class implements an accessor providing direct access to a constant array of elements while all e...
Definition: Accessor.h:942
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:2204
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:2213
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:2198
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition: Accessor.h:241
virtual bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition: Accessor.h:1644
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:1664
virtual const T & operator[](const size_t &index) const =0
Returns one element of this accessor object by a given index.
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:1650
This class implements an indexed-based constant accessor providing access to a subset of elements sto...
Definition: Accessor.h:1356
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:1747
virtual const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:1753
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:1729
This class implements an accessor providing direct access to a constant (unordered) map of elements.
Definition: Accessor.h:1001
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:2258
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:2272
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:2301
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:2241
virtual const T & operator[](const TKey &key) const
Returns one element of this accessor object.
Definition: Accessor.h:2292
virtual bool canAccess(const TKey &key) const
Returns whether this accessor has a specific element.
Definition: Accessor.h:2247
This class implements an accessor providing direct access to a constant array of elements.
Definition: Accessor.h:600
T Type
Definition of the element type of this accessor.
Definition: Accessor.h:606
ConstTemplateArrayAccessor()=default
Creates a new empty accessor.
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:1925
bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition: Accessor.h:1899
size_t KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition: Accessor.h:611
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition: Accessor.h:1887
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:1875
ConstTemplateArrayAccessor< T > & operator=(ConstArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition: Accessor.h:1932
size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:1881
bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition: Accessor.h:1893
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:1912
This class implements an indexed-based constant accessor providing access to a subset of elements sto...
Definition: Accessor.h:1231
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:2551
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:2499
TIndex IndexType
Definition of the data type of the indices.
Definition: Accessor.h:1247
size_t subsetSize_
The number of elements that can be accessed.
Definition: Accessor.h:1345
size_t KeyType
Definition of the key (or e.g., index) type of this accessor.
Definition: Accessor.h:1242
T Type
Definition of the element type of this accessor.
Definition: Accessor.h:1237
ConstTemplateArraySubsetAccessor< T, TIndex > & operator=(ConstTemplateArraySubsetAccessor< T, TIndex > &&accessor) noexcept
Move operator.
Definition: Accessor.h:2559
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition: Accessor.h:2511
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:2517
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:2523
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:2537
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:2505
This class implements a base class for accessors allowing a non-constant reference access.
Definition: Accessor.h:166
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:1638
This class implements an accessor providing direct access to an array of elements.
Definition: Accessor.h:707
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:2000
virtual T * data()
Returns a pointer to the elements of this accessor if the data exists within one memory block without...
Definition: Accessor.h:2018
NonconstArrayAccessor< T > & operator=(NonconstArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition: Accessor.h:2030
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:2024
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 bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition: Accessor.h:1678
virtual bool firstElement(T &element, size_t &index) const
Returns the first element of this accessor.
Definition: Accessor.h:1684
virtual const T & operator[](const size_t &index) const =0
Returns one element of this accessor object by a given key.
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:1710
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:1697
virtual T & operator[](const size_t &index)=0
Returns one element of this accessor object by a given index.
NonconstIndexedAccessor()=default
Creates a new accessor object.
This class implements an accessor providing direct access to an (unordered) map of elements.
Definition: Accessor.h:1074
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:2320
virtual bool firstElement(T &element, TKey &key) const
Returns the first element of this accessor.
Definition: Accessor.h:2331
virtual size_t size() const
Returns the number of accessible elements of this accessor object.
Definition: Accessor.h:2365
virtual const T & operator[](const TKey &key) const
Returns one element of this accessor object.
Definition: Accessor.h:2371
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:2345
This class implements an accessor providing direct access to an array of elements.
Definition: Accessor.h:805
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:2141
NonconstTemplateArrayAccessor()=default
Creates a new empty accessor.
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:2128
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:2098
bool canAccess(const size_t &index) const
Returns whether this accessor has a specific element.
Definition: Accessor.h:2122
NonconstTemplateArrayAccessor< T > & operator=(NonconstTemplateArrayAccessor< T > &&accessor) noexcept
Move operator.
Definition: Accessor.h:2168
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition: Accessor.h:2116
T Type
Definition of the element type of this accessor.
Definition: Accessor.h:811
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:2110
const T & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:2154
This class implements an accessor that guarantees memory access to the elements of an indexed accesso...
Definition: Accessor.h:1459
const T & operator[](const size_t index) const
Returns one element of this accessor.
Definition: Accessor.h:2637
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:2621
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:2629
ScopedConstMemoryAccessor(const TAccessor &accessor)
Creates a new scoped accessor object by a given indexed accessor object.
Definition: Accessor.h:2600
This class implements an accessor that guarantees memory access to the elements of an indexed accesso...
Definition: Accessor.h:1516
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:2653
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:2728
T & operator[](const size_t index)
Returns one element of this accessor.
Definition: Accessor.h:2744
~ScopedNonconstMemoryAccessor()
Destructs the scoped accessor object.
Definition: Accessor.h:2713
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:2736
This class implements an accessor providing direct access to std::shared_ptr<T> elements returned as ...
Definition: Accessor.h:497
SharedPointerConstArrayAccessor< T > & operator=(SharedPointerConstArrayAccessor< T > &&accessor)=default
Move operator.
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:1839
virtual const T *const & operator[](const size_t &index) const
Returns one element of this accessor object.
Definition: Accessor.h:1845
This class implements a base class for all accessors allowing to access temporary elements.
Definition: Accessor.h:202
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.
T Type
Definition of the element type of this accessor.
Definition: Accessor.h:208
This class implements a base class for all indexed-based accessors allowing to access temporary eleme...
Definition: Accessor.h:341
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:1723
TemporaryIndexedAccessor()=default
Creates a new indexed-based accessor object.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15