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