• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 DISTRIBUTED_RDB_RDB_SERVICE_H
17 #define DISTRIBUTED_RDB_RDB_SERVICE_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "distributeddata_relational_store_ipc_interface_code.h"
23 #include "rdb_notifier.h"
24 #include "rdb_types.h"
25 #include "result_set.h"
26 
27 namespace OHOS {
28 namespace DistributedRdb {
29 class RdbService {
30 public:
31     struct Option {
32         int32_t mode;
33         uint32_t seqNum = 0;
34         bool isAsync = false;
35         bool isAutoSync = false;
36         bool isCompensation = false;
37     };
38     using ResultSet = NativeRdb::ResultSet;
39     inline static constexpr const char *SERVICE_NAME = "relational_store";
40 
41     virtual std::string ObtainDistributedTableName(const std::string &device, const std::string &table) = 0;
42 
43     virtual int32_t SetDistributedTables(const RdbSyncerParam &param, const std::vector<std::string> &tables,
44         const std::vector<Reference> &references, bool isRebuild, int32_t type = DISTRIBUTED_DEVICE) = 0;
45 
46     virtual int32_t Sync(const RdbSyncerParam &param, const Option &option, const PredicatesMemo &predicates,
47         const AsyncDetail &async) = 0;
48 
49     virtual int32_t Subscribe(
50         const RdbSyncerParam &param, const SubscribeOption &option, RdbStoreObserver *observer) = 0;
51 
52     virtual int32_t UnSubscribe(
53         const RdbSyncerParam &param, const SubscribeOption &option, RdbStoreObserver *observer) = 0;
54 
55     virtual int32_t RegisterAutoSyncCallback(
56         const RdbSyncerParam &param, std::shared_ptr<DetailProgressObserver> observer) = 0;
57 
58     virtual int32_t UnregisterAutoSyncCallback(
59         const RdbSyncerParam &param, std::shared_ptr<DetailProgressObserver> observer) = 0;
60 
61     virtual std::pair<int32_t, std::shared_ptr<ResultSet>> RemoteQuery(const RdbSyncerParam &param,
62         const std::string &device, const std::string &sql, const std::vector<std::string> &selectionArgs) = 0;
63 
64     virtual int32_t InitNotifier(const RdbSyncerParam &param, sptr<IRemoteObject> notifier) = 0;
65 
66     virtual int32_t BeforeOpen(RdbSyncerParam &param) = 0;
67 
68     virtual int32_t AfterOpen(const RdbSyncerParam &param) = 0;
69 
70     // only use param.storeName_
71     virtual int32_t Delete(const RdbSyncerParam &param) = 0;
72 
73     virtual std::pair<int32_t, std::shared_ptr<ResultSet>> QuerySharingResource(
74         const RdbSyncerParam &param, const PredicatesMemo &predicates, const std::vector<std::string> &columns) = 0;
75 
76     virtual int32_t NotifyDataChange(
77         const RdbSyncerParam &param, const RdbChangedData &rdbChangedData, const RdbNotifyConfig &rdbNotifyConfig) = 0;
78 
79     virtual int32_t SetSearchable(const RdbSyncerParam &param, bool isSearchable) = 0;
80 
81     virtual int32_t Disable(const RdbSyncerParam &param) = 0;
82 
83     virtual int32_t Enable(const RdbSyncerParam &param) = 0;
84 
85     virtual int32_t GetPassword(const RdbSyncerParam &param, std::vector<std::vector<uint8_t>> &password) = 0;
86 
87     virtual std::pair<int32_t, uint32_t> LockCloudContainer(const RdbSyncerParam &param) = 0;
88 
89     virtual int32_t UnlockCloudContainer(const RdbSyncerParam &param) = 0;
90 
91     virtual int32_t GetDebugInfo(const RdbSyncerParam &param, std::map<std::string, RdbDebugInfo> &debugInfo) = 0;
92 
93     virtual int32_t GetDfxInfo(const RdbSyncerParam &param, DistributedRdb::RdbDfxInfo &dfxInfo) = 0;
94 
95     virtual int32_t VerifyPromiseInfo(const RdbSyncerParam &param) = 0;
96 
97     virtual int32_t ReportStatistic(const RdbSyncerParam &param, const RdbStatEvent &statEvent) = 0;
98 };
99 } // namespace DistributedRdb
100 } // namespace OHOS
101 #endif