• 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_SERVICE_H
17 #define DISTRIBUTED_RDB_SERVICE_H
18 
19 #include <memory>
20 #include <string>
21 #include "iremote_broker.h"
22 #include "iremote_object.h"
23 #include "rdb_types.h"
24 #include "visibility.h"
25 
26 namespace OHOS {
27 namespace DistributedRdb {
28 class API_EXPORT RdbService {
29 public:
30     enum {
31         RDB_SERVICE_CMD_OBTAIN_TABLE,
32         RDB_SERVICE_CMD_INIT_NOTIFIER,
33         RDB_SERVICE_CMD_SET_DIST_TABLE,
34         RDB_SERVICE_CMD_SYNC,
35         RDB_SERVICE_CMD_ASYNC,
36         RDB_SERVICE_CMD_SUBSCRIBE,
37         RDB_SERVICE_CMD_UNSUBSCRIBE,
38         RDB_SERVICE_CMD_REMOTE_QUERY,
39         RDB_SERVICE_CREATE_RDB_TABLE,
40         RDB_SERVICE_DESTROY_RDB_TABLE,
41         RDB_SERVICE_CMD_MAX
42     };
43     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedRdb.IRdbService");
44     virtual std::string ObtainDistributedTableName(const std::string &device, const std::string &table) = 0;
45 
46     virtual int32_t SetDistributedTables(const RdbSyncerParam &param, const std::vector<std::string> &tables) = 0;
47 
48     virtual int32_t Sync(const RdbSyncerParam &param, const SyncOption &option, const RdbPredicates &predicates,
49         const SyncCallback &callback) = 0;
50 
51     virtual int32_t Subscribe(const RdbSyncerParam &param, const SubscribeOption &option,
52         RdbStoreObserver *observer) = 0;
53 
54     virtual int32_t UnSubscribe(const RdbSyncerParam &param, const SubscribeOption &option,
55         RdbStoreObserver *observer) = 0;
56 
57     virtual int32_t RemoteQuery(const RdbSyncerParam &param, const std::string &device, const std::string &sql,
58         const std::vector<std::string> &selectionArgs, sptr<IRemoteObject> &resultSet) = 0;
59     virtual int32_t CreateRDBTable(const RdbSyncerParam &param, const std::string &writePermission,
60         const std::string &readPermission) = 0;
61 
62     virtual int32_t DestroyRDBTable(const RdbSyncerParam &param) = 0;
63 
64     virtual int32_t InitNotifier(const RdbSyncerParam &param, const sptr<IRemoteObject> notifier) = 0;
65 
66 protected:
67     virtual int32_t DoSync(const RdbSyncerParam &param, const SyncOption &option, const RdbPredicates &predicates,
68         SyncResult &result) = 0;
69 
70     virtual int32_t DoAsync(const RdbSyncerParam &param, uint32_t seqNum, const SyncOption &option,
71         const RdbPredicates &predicates) = 0;
72 
73     virtual int32_t DoSubscribe(const RdbSyncerParam &param) = 0;
74 
75     virtual int32_t DoUnSubscribe(const RdbSyncerParam &param) = 0;
76 };
77 }
78 } // namespace OHOS::DistributedRdb
79 #endif
80