1 /* 2 * Copyright (c) 2024 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 NATIVE_RDB_LOCAL_DB_OBSERVER_H 17 #define NATIVE_RDB_LOCAL_DB_OBSERVER_H 18 19 #include <memory> 20 #include "rdb_types.h" 21 #include "store_observer.h" 22 23 namespace OHOS { 24 namespace NativeRdb { 25 using namespace OHOS::DistributedRdb; 26 class RdbStoreLocalDbObserver : public DistributedDB::StoreObserver { 27 public: RdbStoreLocalDbObserver(const std::shared_ptr<RdbStoreObserver> & observer)28 explicit RdbStoreLocalDbObserver(const std::shared_ptr<RdbStoreObserver> &observer) : observer_(observer) {}; ~RdbStoreLocalDbObserver()29 virtual ~RdbStoreLocalDbObserver() {}; 30 void OnChange(DistributedDB::StoreObserver::StoreChangedInfo &&data) override; GetObserver()31 std::shared_ptr<RdbStoreObserver> GetObserver() 32 { 33 return observer_; 34 } 35 36 private: 37 void Convert(const DistributedDB::ChangedData &dataInfo, RdbStoreObserver::ChangeInfo &changeInfo, 38 RdbStoreObserver::ChangeType changeType); 39 std::shared_ptr<RdbStoreObserver> observer_ = nullptr; 40 }; 41 } // namespace NativeRdb 42 } // namespace OHOS 43 #endif