1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief A header file for the BlobIterator class
7 * @file ie_blob_iterator.hpp
10 #include "ie_locked_memory.hpp"
13 namespace InferenceEngine {
16 * @brief This class provides range loops support for TBlob objects
25 * @brief A move constructor to create a BlobIterator instance from a LockedMemory instance.
26 * Explicitly rejects implicit conversions.
27 * @param lk Rvalue of the memory instance to move from
28 * @param offset Size of offset in memory
30 explicit BlobIterator(LockedMemory<T> &&lk, size_t offset = 0)
31 : _mem(std::move(lk)), _offset(offset) {
35 * @brief Increments an offset of the current BlobIterator instance
36 * @return The current BlobIterator instance
38 BlobIterator &operator++() {
44 * @brief An overloaded postfix incrementation operator
45 * Implementation does not follow std interface since only move semantics is used
47 void operator++(int) {
52 * @brief Checks if the given iterator is not equal to the current one
53 * @param that Iterator to compare with
54 * @return true if the given iterator is not equal to the current one, false - otherwise
56 bool operator!=(const BlobIterator &that) const {
57 return !operator==(that);
61 * @brief Gets a value by the pointer to the current iterator
62 * @return The value stored in memory for the current offset value
64 const T &operator*() const {
65 return *(_mem.template as<const T *>() + _offset);
69 * @brief Gets a value by the pointer to the current iterator
70 * @return The value stored in memory for the current offset value
73 return *(_mem.template as<T *>() + _offset);
76 * @brief Compares the given iterator with the current one
77 * @param that Iterator to compare with
78 * @return true if the given iterator is equal to the current one, false - otherwise
80 bool operator==(const BlobIterator &that) const {
81 return &operator*() == &that.operator*();
84 } // namespace details
85 } // namespace InferenceEngine