blob: f128d8f67e922b77375c2baf359f660d8e5eb6c8 [file] [log] [blame]
SiCong Li3e363692017-07-04 15:02:10 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
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 */
24#ifndef __ARM_COMPUTE_TEST_IARRAYACCESSOR_H__
25#define __ARM_COMPUTE_TEST_IARRAYACCESSOR_H__
26
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:
38 using value_type = T;
39
40 /** Virtual destructor. */
41 virtual ~IArrayAccessor() = default;
42
43 /** Number of elements of the tensor. */
John Richardsonf89a49f2017-09-05 11:21:56 +010044 virtual size_t num_values() const = 0;
SiCong Li3e363692017-07-04 15:02:10 +010045
46 /** Access to the buffer.
47 *
48 * @return A pointer to the first element in the buffer.
49 */
50 virtual T *buffer() = 0;
51
52 /** Resize array.
53 *
54 * @param[in] num The new array size in number of elements
55 */
56 virtual void resize(size_t num) = 0;
John Richardsonf89a49f2017-09-05 11:21:56 +010057
58 /** Reference to the element of the array located at the given index
59 *
60 * @param[in] index Index of the element
61 *
62 * @return A reference to the element of the array located at the given index.
63 */
64 virtual T &at(size_t index) const = 0;
SiCong Li3e363692017-07-04 15:02:10 +010065};
66} // namespace test
67} // namespace arm_compute
68#endif /* __ARM_COMPUTE_TEST_IARRAYACCESSOR_H__ */