blob: 4c08b4ab0924b63e4cf655bfcb206dc46ce57a91 [file] [log] [blame]
Georgios Pinitas99d40952018-04-23 16:26:46 +01001/*
2 * Copyright (c) 2018 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_RUNTIME_IMEMORY_REGION_H__
25#define __ARM_COMPUTE_RUNTIME_IMEMORY_REGION_H__
26
27#include <cstddef>
28
29namespace arm_compute
30{
31/** Memory region interface */
32class IMemoryRegion
33{
34public:
35 /** Default constructor
36 *
37 * @param[in] size Region size
38 */
39 IMemoryRegion(size_t size)
40 : _size(size)
41 {
42 }
43 /** Virtual Destructor */
44 virtual ~IMemoryRegion() = default;
45 /** Returns the pointer to the allocated data.
46 *
47 * @return Pointer to the allocated data
48 */
49 virtual void *buffer() = 0;
50 /** Returns the pointer to the allocated data.
51 *
52 * @return Pointer to the allocated data
53 */
54 virtual void *buffer() const = 0;
55 /** Handle of internal memory
56 *
57 * @return Handle of memory
58 */
59 virtual void **handle() = 0;
60 /** Memory region size accessor
61 *
62 * @return Memory region size
63 */
64 size_t size()
65 {
66 return _size;
67 }
68 /** Sets size of region
69 *
70 * @warning This should only be used in correlation with handle
71 *
72 * @param[in] size Size to set
73 */
74 void set_size(size_t size)
75 {
76 _size = size;
77 }
78
79protected:
80 size_t _size;
81};
82} // namespace arm_compute
83#endif /* __ARM_COMPUTE_RUNTIME_IMEMORY_REGION_H__ */