• 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 I_OBJECT_CALLBACK_H
17 #define I_OBJECT_CALLBACK_H
18 
19 #include <map>
20 #include "iremote_broker.h"
21 #include "iremote_proxy.h"
22 #include "iremote_stub.h"
23 #include "types.h"
24 
25 namespace OHOS {
26 namespace DistributedObject {
27 using namespace DistributedKv;
28 class IObjectSaveCallback : public IRemoteBroker {
29 public:
30     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedObject.IObjectSaveCallback");
31     virtual void Completed(const std::map<std::string, int32_t> &results) = 0;
32 };
33 
34 class API_EXPORT ObjectSaveCallbackStub : public IRemoteStub<IObjectSaveCallback> {
35 public:
36     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
37 };
38 
39 class API_EXPORT ObjectSaveCallbackProxy : public IRemoteProxy<IObjectSaveCallback> {
40 public:
41     explicit ObjectSaveCallbackProxy(const sptr<IRemoteObject> &impl);
42     ~ObjectSaveCallbackProxy() = default;
43     void Completed(const std::map<std::string, int32_t> &results) override;
44 
45 private:
46     static inline BrokerDelegator<ObjectSaveCallbackProxy> delegator_;
47 };
48 
49 class IObjectRevokeSaveCallback : public IRemoteBroker {
50 public:
51     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedObject.IObjectRevokeSaveCallback");
52     virtual void Completed(int32_t status) = 0;
53 };
54 
55 class API_EXPORT ObjectRevokeSaveCallbackStub : public IRemoteStub<IObjectRevokeSaveCallback> {
56 public:
57     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
58 };
59 
60 class API_EXPORT ObjectRevokeSaveCallbackProxy : public IRemoteProxy<IObjectRevokeSaveCallback> {
61 public:
62     explicit ObjectRevokeSaveCallbackProxy(const sptr<IRemoteObject> &impl);
63     ~ObjectRevokeSaveCallbackProxy() = default;
64     void Completed(int32_t status) override;
65 
66 private:
67     static inline BrokerDelegator<ObjectRevokeSaveCallbackProxy> delegator_;
68 };
69 
70 class IObjectRetrieveCallback : public IRemoteBroker {
71 public:
72     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedObject.IObjectRetrieveCallback");
73     virtual void Completed(const std::map<std::string, std::vector<uint8_t>> &results) = 0;
74 };
75 
76 class API_EXPORT ObjectRetrieveCallbackStub : public IRemoteStub<IObjectRetrieveCallback> {
77 public:
78     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
79 };
80 
81 class API_EXPORT ObjectRetrieveCallbackProxy : public IRemoteProxy<IObjectRetrieveCallback> {
82 public:
83     explicit ObjectRetrieveCallbackProxy(const sptr<IRemoteObject> &impl);
84     ~ObjectRetrieveCallbackProxy() = default;
85     void Completed(const std::map<std::string, std::vector<uint8_t>> &results) override;
86 
87 private:
88     static inline BrokerDelegator<ObjectRetrieveCallbackProxy> delegator_;
89 };
90 
91 class IObjectChangeCallback : public IRemoteBroker {
92 public:
93     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DistributedObject.IObjectChangeCallback");
94     virtual void Completed(const std::map<std::string, std::vector<uint8_t>> &results) = 0;
95 };
96 
97 class API_EXPORT ObjectChangeCallbackStub : public IRemoteStub<IObjectChangeCallback> {
98 public:
99     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
100 };
101 
102 class API_EXPORT ObjectChangeCallbackProxy : public IRemoteProxy<IObjectChangeCallback> {
103 public:
104     explicit ObjectChangeCallbackProxy(const sptr<IRemoteObject> &impl);
105     ~ObjectChangeCallbackProxy() = default;
106     void Completed(const std::map<std::string, std::vector<uint8_t>> &results) override;
107 
108 private:
109     static inline BrokerDelegator<ObjectChangeCallbackProxy> delegator_;
110 };
111 } // namespace DistributedObject
112 } // namespace OHOS
113 
114 #endif // I_KVSTORE_SYNC_CALLBACK_H
115