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 CHANGE_NOTIFICATION_H 17 #define CHANGE_NOTIFICATION_H 18 19 #include <list> 20 #include "types.h" 21 22 namespace OHOS { 23 namespace DistributedKv { 24 class ChangeNotification final { 25 public: 26 /** 27 * @brief Constructor of ChangeNotification. 28 * @param insertEntries Inserted entries. 29 * @param updateEntries Updated entries. 30 * @param deleteEntries Deleted entries. 31 * @param deviceId The device ID. 32 * @param icClear Indicate whether the clear function cause this change. 33 */ 34 API_EXPORT ChangeNotification(std::vector<Entry> &&insertEntries, std::vector<Entry> &&updateEntries, 35 std::vector<Entry> &&deleteEntries, const std::string &deviceId, bool isClear); 36 37 /** 38 * @brief Destructor. 39 */ 40 API_EXPORT ~ChangeNotification(); 41 42 /** 43 * @brief Get all inserted entries in this change. 44 */ 45 API_EXPORT const std::vector<Entry> &GetInsertEntries() const; 46 47 /** 48 * @brief Get all updated entries in this changing. 49 */ 50 API_EXPORT const std::vector<Entry> &GetUpdateEntries() const; 51 52 /** 53 * @brief Get all deleted entries in this changing. 54 */ 55 API_EXPORT const std::vector<Entry> &GetDeleteEntries() const; 56 57 /** 58 * @brief Get the device ID. 59 */ 60 API_EXPORT const std::string &GetDeviceId() const; 61 62 /** 63 * @brief Check if this change is made by calling the clear function. 64 * @return Return true if caused by clear function, otherwise false. 65 */ 66 API_EXPORT bool IsClear() const; 67 68 private: 69 std::vector<Entry> insertEntries_; 70 71 std::vector<Entry> updateEntries_; 72 73 std::vector<Entry> deleteEntries_; 74 75 std::string deviceId_; 76 77 bool isClear_ = false; 78 }; 79 } // namespace DistributedKv 80 } // namespace OHOS 81 #endif // CHANGE_NOTIFICATION_H 82