• 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 "rdb_types.h"
23 #include "rdb_notifier.h"
24 #include "distributeddata_relational_store_ipc_interface_code.h"
25 
26 namespace OHOS {
27 template <typename T>
28 class sptr;
29 class IRemoteObject;
30 namespace DistributedRdb {
31 class RdbService {
32 public:
33     struct Option {
34         int32_t mode;
35         uint32_t seqNum = 0;
36         bool isAsync = false;
37     };
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, int32_t type = DISTRIBUTED_DEVICE) = 0;
43 
44     virtual int32_t Sync(const RdbSyncerParam &param, const Option &option, const PredicatesMemo &predicates,
45         const AsyncDetail &async) = 0;
46 
47     virtual int32_t Subscribe(const RdbSyncerParam &param, const SubscribeOption &option,
48         RdbStoreObserver *observer) = 0;
49 
50     virtual int32_t UnSubscribe(const RdbSyncerParam &param, const SubscribeOption &option,
51         RdbStoreObserver *observer) = 0;
52 
53     virtual int32_t RemoteQuery(const RdbSyncerParam &param, const std::string &device, const std::string &sql,
54         const std::vector<std::string> &selectionArgs, sptr<IRemoteObject> &resultSet) = 0;
55 
56     virtual int32_t InitNotifier(const RdbSyncerParam &param, sptr<IRemoteObject> notifier) = 0;
57 
58     virtual int32_t GetSchema(const RdbSyncerParam &param) = 0;
59 
60     //only use param.storeName_
61     virtual int32_t Delete(const RdbSyncerParam &param) = 0;
62 
63     inline static constexpr const char *SERVICE_NAME = "relational_store";
64 };
65 }
66 } // namespace OHOS::DistributedRdb
67 #endif