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 OBJECT_CALLBACK_H 17 #define OBJECT_CALLBACK_H 18 19 #include "iobject_callback.h" 20 21 namespace OHOS { 22 namespace ObjectStore { 23 using namespace DistributedObject; 24 class ObjectSaveCallback : public ObjectSaveCallbackStub { 25 public: 26 ObjectSaveCallback(const std::function<void(const std::map<std::string, int32_t> &)> &callback); 27 void Completed(const std::map<std::string, int32_t> &results) override; 28 29 private: 30 const std::function<void(const std::map<std::string, int32_t> &)> callback_; 31 }; 32 33 class ObjectRevokeSaveCallback : public ObjectRevokeSaveCallbackStub { 34 public: 35 ObjectRevokeSaveCallback(const std::function<void(int32_t)> &callback); 36 void Completed(int32_t) override; 37 38 private: 39 const std::function<void(int32_t status)> callback_; 40 }; 41 42 class ObjectRetrieveCallback : public ObjectRetrieveCallbackStub { 43 public: 44 ObjectRetrieveCallback(const std::function<void(const std::map<std::string, std::vector<uint8_t>> &)> &callback); 45 void Completed(const std::map<std::string, std::vector<uint8_t>> &results) override; 46 47 private: 48 const std::function<void(const std::map<std::string, std::vector<uint8_t>> &)> callback_; 49 }; 50 51 class ObjectChangeCallback : public ObjectChangeCallbackStub { 52 public: 53 ObjectChangeCallback(const std::function<void(const std::map<std::string, std::vector<uint8_t>> &)> &callback); 54 void Completed(const std::map<std::string, std::vector<uint8_t>> &results) override; 55 56 private: 57 const std::function<void(const std::map<std::string, std::vector<uint8_t>> &)> callback_; 58 }; 59 } // namespace DistributedKv 60 } // namespace OHOS 61 62 #endif // OBJECT_CALLBACK_H 63