blob: 488aeb023072a2cf21542f2d1b0a5388a34fa5e0 [file] [log] [blame]
SiCong Li3e363692017-07-04 15:02:10 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2019 Arm Limited.
SiCong Li3e363692017-07-04 15:02:10 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_TEST_IARRAYACCESSOR_H
25#define ARM_COMPUTE_TEST_IARRAYACCESSOR_H
SiCong Li3e363692017-07-04 15:02:10 +010026
27namespace arm_compute
28{
29namespace test
30{
31/** Common interface to provide information and access to array like
32 * structures.
33 */
34template <typename T>
35class IArrayAccessor
36{
37public:
Alex Gildayc357c472018-03-21 13:54:09 +000038 /** Array value type */
SiCong Li3e363692017-07-04 15:02:10 +010039 using value_type = T;
40
41 /** Virtual destructor. */
42 virtual ~IArrayAccessor() = default;
43
Alex Gildayc357c472018-03-21 13:54:09 +000044 /** Number of elements of the tensor.
45 *
46 * @return the number of elements.
47 */
John Richardsonf89a49f2017-09-05 11:21:56 +010048 virtual size_t num_values() const = 0;
SiCong Li3e363692017-07-04 15:02:10 +010049
50 /** Access to the buffer.
51 *
52 * @return A pointer to the first element in the buffer.
53 */
54 virtual T *buffer() = 0;
55
56 /** Resize array.
57 *
Anthony Barbierf202e502017-11-23 18:02:04 +000058 * @param[in] num The new array size in number of elements
SiCong Li3e363692017-07-04 15:02:10 +010059 */
60 virtual void resize(size_t num) = 0;
John Richardsonf89a49f2017-09-05 11:21:56 +010061
62 /** Reference to the element of the array located at the given index
63 *
64 * @param[in] index Index of the element
65 *
66 * @return A reference to the element of the array located at the given index.
67 */
68 virtual T &at(size_t index) const = 0;
SiCong Li3e363692017-07-04 15:02:10 +010069};
70} // namespace test
71} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000072#endif /* ARM_COMPUTE_TEST_IARRAYACCESSOR_H */