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 #ifndef OHOS_ABILITY_RUNTIME_DATAOBS_MGR_CHANGENOTIFICATION_H 16 #define OHOS_ABILITY_RUNTIME_DATAOBS_MGR_CHANGENOTIFICATION_H 17 18 #include <list> 19 #include <map> 20 #include "uri.h" 21 #include "message_parcel.h" 22 23 namespace OHOS { 24 namespace AAFwk { 25 struct ChangeInfo { 26 enum ChangeType : uint32_t { 27 INSERT = 0, 28 DELETE, 29 UPDATE, 30 OTHER, 31 INVAILD, 32 }; 33 using Value = std::variant<std::monostate, int64_t, double, std::string, bool, std::vector<uint8_t>>; 34 using VBucket = std::map<std::string, Value>; 35 using VBuckets = std::vector<VBucket>; 36 37 static bool Marshalling(const ChangeInfo &input, MessageParcel &parcel); 38 static bool Unmarshalling(ChangeInfo &output, MessageParcel &parcel); 39 40 ChangeType changeType_ = INVAILD; 41 mutable std::list<Uri> uris_ = {}; 42 void *data_ = nullptr; 43 uint32_t size_ = 0; 44 VBuckets valueBuckets_ = {}; 45 static constexpr int LIST_MAX_COUNT = 3000; 46 }; 47 } // namespace AAFwk 48 } // namespace OHOS 49 #endif //OHOS_ABILITY_RUNTIME_DATAOBS_MGR_CHANGENOTIFICATION_H 50