1 /* 2 * Copyright (c) 2023 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 DRAG_DATA_PACKER_H 17 #define DRAG_DATA_PACKER_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "parcel.h" 24 25 #include "drag_data.h" 26 27 namespace OHOS { 28 namespace Msdp { 29 namespace DeviceStatus { 30 31 using SummaryMap = std::map<std::string, int64_t>; 32 class DragDataPacker { 33 public: 34 static int32_t Marshalling(const DragData &dragData, Parcel &data, bool isCross = false); 35 static int32_t UnMarshalling(Parcel &data, DragData &dragData, bool isCross = false); 36 static int32_t CheckDragData(const DragData &dragData); 37 static int32_t MarshallingDetailedSummarys(const DragData &dragData, Parcel &data); 38 static int32_t UnMarshallingDetailedSummarys(Parcel &data, DragData &dragData); 39 static int32_t MarshallingSummaryExpanding(const DragData &dragData, Parcel &data); 40 static int32_t UnMarshallingSummaryExpanding(Parcel &data, DragData &dragData); 41 }; 42 43 class ShadowPacker { 44 public: 45 static int32_t Marshalling(const std::vector<ShadowInfo> &shadowInfos, Parcel &data, bool isCross = false); 46 static int32_t UnMarshalling(Parcel &data, std::vector<ShadowInfo> &shadowInfos, bool isCross = false); 47 static int32_t PackUpShadowInfo(const ShadowInfo &shadowInfo, Parcel &data, bool isCross = false); 48 static int32_t UnPackShadowInfo(Parcel &data, ShadowInfo &shadowInfo, bool isCross = false); 49 static int32_t CheckShadowInfo(const ShadowInfo &shadowInfo); 50 }; 51 52 class SummaryPacker { 53 public: 54 static int32_t Marshalling(const SummaryMap &val, Parcel &parcel); 55 static int32_t UnMarshalling(Parcel &parcel, SummaryMap &val); 56 }; 57 58 class ShadowOffsetPacker { 59 public: 60 static int32_t Marshalling(const ShadowOffset &shadowOffset, Parcel &parcel); 61 static int32_t UnMarshalling(Parcel &parcel, ShadowOffset &shadowOffset); 62 }; 63 64 class SummaryFormat { 65 public: 66 static int32_t Marshalling(const std::map<std::string, std::vector<int32_t>> &val, Parcel &parcel); 67 static int32_t UnMarshalling(Parcel &parcel, std::map<std::string, std::vector<int32_t>> &val); 68 }; 69 } // namespace DeviceStatus 70 } // namespace Msdp 71 } // namespace OHOS 72 #endif // DRAG_DATA_PACKER_H 73