• 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 "result_set.h"
23 #include "rdb_types.h"
24 #include "rdb_notifier.h"
25 #include "distributeddata_relational_store_ipc_interface_code.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     };
37     using ResultSet = NativeRdb::ResultSet;
38 
39     virtual std::string ObtainDistributedTableName(const std::string &device, const std::string &table) = 0;
40 
41     virtual int32_t SetDistributedTables(
42         const RdbSyncerParam &param, const std::vector<std::string> &tables,
43         const std::vector<Reference> &references, int32_t type = DISTRIBUTED_DEVICE) = 0;
44 
45     virtual int32_t Sync(const RdbSyncerParam &param, const Option &option, const PredicatesMemo &predicates,
46         const AsyncDetail &async) = 0;
47 
48     virtual int32_t Subscribe(const RdbSyncerParam &param, const SubscribeOption &option,
49         RdbStoreObserver *observer) = 0;
50 
51     virtual int32_t UnSubscribe(const RdbSyncerParam &param, const SubscribeOption &option,
52         RdbStoreObserver *observer) = 0;
53 
54     virtual int32_t RegisterAutoSyncCallback(
55         const RdbSyncerParam &param, std::shared_ptr<DetailProgressObserver> observer) = 0;
56 
57     virtual int32_t UnregisterAutoSyncCallback(
58         const RdbSyncerParam &param, std::shared_ptr<DetailProgressObserver> observer) = 0;
59 
60     virtual std::pair<int32_t, std::shared_ptr<ResultSet>> RemoteQuery(const RdbSyncerParam &param,
61         const std::string &device, const std::string &sql, const std::vector<std::string> &selectionArgs) = 0;
62 
63     virtual int32_t InitNotifier(const RdbSyncerParam &param, sptr<IRemoteObject> notifier) = 0;
64 
65     virtual int32_t GetSchema(const RdbSyncerParam &param) = 0;
66 
67     // only use param.storeName_
68     virtual int32_t Delete(const RdbSyncerParam &param) = 0;
69 
70     virtual std::pair<int32_t, std::shared_ptr<ResultSet>> QuerySharingResource(
71         const RdbSyncerParam &param, const PredicatesMemo &predicates, const std::vector<std::string> &columns) = 0;
72 
73     virtual int32_t NotifyDataChange(const RdbSyncerParam &param, const RdbChangedData &rdbChangedData) = 0;
74 
75     inline static constexpr const char *SERVICE_NAME = "relational_store";
76 };
77 }
78 } // namespace OHOS::DistributedRdb
79 #endif