Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2020 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_ARRAY_H |
| 25 | #define ARM_COMPUTE_ARRAY_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/IArray.h" |
| 28 | #include "arm_compute/core/Types.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 29 | #include "support/MemorySupport.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | |
| 31 | #include <memory> |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | /** Basic implementation of the IArray interface which allocates a static number of T values */ |
| 36 | template <class T> |
| 37 | class Array : public IArray<T> |
| 38 | { |
| 39 | public: |
| 40 | /** Default constructor: empty array */ |
| 41 | Array() |
| 42 | : IArray<T>(0), _values(nullptr) |
| 43 | { |
| 44 | } |
| 45 | /** Constructor: initializes an array which can contain up to max_num_points values |
| 46 | * |
| 47 | * @param[in] max_num_values Maximum number of values the array will be able to stored |
| 48 | */ |
| 49 | Array(size_t max_num_values) |
Moritz Pflanzer | d0ae8b8 | 2017-06-29 14:51:57 +0100 | [diff] [blame] | 50 | : IArray<T>(max_num_values), _values(arm_compute::support::cpp14::make_unique<T[]>(max_num_values)) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 51 | { |
| 52 | } |
| 53 | |
| 54 | // Inherited methods overridden: |
| 55 | T *buffer() const override |
| 56 | { |
| 57 | return _values.get(); |
| 58 | } |
| 59 | |
| 60 | private: |
| 61 | std::unique_ptr<T[]> _values; |
| 62 | }; |
| 63 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 64 | /** Array of Key Points. */ |
| 65 | using KeyPointArray = Array<KeyPoint>; |
| 66 | /** Array of 2D Coordinates. */ |
| 67 | using Coordinates2DArray = Array<Coordinates2D>; |
| 68 | /** Array of Detection Windows. */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 69 | using DetectionWindowArray = Array<DetectionWindow>; |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 70 | /** Array of 2D Sizes. */ |
| 71 | using Size2DArray = Array<Size2D>; |
| 72 | /** Array of uint8s. */ |
| 73 | using UInt8Array = Array<uint8_t>; |
| 74 | /** Array of uint16s. */ |
| 75 | using UInt16Array = Array<uint16_t>; |
| 76 | /** Array of uint32s. */ |
| 77 | using UInt32Array = Array<uint32_t>; |
| 78 | /** Array of int16s. */ |
| 79 | using Int16Array = Array<int16_t>; |
| 80 | /** Array of int32s. */ |
| 81 | using Int32Array = Array<int32_t>; |
| 82 | /** Array of floats. */ |
| 83 | using FloatArray = Array<float>; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 84 | } |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 85 | #endif /* ARM_COMPUTE_ARRAY_H */ |