1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_BUFFER_HANDLE_H 17 #define HDI_BUFFER_HANDLE_H 18 19 #include <message_parcel.h> 20 #include "buffer_handle.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Base { 25 using OHOS::MessageParcel; 26 using OHOS::Parcelable; 27 28 class HdiBufferHandle : public Parcelable { 29 public: 30 HdiBufferHandle(); 31 virtual ~HdiBufferHandle(); 32 explicit HdiBufferHandle(BufferHandle &handle); 33 34 HdiBufferHandle(const HdiBufferHandle &other); 35 HdiBufferHandle(HdiBufferHandle &&other) noexcept; 36 37 HdiBufferHandle &operator=(const HdiBufferHandle &other); 38 HdiBufferHandle &operator=(HdiBufferHandle &&other) noexcept; 39 40 bool Marshalling(Parcel &parcel) const override; 41 static sptr<HdiBufferHandle> Unmarshalling(Parcel &parcel); 42 BufferHandle *Move(); 43 std::string Dump() const; 44 45 private: 46 bool ExtractFromParcel(Parcel &parcel); 47 static bool WriteReserveData(MessageParcel &messageParcel, const BufferHandle &handle); 48 static bool ReadReserveData(MessageParcel &messageParcel, BufferHandle &handle); 49 BufferHandle *handle_; 50 }; 51 } // namespace Base 52 } // namespace HDI 53 } // namespace OHOS 54 55 #endif // HDI_BUFFER_HANDLE_H