1 /* 2 * Copyright (c) 2021 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 BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_SORTING_MAP_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_SORTING_MAP_H 18 19 #include "notification_sorting.h" 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace Notification { 24 class NotificationSortingMap final : public Parcelable { 25 public: 26 /** 27 * @brief Default constructor used to create an empty NotificationMap instance. 28 */ 29 NotificationSortingMap(); 30 31 /** 32 * @brief Default deconstructor used to deconstruct. 33 */ 34 ~NotificationSortingMap(); 35 36 /** 37 * @brief A constructor used to create a NotificationSortingMap instance by copying parameters from an existing one. 38 * 39 * @param Indicates the NotificationSortingMap object. 40 */ 41 NotificationSortingMap(const std::vector<NotificationSorting> &sortingList); 42 43 /** 44 * @brief Obtains the list of sorted hash codes. 45 * 46 * @return Returns the list of sorted hash codes. 47 */ GetKey()48 inline std::vector<std::string> GetKey() 49 { 50 return sortedKey_; 51 } 52 53 /** 54 * @brief Obtains NotificationSorting based on the hash codes. 55 * 56 * @param key Indicates the hash codes obtained by using getkey(). 57 * 58 * @param sorting Indicates the sorting information about the hash codes. 59 * 60 */ 61 bool GetNotificationSorting(const std::string &key, NotificationSorting &sorting) const; 62 63 /** 64 * @brief Marshals a NotificationSortingMap object into a Parcel. 65 * 66 * @param parcel Indicates the Parcel object for marshalling. 67 * 68 * @return Returns true if the marshalling is successful; returns false otherwise. 69 */ 70 bool Marshalling(Parcel &parcel) const override; 71 72 /** 73 * @brief Unmarshals a NotificationSortingMap object from a Parcel. 74 * 75 * @param Indicates the Parcel object for unmarshalling. 76 */ 77 static NotificationSortingMap *Unmarshalling(Parcel &parcel); 78 79 /** 80 * @brief Dump sorting map info 81 * 82 * @return Return sorting map info to string. 83 */ 84 std::string Dump() const; 85 86 private: 87 void SetKey(const std::string &key); 88 void SetNotificationSorting(const std::vector<NotificationSorting> &sortingList); 89 90 private: 91 std::vector<std::string> sortedKey_ {}; 92 std::map<std::string, NotificationSorting> sortings_ {}; 93 }; 94 } // namespace Notification 95 } // namespace OHOS 96 97 #endif // BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_SORTING_MAP_H