1 /* 2 * Copyright (c) 2021 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 DISTRIBUTEDDATAMGR_DELEGATE_MGR_CALLBACK_H 17 #define DISTRIBUTEDDATAMGR_DELEGATE_MGR_CALLBACK_H 18 19 #include "db_meta_callback_delegate.h" 20 21 namespace OHOS { 22 namespace AppDistributedKv { 23 class DelegateMgrCallback : public DistributedKv::DbMetaCallbackDelegate { 24 public: ~DelegateMgrCallback()25 virtual ~DelegateMgrCallback() {} 26 DelegateMgrCallback(DistributedDB::KvStoreDelegateManager * delegate)27 explicit DelegateMgrCallback(DistributedDB::KvStoreDelegateManager *delegate) 28 : delegate_(delegate) {} 29 GetKvStoreDiskSize(const std::string & storeId,uint64_t & size)30 bool GetKvStoreDiskSize(const std::string &storeId, uint64_t &size) override 31 { 32 if (IsDestruct()) { 33 return false; 34 } 35 return delegate_->GetKvStoreDiskSize(storeId, size) == DistributedDB::DBStatus::OK; 36 } 37 GetKvStoreKeys(std::vector<DistributedKv::StoreInfo> & entries)38 void GetKvStoreKeys(std::vector<DistributedKv::StoreInfo> &entries) override 39 { 40 (void) entries; 41 } 42 IsDestruct()43 bool IsDestruct() 44 { 45 return delegate_ == nullptr; 46 } 47 48 private: 49 DistributedDB::KvStoreDelegateManager *delegate_ {}; 50 }; 51 } // namespace AppDistributedKv 52 } // namespace OHOS 53 #endif // DISTRIBUTEDDATAMGR_DELEGATE_MGR_CALLBACK_H 54