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