1 /*
2 * This file is auto-generated. DO NOT MODIFY.
3 * Using: out/host/linux-x86/bin/aidl --lang=ndk --structured --version 4 --hash 53178f8de9b8861df391cf0593f6f3e08adad33d -t --stability vintf --min_sdk_version 30 -pout/soong/.intermediates/hardware/interfaces/common/aidl/android.hardware.common_interface/2/preprocessed.aidl -pout/soong/.intermediates/hardware/interfaces/graphics/common/aidl/android.hardware.graphics.common_interface/6/preprocessed.aidl --ninja -d out/soong/.intermediates/hardware/interfaces/neuralnetworks/aidl/android.hardware.neuralnetworks-V4-ndk-source/gen/staging/android/hardware/neuralnetworks/Memory.cpp.d -h out/soong/.intermediates/hardware/interfaces/neuralnetworks/aidl/android.hardware.neuralnetworks-V4-ndk-source/gen/include/staging -o out/soong/.intermediates/hardware/interfaces/neuralnetworks/aidl/android.hardware.neuralnetworks-V4-ndk-source/gen/staging -Nhardware/interfaces/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/4 hardware/interfaces/neuralnetworks/aidl/aidl_api/android.hardware.neuralnetworks/4/android/hardware/neuralnetworks/Memory.aidl
4 *
5 * DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
6 * ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
7 * AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
8 */
9 #pragma once
10
11 #include <array>
12 #include <cassert>
13 #include <cstdint>
14 #include <memory>
15 #include <optional>
16 #include <string>
17 #include <type_traits>
18 #include <utility>
19 #include <variant>
20 #include <vector>
21 #include <android/binder_enums.h>
22 #include <android/binder_interface_utils.h>
23 #include <android/binder_parcelable_utils.h>
24 #include <android/binder_to_string.h>
25 #include <aidl/android/hardware/common/Ashmem.h>
26 #include <aidl/android/hardware/common/MappableFile.h>
27 #include <aidl/android/hardware/graphics/common/HardwareBuffer.h>
28 #ifdef BINDER_STABILITY_SUPPORT
29 #include <android/binder_stability.h>
30 #endif // BINDER_STABILITY_SUPPORT
31
32 #ifndef __BIONIC__
33 #define __assert2(a,b,c,d) ((void)0)
34 #endif
35
36 namespace aidl::android::hardware::common {
37 class Ashmem;
38 class MappableFile;
39 } // namespace aidl::android::hardware::common
40 namespace aidl::android::hardware::graphics::common {
41 class HardwareBuffer;
42 } // namespace aidl::android::hardware::graphics::common
43 namespace aidl {
44 namespace android {
45 namespace hardware {
46 namespace neuralnetworks {
47 class Memory {
48 public:
49 typedef std::false_type fixed_size;
50 static const char* descriptor;
51
52 enum class Tag : int32_t {
53 ashmem = 0,
54 mappableFile = 1,
55 hardwareBuffer = 2,
56 };
57
58 // Expose tag symbols for legacy code
59 static const inline Tag ashmem = Tag::ashmem;
60 static const inline Tag mappableFile = Tag::mappableFile;
61 static const inline Tag hardwareBuffer = Tag::hardwareBuffer;
62
63 template<typename _Tp>
64 static constexpr bool _not_self = !std::is_same_v<std::remove_cv_t<std::remove_reference_t<_Tp>>, Memory>;
65
Memory()66 Memory() : _value(std::in_place_index<static_cast<size_t>(ashmem)>, ::aidl::android::hardware::common::Ashmem()) { }
67
68 template <typename _Tp, typename = std::enable_if_t<_not_self<_Tp>>>
69 // NOLINTNEXTLINE(google-explicit-constructor)
Memory(_Tp && _arg)70 constexpr Memory(_Tp&& _arg)
71 : _value(std::forward<_Tp>(_arg)) {}
72
73 template <size_t _Np, typename... _Tp>
Memory(std::in_place_index_t<_Np>,_Tp &&..._args)74 constexpr explicit Memory(std::in_place_index_t<_Np>, _Tp&&... _args)
75 : _value(std::in_place_index<_Np>, std::forward<_Tp>(_args)...) {}
76
77 template <Tag _tag, typename... _Tp>
make(_Tp &&..._args)78 static Memory make(_Tp&&... _args) {
79 return Memory(std::in_place_index<static_cast<size_t>(_tag)>, std::forward<_Tp>(_args)...);
80 }
81
82 template <Tag _tag, typename _Tp, typename... _Up>
make(std::initializer_list<_Tp> _il,_Up &&..._args)83 static Memory make(std::initializer_list<_Tp> _il, _Up&&... _args) {
84 return Memory(std::in_place_index<static_cast<size_t>(_tag)>, std::move(_il), std::forward<_Up>(_args)...);
85 }
86
getTag()87 Tag getTag() const {
88 return static_cast<Tag>(_value.index());
89 }
90
91 template <Tag _tag>
get()92 const auto& get() const {
93 if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
94 return std::get<static_cast<size_t>(_tag)>(_value);
95 }
96
97 template <Tag _tag>
get()98 auto& get() {
99 if (getTag() != _tag) { __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, "bad access: a wrong tag"); }
100 return std::get<static_cast<size_t>(_tag)>(_value);
101 }
102
103 template <Tag _tag, typename... _Tp>
set(_Tp &&..._args)104 void set(_Tp&&... _args) {
105 _value.emplace<static_cast<size_t>(_tag)>(std::forward<_Tp>(_args)...);
106 }
107
108 binder_status_t readFromParcel(const AParcel* _parcel);
109 binder_status_t writeToParcel(AParcel* _parcel) const;
110
111 inline bool operator==(const Memory& _rhs) const {
112 return _value == _rhs._value;
113 }
114 inline bool operator<(const Memory& _rhs) const {
115 return _value < _rhs._value;
116 }
117 inline bool operator!=(const Memory& _rhs) const {
118 return !(*this == _rhs);
119 }
120 inline bool operator>(const Memory& _rhs) const {
121 return _rhs < *this;
122 }
123 inline bool operator>=(const Memory& _rhs) const {
124 return !(*this < _rhs);
125 }
126 inline bool operator<=(const Memory& _rhs) const {
127 return !(_rhs < *this);
128 }
129
130 static const ::ndk::parcelable_stability_t _aidl_stability = ::ndk::STABILITY_VINTF;
toString()131 inline std::string toString() const {
132 std::ostringstream os;
133 os << "Memory{";
134 switch (getTag()) {
135 case ashmem: os << "ashmem: " << ::android::internal::ToString(get<ashmem>()); break;
136 case mappableFile: os << "mappableFile: " << ::android::internal::ToString(get<mappableFile>()); break;
137 case hardwareBuffer: os << "hardwareBuffer: " << ::android::internal::ToString(get<hardwareBuffer>()); break;
138 }
139 os << "}";
140 return os.str();
141 }
142 private:
143 std::variant<::aidl::android::hardware::common::Ashmem, ::aidl::android::hardware::common::MappableFile, ::aidl::android::hardware::graphics::common::HardwareBuffer> _value;
144 };
145 } // namespace neuralnetworks
146 } // namespace hardware
147 } // namespace android
148 } // namespace aidl
149 namespace aidl {
150 namespace android {
151 namespace hardware {
152 namespace neuralnetworks {
toString(Memory::Tag val)153 [[nodiscard]] static inline std::string toString(Memory::Tag val) {
154 switch(val) {
155 case Memory::Tag::ashmem:
156 return "ashmem";
157 case Memory::Tag::mappableFile:
158 return "mappableFile";
159 case Memory::Tag::hardwareBuffer:
160 return "hardwareBuffer";
161 default:
162 return std::to_string(static_cast<int32_t>(val));
163 }
164 }
165 } // namespace neuralnetworks
166 } // namespace hardware
167 } // namespace android
168 } // namespace aidl
169 namespace ndk {
170 namespace internal {
171 #pragma clang diagnostic push
172 #pragma clang diagnostic ignored "-Wc++17-extensions"
173 template <>
174 constexpr inline std::array<aidl::android::hardware::neuralnetworks::Memory::Tag, 3> enum_values<aidl::android::hardware::neuralnetworks::Memory::Tag> = {
175 aidl::android::hardware::neuralnetworks::Memory::Tag::ashmem,
176 aidl::android::hardware::neuralnetworks::Memory::Tag::mappableFile,
177 aidl::android::hardware::neuralnetworks::Memory::Tag::hardwareBuffer,
178 };
179 #pragma clang diagnostic pop
180 } // namespace internal
181 } // namespace ndk
182