1 /* 2 * Copyright (c) 2025 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 UNIFIEDDATACHANNEL_H 17 #define UNIFIEDDATACHANNEL_H 18 19 #include <ani.h> 20 #include <memory> 21 #include <string> 22 23 #include "unified_data.h" 24 #include "unified_record.h" 25 26 namespace OHOS { 27 namespace UDMF { 28 class UnifiedRecordHolder { 29 public: 30 explicit UnifiedRecordHolder(ani_env *env, const std::string type, ani_object unionValue); 31 32 const std::shared_ptr<UnifiedRecord> Get(); 33 34 void Set(ani_ref saveRemote); 35 36 ~UnifiedRecordHolder(); 37 38 private: 39 ani_ref saveRemote_ = nullptr; 40 std::shared_ptr<UnifiedRecord> object_; 41 }; 42 43 class UnifiedDataHolder { 44 public: 45 explicit UnifiedDataHolder(UnifiedRecordHolder* recordHolder); 46 47 std::shared_ptr<UnifiedData> Get(); 48 49 void Set(ani_ref saveRemote); 50 ~UnifiedDataHolder(); 51 52 private: 53 ani_ref saveRemote_ = nullptr; 54 std::shared_ptr<UnifiedData> object_; 55 }; 56 } // namespace UDMF 57 } // namespace OHOS 58 #endif // UNIFIEDDATACHANNEL_H