• 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_STUB_H
17 #define DISTRIBUTED_RDB_SERVICE_STUB_H
18 
19 #include "iremote_stub.h"
20 #include "rdb_service.h"
21 #include "rdb_notifier.h"
22 #include "feature/feature_system.h"
23 
24 namespace OHOS::DistributedRdb {
25 using RdbServiceCode = OHOS::DistributedRdb::RelationalStore::RdbServiceInterfaceCode;
26 
27 class RdbServiceStub : public RdbService, public DistributedData::FeatureSystem::Feature {
28 public:
29     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedRdb.IRdbService");
30     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply) override;
31 
32 private:
33     static bool CheckInterfaceToken(MessageParcel& data);
34 
35     int32_t OnRemoteObtainDistributedTableName(MessageParcel& data, MessageParcel& reply);
36 
37     int32_t OnGetSchema(MessageParcel& data, MessageParcel& reply);
38 
39     int32_t OnDelete(MessageParcel& data, MessageParcel& reply);
40 
41     int32_t OnRemoteInitNotifier(MessageParcel& data, MessageParcel& reply);
42 
43     int32_t OnRemoteSetDistributedTables(MessageParcel& data, MessageParcel& reply);
44 
45     int32_t OnRemoteDoSync(MessageParcel& data, MessageParcel& reply);
46 
47     int32_t OnRemoteDoAsync(MessageParcel& data, MessageParcel& reply);
48 
49     int32_t OnRemoteDoSubscribe(MessageParcel& data, MessageParcel& reply);
50 
51     int32_t OnRemoteDoUnSubscribe(MessageParcel& data, MessageParcel& reply);
52 
53     int32_t OnRemoteDoRemoteQuery(MessageParcel& data, MessageParcel& reply);
54 
55     using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &);
56     static constexpr RequestHandle HANDLERS[static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_MAX)] = {
57         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_OBTAIN_TABLE)] =
58             &RdbServiceStub::OnRemoteObtainDistributedTableName,
59         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_INIT_NOTIFIER)] = &RdbServiceStub::OnRemoteInitNotifier,
60         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SET_DIST_TABLE)] =
61             &RdbServiceStub::OnRemoteSetDistributedTables,
62         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SYNC)] = &RdbServiceStub::OnRemoteDoSync,
63         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_ASYNC)] = &RdbServiceStub::OnRemoteDoAsync,
64         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_SUBSCRIBE)] = &RdbServiceStub::OnRemoteDoSubscribe,
65         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_UNSUBSCRIBE)] = &RdbServiceStub::OnRemoteDoUnSubscribe,
66         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_REMOTE_QUERY)] = &RdbServiceStub::OnRemoteDoRemoteQuery,
67         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_GET_SCHEMA)] = &RdbServiceStub::OnGetSchema,
68         [static_cast<uint32_t>(RdbServiceCode::RDB_SERVICE_CMD_DELETE)] = &RdbServiceStub::OnDelete
69     };
70 };
71 } // namespace OHOS::DistributedRdb
72 #endif
73